/* FlashTrans — 蓝白极简 */

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-weak: #eff6ff;
  --ink: #1e293b;
  --ink-weak: #64748b;
  --ink-faint: #94a3b8;
  --line: #dbe4f0;
  --line-focus: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* 顶栏 */
.site-header {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; }

.logo { width: 22px; height: 22px; fill: var(--blue); }

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink);
}

.tagline { font-size: 13px; color: var(--ink-faint); letter-spacing: 1px; }

/* 垂直居中容器 */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 双栏主体 */
.panels {
  flex-shrink: 0;
  max-width: 773px;
  width: 100%;
  margin: 24px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 64px;
  min-height: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  height: calc(30vh);
  min-height: 150px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.panel:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--line-focus);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title { font-size: 14px; font-weight: 600; color: var(--ink); }

.direction-tag {
  font-size: 12px;
  color: var(--blue);
  background: var(--blue-weak);
  border-radius: 999px;
  padding: 3px 12px;
  letter-spacing: 0.5px;
}

.direction-tag.idle { color: var(--ink-faint); background: #f4f7fb; }

.status { font-size: 12px; color: var(--blue); }

textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  font-size: 15px;
  line-height: 1.8;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
}

textarea::placeholder { color: var(--ink-faint); }

.output {
  flex: 1;
  padding: 16px;
  font-size: 15px;
  line-height: 1.8;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  background: #f6f8fa;
}

.output .placeholder { color: #a8c0e8; }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.btn-group { display: flex; gap: 6px; align-items: center; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--ink-weak);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon svg { width: 15px; height: 15px; display: block; }

.btn-icon:hover {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-weak);
}

.btn-icon:active { transform: scale(0.94); }

.char-count { font-size: 12px; color: var(--ink-faint); }

/* 翻译按钮行 */
.translate-row {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 72px 24px 24px;
}

.btn-primary {
  font-size: 17px;
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  font-weight: 700;
  letter-spacing: 4px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  color: #ffffff;
  background: var(--blue);
  border: none;
  border-radius: 8px;
  padding: 11px 52px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-primary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.btn-primary:disabled {
  background: #93b4f5;
  cursor: not-allowed;
  transform: none;
}

/* 录音态 */
.btn-primary.recording {
  background: var(--danger);
  letter-spacing: 1px;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

.btn-primary.recording:hover { background: var(--danger); }

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.hint { font-size: 12px; color: var(--ink-faint); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  padding: 9px 20px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 80vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* 桌面端（视口 >768px）：左右双栏，左原文右译文；移动端保持现状 */
@media (min-width: 769px) {
  .panels {
    grid-template-columns: 1fr 1fr;
    /* 拉宽至与顶部分割线同宽，面板外边缘与线两端对齐 */
    max-width: 1380px;
    padding: 0;
  }

  /* 每窗高度 = 译文高 + 间隔 + 原文高，尽量多显示长文 */
  .panel {
    height: calc(60vh + 64px);
    min-height: 364px;
  }

  /* DOM 顺序为译文在前（保持移动端顺序），桌面端视觉顺序改为原文在左 */
  .panel-input { order: 1; }
  .panel-output { order: 2; }
}

/* 移动端（视口 ≤768px 自动切换） */
@media (max-width: 768px) {
  /* 品牌居中放大，去掉分割线 */
  .site-header { padding: 16px; justify-content: center; border-bottom: none; }
  .logo { width: 28px; height: 28px; }
  .brand-name { font-size: 24px; }
  .tagline { display: none; }

  /* 移动端整体垂直居中 */
  .stage { justify-content: center; }

  .panels {
    gap: 48px;
    margin-top: 0;
    padding: 0 12px;
  }

  .panel {
    height: auto;
    min-height: 0;
    border-radius: 10px;
  }

  .panel-head { padding: 10px 12px; }
  .panel-foot { padding: 8px 10px; }

  /* 16px 防止 iOS 聚焦输入框时自动放大页面 */
  textarea, .output {
    min-height: 150px;
    font-size: 16px;
    padding: 12px;
  }

  /* 触控目标放大 */
  .btn-icon { width: 34px; height: 34px; }
  .btn-icon svg { width: 16px; height: 16px; display: block; }

  /* 翻译按钮下移并放大 50% */
  .translate-row { padding: 48px 24px 24px; gap: 6px; }
  .btn-primary { padding: 13px 59px; font-size: 20px; letter-spacing: 6px; }
  .kbd-hint { display: none; }

  .toast { bottom: 24px; }
}
