/* ============================================================
   人机协同日语写作平台 · 全局样式
   设计规范：对比 / 重复 / 对齐 / 亲密性
   间距基准 8px；边框 1px 轻线 + 分级投影分层（不再用粗描边）
   主色：教学蓝（专业可靠）+ 辅助青 + 琥珀强调；含暗色模式
   ============================================================ */

:root {
  /* 主色：教学蓝（专业可靠，清亮） */
  --brand: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-active: #1E40AF;
  --brand-soft: #EAF1FE;
  --brand-soft-2: #F5F8FF;
  --brand-ink: #ffffff;

  /* 辅助青 / 强调琥珀 */
  --accent: #0891B2;
  --accent-soft: #E2F6FB;

  /* 中性 */
  --bg: #F5F7FB;
  --panel: #ffffff;
  --panel-alt: #F4F7FB;
  --ink: #0F172A;
  --ink-soft: #475569;
  --muted: #64748B;

  /* 状态 */
  --ok: #15803D;        --ok-soft: #DCFCE7;
  --warn: #B45309;      --warn-soft: #FEF3E2;
  --danger: #DC2626;    --danger-soft: #FEECEC;  --danger-border: #F3C6C6;
  --info: #0891B2;      --info-soft: #E2F6FB;
  --ai: #B45309;        --ai-soft: #FEF6E7;      --ai-border: #EBCB8B;

  /* 边框：1px 轻线，靠投影分层 */
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-light: #EEF2F7;
  --border-width: 1px;

  /* 间距（4/8 基准） */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  /* 圆角 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* 冷调分层阴影 */
  --shadow-xs: 0 1px 2px rgba(16,24,40,.04);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md: 0 2px 8px rgba(16,24,40,.08), 0 8px 24px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14), 0 4px 12px rgba(16,24,40,.08);
  --shadow-brand: 0 4px 14px rgba(37,99,235,.30);

  /* 渐变（质感来源） */
  --grad-brand: linear-gradient(135deg,#2563EB,#0891B2);
  --grad-brand-v: linear-gradient(180deg,#3B82F6,#2563EB);
  --grad-sidebar: linear-gradient(180deg,#0B1220,#101A2E);

  --font: "Microsoft YaHei","Hiragino Sans GB","Noto Sans CJK SC",system-ui,sans-serif;
  --font-ja: "Yu Gothic","Hiragino Sans","Meiryo",var(--font);

  --focus-ring: rgba(37,99,235,.22);
  --mask: rgba(15,23,42,.5);
}

/* 暗色模式（自动跟随系统） */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220; --panel: #121A2A; --panel-alt: #1B2740;
    --ink: #E6EDF7; --ink-soft: #A9B6CC; --muted: #7E8CA6;
    --brand: #60A5FA; --brand-hover: #93C5FD; --brand-soft: #16233B; --brand-soft-2: #1B2740;
    --accent: #22D3EE; --accent-soft: #0E2A33;
    --border: #26344F; --border-strong: #33415C; --border-light: #1E2A42;
    --ok-soft:#0F2A1B; --warn-soft:#2B2110; --danger-soft:#2A1418; --info-soft:#0E2A33; --ai-soft:#2B2110;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
    --shadow-md: 0 8px 24px rgba(0,0,0,.5);
    --grad-sidebar: linear-gradient(180deg,#080D17,#0E1626);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------
   布局
   ------------------------------------------------------------ */
.layout { display: flex; min-height: 100vh; }

/* 深色侧栏：建立明确"骨架感" */
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: var(--grad-sidebar);
  border-right: 1px solid rgba(255,255,255,.08);
  padding: var(--sp-3) 12px;
}
.sidebar-brand {
  padding: 0 12px var(--sp-3);
  font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}
.sidebar nav { display: flex; flex-direction: column; }
.nav-item {
  padding: 10px 14px; margin-bottom: 4px;
  color: #94A3B8; cursor: pointer;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: var(--sp-2);
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active {
  background: rgba(37,99,235,.25);
  color: #fff; font-weight: 600;
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(64,140,255,.35);
}
/* 待开放入口（深色侧栏上的弱提示） */
.nav-item.soon { color: #64748B; cursor: not-allowed; }
.nav-item.soon:hover { background: transparent; }
.nav-soon-mark { font-size: 11px; margin-left: auto; color: #64748B; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-5); gap: var(--sp-3);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.topbar .who { color: var(--muted); font-size: 13px; }

.content { padding: var(--sp-5); flex: 1; overflow-x: hidden; }

/* ------------------------------------------------------------
   卡片与面板
   ------------------------------------------------------------ */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  transition: box-shadow .18s, transform .18s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
  font-size: 15px; font-weight: 700; margin: 0 0 var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
}
/* 标题左侧色条，强化区块识别 */
.card-title::before {
  content: ""; width: 4px; height: 15px; border-radius: 2px;
  background: var(--grad-brand); margin-right: 10px; flex: none;
}
.card-desc { color: var(--muted); font-size: 13px; margin: -6px 0 var(--sp-3); }

.panel-section + .panel-section {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border-light);
}

/* ------------------------------------------------------------
   按钮（可见的质感升级）
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  font-size: 13px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--brand-soft-2); border-color: var(--border-strong); box-shadow: var(--shadow-sm); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  background: var(--grad-brand-v);
  border-color: var(--brand);
  color: var(--brand-ink); font-weight: 600;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(37,99,235,.38); }

.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 26px; font-size: 15px; }
.btn-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ------------------------------------------------------------
   表单
   ------------------------------------------------------------ */
.field { margin-bottom: var(--sp-3); }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); }

input[type=text], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  background: var(--panel); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border: 2px solid var(--brand);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.8; }
textarea.ja { font-family: var(--font-ja); font-size: 15px; }
.field-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 200px; }

/* ------------------------------------------------------------
   KPI（学情 / 成长，原无样式 → 补齐）
   ------------------------------------------------------------ */
.kpi {
  flex: 0 0 auto; min-width: 118px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--panel-alt);
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  box-shadow: var(--shadow-xs);
}
.kpi .v { font-size: 22px; font-weight: 700; color: var(--brand); line-height: 1.25; }
.kpi .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------
   两栏栅格 / 列表项
   ------------------------------------------------------------ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-light); margin-bottom: 8px;
  background: var(--panel); transition: background .15s, border-color .15s;
}
.list-item:hover { background: var(--brand-soft-2); border-color: var(--border); }

/* ------------------------------------------------------------
   表格
   ------------------------------------------------------------ */
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--shadow-xs);
}
th, td {
  padding: 10px 14px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}
th {
  background: var(--brand-soft); color: var(--brand-hover);
  font-weight: 600; font-size: 12px; letter-spacing: .4px;
  position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background .12s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--brand-soft-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------
   徽章（胶囊化）
   ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  border: 1px solid transparent; background: var(--panel-alt); color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.ai { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-border); }

/* ------------------------------------------------------------
   提示条（左侧状态色条）
   ------------------------------------------------------------ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-left-width: 4px;
  background: var(--panel); font-size: 13px; margin-bottom: var(--sp-3);
  color: var(--ink);
}
.alert.ok { border-left-color: var(--ok); }
.alert.warn { border-left-color: var(--warn); }
.alert.danger { border-left-color: var(--danger); }
.alert.info { border-left-color: var(--brand); }

/* 进度条 */
.progress { height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: var(--grad-brand); width: 0; transition: width .25s; }

/* 空状态 */
.empty {
  padding: var(--sp-5) var(--sp-3); text-align: center;
  color: var(--muted); font-size: 13px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--panel-alt);
}

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: var(--mask); display: flex; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-3); }
.modal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 88vh; overflow: auto;
  padding: var(--sp-4);
}
.modal.wide { max-width: 880px; }
.modal h3 { margin: 0 0 var(--sp-3); font-size: 16px; }

/* ------------------------------------------------------------
   工具类
   ------------------------------------------------------------ */
.row { display: flex; gap: var(--sp-2); align-items: center; }
.row-between { display: flex; gap: var(--sp-2); align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.center { justify-content: center; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------
   登录页
   ------------------------------------------------------------ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-3);
  background: radial-gradient(1200px 600px at 50% -10%, #E8F0FE 0%, #F5F7FB 60%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6) var(--sp-5);
}
.login-card h1 {
  font-size: 20px; margin: 0 0 4px; text-align: center;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: var(--sp-4); }
.login-tabs { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.login-tabs button {
  flex: 1; padding: 8px; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--ink-soft);
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius-sm);
  transition: all .15s;
}
.login-tabs button.active {
  background: var(--grad-brand-v); border-color: var(--brand);
  color: var(--brand-ink); font-weight: 600; box-shadow: var(--shadow-brand);
}
.login-foot { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.login-alert { min-height: 20px; }

/* ------------------------------------------------------------
   评阅工作台
   ------------------------------------------------------------ */
.review-layout { display: flex; gap: 12px; align-items: flex-start; }

.review-list { width: 268px; flex: 0 0 268px; padding: 12px; }
.list-scroll { max-height: calc(100vh - 220px); overflow-y: auto; }
.review-item {
  padding: 10px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer; background: var(--panel);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.review-item:hover { background: var(--brand-soft-2); border-color: var(--border); }
.review-item.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }

.review-detail { flex: 1; min-width: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-light); margin-bottom: -8px; }
.tab {
  padding: 8px 16px; cursor: pointer; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); font-weight: 600; border-bottom-color: var(--brand); }

.score-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.score-row:last-of-type { border-bottom: none; }
.score-ai { font-size: 17px; font-weight: 700; color: var(--muted); min-width: 34px; text-align: center; }

.essay-text { white-space: pre-wrap; line-height: 1.9; padding: 12px 14px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--panel-alt); font-size: 14px; }
.essay-text.ja { font-family: var(--font-ja); font-size: 15px; }

.edit-item { padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--panel-alt); }
.diff { font-family: var(--font-ja); font-size: 14px; line-height: 1.8; }
/* 修订痕迹配色：删除=红底删除线，新增=绿底下划线（形状差异，兼顾色觉障碍）。
   全局定义，使表格单元格内的修订痕迹也能跟随主题（不再依赖各模板内联覆盖）。 */
del {
  background: var(--danger-soft);
  color: var(--danger);
  text-decoration: line-through;
}
ins {
  background: var(--ok-soft);
  color: var(--ok);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.bar-label { width: 150px; flex: 0 0 150px; font-size: 13px; color: var(--ink-soft); }
.bar-track { flex: 1; height: 16px; background: var(--border-light); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
/* JS 实际写的是 <span class="bar-fill">，旧选择器 .bar-track>i 对不上 → 条形图空白。两者都支持。 */
.bar-track > i, .bar-track > .bar-fill { display: block; height: 100%; background: var(--grad-brand); width: 0; transition: width .4s ease; }
.bar-num, .bar-value { width: 56px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

.suggest-item { padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--panel-alt); }

.batch-log { max-height: 260px; overflow-y: auto; margin-top: 10px; }
.batch-log .text-sm { padding: 3px 0; border-bottom: 1px solid var(--border-light); }
.text-sm.ok { color: var(--ok); }
.text-sm.err { color: var(--danger); }

/* ------------------------------------------------------------
   悬浮「译」按钮 / 通知气泡 / Toast 动画（新增）
   ------------------------------------------------------------ */
.float-translate {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  background: var(--grad-brand); border: none;
  box-shadow: var(--shadow-brand); cursor: pointer;
  opacity: .85; transition: opacity .15s, transform .15s;
}
.float-translate:hover { opacity: 1; transform: scale(1.08); }

.notice-dot {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: var(--radius-pill);
  background: var(--danger); color: #fff; font-size: 11px; line-height: 16px;
  text-align: center; box-shadow: 0 0 0 2px var(--panel);
}

@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
#jpwp-toast > .alert { animation: toastIn .22s ease-out; }

/* ------------------------------------------------------------
   响应式：笔记本侧边栏 / 手机底部标签
   ------------------------------------------------------------ */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 0;
    position: sticky; top: 0; z-index: 20;
  }
  .sidebar-brand { display: none; }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    flex: 0 0 auto;
    padding: 12px var(--sp-3);
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    justify-content: center;
  }
  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .topbar { padding: 0 var(--sp-3); }
  .topbar h1 { font-size: 15px; }
  .content { padding: var(--sp-3); }
  .card { padding: var(--sp-3); }
  .field-row > * { min-width: 100%; }

  /* 评阅工作台：手机上改为上下堆叠，列表横向滚动 */
  .review-layout { flex-direction: column; }
  .review-list { width: 100%; flex: none; }
  .list-scroll { max-height: 220px; }
  .score-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bar-label { width: 96px; flex: 0 0 96px; font-size: 12px; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; padding: 8px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
}
