/* 配色：白底为主（60%），深蓝为主色（30%），青绿/红色作点缀（10%） */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --primary: #2f5597;
  --primary-dark: #234275;
  --accent: #0f766e;
  --danger: #b91c1c;
  --radius: 10px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%; /* 禁止手机浏览器自动放大字体 */
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 手机地址栏伸缩时仍占满可视高度 */
  padding: var(--gap);
  padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom)); /* 全面屏底部安全区 */
  gap: 12px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.brand-title { font-size: 22px; font-weight: 700; color: var(--primary); }
.brand-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.field-label { font-size: 14px; color: var(--ink-soft); }
input[type="text"], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
}
input[type="text"] { width: 230px; }

.btn {
  font: inherit;
  font-size: 15px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border-color: #b9c8de; }
.btn-outline:hover:not(:disabled) { background: #eef3fa; }
.btn-text { background: transparent; color: var(--primary); text-decoration: underline; padding: 6px 8px; font-size: 14px; }

.badge {
  font-size: 13px;
  border-radius: 999px;
  padding: 5px 12px;
  background: #f1f5f9;
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge-ok { background: #e7f6ef; color: var(--accent); }
.badge-error { background: #fdeaea; color: var(--danger); }
.badge-run { background: #eaf1fb; color: var(--primary); }
.lock-group { display: inline-flex; align-items: center; gap: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.lock-group input[type="password"] { width: 120px; }

.meta-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 0 4px;
}
.meta-hint { margin-left: auto; }

.dual-window {
  flex: 1;
  min-height: 260px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.window-head {
  padding: 12px 18px;
  font-weight: 700;
  font-size: 17px;
  border-bottom: 2px solid var(--line);
  background: #fbfcfe;
}
.window-head-zh { border-right: 1px solid var(--line); color: var(--primary); }
.window-head-ja { color: var(--accent); }
.window-head span { font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-left: 8px; }

.lines {
  grid-column: 1 / -1;
  overflow-y: auto;
  padding: 8px 0;
  scroll-behavior: smooth;
}
.line-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px dashed var(--line);
  min-height: 56px;
}
.line-row:last-child { border-bottom: none; }
.line-row.active { background: #f5f9ff; }
.cell {
  padding: 12px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 17px;
}
.cell.zh { border-right: 1px solid var(--line); }
.cell.ja { color: #134e4a; }
/* 中文原话里夹带的日语表达：黄色高亮，便于老师挑出来加工或删除 */
.ja-mix { background: #fff3cd; color: #92400e; border-radius: 3px; padding: 0 2px; font-weight: 600; }
.cell.waiting { color: #9ca3af; font-size: 15px; }
.empty-hint { padding: 40px 20px; text-align: center; color: var(--ink-soft); font-size: 16px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.summary-output {
  flex: 1 0 100%;
  max-height: 190px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal[hidden] { display: none; }
.modal-box {
  width: min(640px, 92vw);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 16px 40px rgba(0,0,0,.2);
}
.modal-box h3 { margin: 0 0 8px; color: var(--primary); }
.modal-hint { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; }
.modal-box textarea { width: 100%; height: 260px; font-family: Consolas, monospace; font-size: 14px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ========== 手机适配（宽度 ≤ 720px） ========== */
@media (max-width: 720px) {
  :root { --gap: 10px; }
  .app-shell { padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); gap: 8px; }

  /* 顶栏：标题缩小，课程名独占一行，按钮适合手指点按 */
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand-title { font-size: 18px; }
  .brand-sub { font-size: 12px; }
  .controls { width: 100%; gap: 6px; }
  .field-label { display: none; }
  #courseTitle { flex: 1 1 100%; width: 100%; font-size: 16px; }
  .btn { min-height: 44px; font-size: 16px; padding: 10px 12px; }
  .btn-text { min-height: auto; font-size: 14px; }
  .lock-group { flex: 1 1 100%; padding: 8px 0 0; border-left: none; border-top: 1px dashed var(--line); }
  .lock-group input[type="password"] { flex: 1; width: auto; font-size: 16px; }
  #statusBadge { font-size: 12px; }

  .meta-bar { gap: 10px; font-size: 12px; }
  .meta-hint { display: none; }
  #scrollBtn { margin-left: auto; }

  /* 双窗口改为"逐句卡片"：中文在上、日文在下，各自带语言小标签 */
  .dual-window { min-height: 180px; }
  .window-head { display: none; }
  .line-row { grid-template-columns: 1fr; padding: 8px 0; }
  .cell { padding: 6px 12px; font-size: 16px; line-height: 1.55; }
  .cell.zh { border-right: none; border-bottom: 1px dashed var(--line); }
  .cell.zh::before, .cell.ja::before {
    display: inline-block;
    min-width: 20px;
    margin-right: 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    vertical-align: 1px;
  }
  .cell.zh::before { content: "中"; background: #eaf1fb; color: var(--primary); }
  .cell.ja::before { content: "日"; background: #e7f6ef; color: var(--accent); }

  .toolbar { padding: 8px 10px; gap: 8px; }
  .tool-group { gap: 6px; }
  .tool-group select { min-height: 44px; font-size: 16px; }
  .summary-output { max-height: 130px; font-size: 13px; }

  .modal-box { width: 94vw; padding: 16px; }
  .modal-box textarea { height: 50vh; font-size: 16px; }
  .modal-actions .btn { flex: 1; }
}
