/* ==========================================================================
   作文誊清台 · 样式
   设计基调：旧纸、墨色、朱砂印章
   ========================================================================== */

:root {
  --bg: #f3efe6;
  --surface: #fffdf8;
  --surface-2: #faf6ec;
  --surface-3: #f4ede0;
  --ink: #241f1a;
  --ink-soft: #5d564b;
  --ink-faint: #948b7c;
  --line: #e7decd;
  --line-strong: #d5c7ae;
  --accent: #b2472a;
  --accent-deep: #8d341c;
  --accent-soft: #f8e8e1;
  --jade: #2f6f5e;
  --jade-soft: #e4f0ea;
  --amber: #9a6b1f;
  --amber-soft: #f8eed8;
  --blue: #34597d;
  --blue-soft: #e6eef6;
  --danger: #b23a3a;
  --danger-soft: #fbe9e7;

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(74, 54, 32, .05), 0 2px 6px rgba(74, 54, 32, .04);
  --shadow-md: 0 2px 4px rgba(74, 54, 32, .05), 0 16px 36px rgba(74, 54, 32, .09);
  --shadow-lg: 0 30px 80px rgba(40, 26, 12, .28);

  --font-ui: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC",
    "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-kai: "Kaiti SC", "KaiTi", "STKaiti", "楷体", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 6% -10%, #fffbf1 0%, rgba(255, 251, 241, 0) 62%),
    radial-gradient(900px 460px at 98% -6%, #efe6d4 0%, rgba(239, 230, 212, 0) 58%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    linear-gradient(rgba(120, 96, 64, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 96, 64, .045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .5), transparent 42%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .5), transparent 42%);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

::selection { background: #f3d9cf; }

/* ---------------------------------------------------------------- 布局 */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(255, 253, 248, .82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(213, 199, 174, .55);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-seal {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #c05233, #93351d);
  color: #fff6ea;
  font-family: var(--font-kai);
  font-size: 26px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 6px 14px rgba(150, 55, 30, .3);
  transform: rotate(-3deg);
}

.brand-copy h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .04em;
}

.brand-copy p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, .14);
  flex: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.user-chip[hidden] { display: none; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--ink); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quota-chip {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #ecd8a8;
  background: #fdf1d6;
  color: #8a5a12;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.user-chip .btn { height: 28px; padding: 0 9px; font-size: 11.5px; border-radius: 8px; }

/* ---------------------------------------------------------------- 状态行 */

.statusline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 34px) 0;
  flex-wrap: wrap;
  min-height: 40px;
}

.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 253, 248, .75);
  border: 1px solid var(--line);
}

.stat b {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat.is-accent b { color: var(--accent); }
.stat.is-jade b { color: var(--jade); }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  min-width: 240px;
}

.progress-track {
  width: 160px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #c8663f, #a53d22);
  transition: width .3s ease;
}

/* ---------------------------------------------------------------- 作文卡片 */

.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(352px, 1fr));
  align-items: start;
  gap: 18px;
  padding: 20px clamp(16px, 3vw, 34px) 40px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 17px 18px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-no {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-kai);
  font-size: 16px;
  color: var(--ink-soft);
  letter-spacing: .02em;
}

.card-title {
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: .01em;
  outline: none;
  transition: border-color .16s ease;
}

.card-title::placeholder { color: var(--ink-faint); font-weight: 500; }
.card-title:hover { border-bottom-color: var(--line); }
.card-title:focus { border-bottom-color: var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: .02em;
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}

.pill--todo { background: var(--amber-soft); color: var(--amber); }
.pill--done { background: var(--jade-soft); color: var(--jade); }
.pill--run { background: var(--blue-soft); color: var(--blue); }
.pill--run::before { animation: pulse 1.1s ease-in-out infinite; }
.pill--err { background: var(--danger-soft); color: var(--danger); }
.pill--idle { background: var(--surface-3); color: var(--ink-faint); }

@keyframes pulse {
  0%, 100% { opacity: .35; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.icon-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* 缩略图 */

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: zoom-in;
  padding: 0;
  transition: transform .16s ease, box-shadow .16s ease;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.thumb.dragging { opacity: .4; }
.thumb.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }

.thumb-no {
  position: absolute;
  left: 5px;
  bottom: 5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(28, 22, 16, .68);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.thumb-x {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(28, 22, 16, .6);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .16s ease, background .16s ease;
}

.thumb:hover .thumb-x { opacity: 1; }
.thumb-x:hover { background: var(--danger); }

.thumb.add {
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.thumb.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.thumb.add span { font-size: 22px; line-height: 1; font-weight: 300; }
.thumb.add small { display: block; font-size: 10px; margin-top: 3px; letter-spacing: .05em; }

.thumb.add.is-full {
  border-style: solid;
  border-color: var(--line);
  color: var(--ink-faint);
  cursor: default;
  opacity: .6;
}

.card.is-uploading { opacity: .7; pointer-events: none; }

.card.drop-active { border-color: var(--accent); background: #fffaf6; box-shadow: 0 0 0 3px var(--accent-soft); }

/* 元信息 */

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 26px;
  font-size: 12px;
  color: var(--ink-faint);
  flex-wrap: wrap;
}

.meta-text { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-sep {
  display: inline-block;
  width: 1px;
  height: 11px;
  background: var(--line-strong);
}
.meta-err { color: var(--danger); display: inline-flex; align-items: center; gap: 4px; }

.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-3);
  gap: 2px;
}

.seg button {
  border: none;
  background: transparent;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(74, 54, 32, .12);
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.card-actions .btn { flex: 1; min-width: 74px; }

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: .01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease,
    transform .12s ease, box-shadow .16s ease;
  user-select: none;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #bc4e2f, #a83f22);
  color: #fff8ef;
  box-shadow: 0 1px 2px rgba(120, 45, 20, .25), 0 6px 16px rgba(160, 60, 30, .22);
}

.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #c65a39, #b04526); }

.btn-ghost {
  background: rgba(255, 253, 248, .7);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover:not(:disabled) { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }

.btn-outline {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-accent {
  background: var(--accent-soft);
  border-color: #eccfc4;
  color: var(--accent-deep);
}

.btn-accent:hover:not(:disabled) { background: #f6ddd5; border-color: var(--accent); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

.linklike {
  border: none;
  background: none;
  padding: 0;
  color: var(--ink-faint);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.linklike:hover { color: var(--accent); }

/* 加载小圈 */
.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.8px solid currentColor;
  border-top-color: transparent;
  animation: spin .8s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 空状态 */

.empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 64px 24px 72px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 26px;
  background: rgba(255, 253, 248, .55);
}

.empty-art {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(150deg, #fff7ea, #f2e6d2);
  border: 1px solid var(--line);
  font-family: var(--font-kai);
  font-size: 46px;
  color: #c2a382;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .5);
}

.empty h2 { margin: 4px 0 0; font-size: 19px; font-weight: 650; }
.empty p { margin: 0; font-size: 13.5px; color: var(--ink-faint); line-height: 1.9; max-width: 460px; }

/* ---------------------------------------------------------------- 页脚 */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 3vw, 34px) 22px;
  font-size: 11.5px;
  color: var(--ink-faint);
  border-top: 1px solid rgba(213, 199, 174, .45);
}

.footer code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- 弹层 */

.modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
.modal-root.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 28, 18, .42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade .18s ease;
}

.modal-panel {
  position: relative;
  margin: clamp(16px, 5vh, 56px) auto;
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .24s cubic-bezier(.2, .9, .3, 1);
}

.modal-panel--wide { width: min(960px, calc(100% - 28px)); }
.modal-panel--paper { width: min(1080px, calc(100% - 28px)); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}

.modal-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: .02em;
}

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

.modal-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.modal-body {
  padding: 18px 20px 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
}

.modal-foot .spacer { flex: 1; }
.modal-foot .hint { font-size: 12px; color: var(--ink-faint); }

/* ---------------------------------------------------------------- 设置 */

.form-section { margin-bottom: 22px; }
.form-section:last-child { margin-bottom: 0; }

.form-section h4 {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .08em;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section h4::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.field > label {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: right;
}

.field .control { min-width: 0; }

.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fffefa;
  font-size: 13px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.8; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(178, 71, 42, .12);
}

.input::placeholder { color: #b3a997; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b8170' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.field-note { margin: -4px 0 12px 108px; font-size: 11.5px; color: var(--ink-faint); line-height: 1.7; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); }

.provider-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.provider-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fffefa;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.provider-option b { font-size: 13px; font-weight: 650; }
.provider-option small { font-size: 11px; color: var(--ink-faint); }

.provider-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(178, 71, 42, .09);
}

.test-result {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.7;
  display: none;
}

.test-result.show { display: block; }
.test-result.ok { background: var(--jade-soft); color: var(--jade); }
.test-result.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- 编辑器 */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: var(--surface-3);
  margin-bottom: 14px;
  flex: none;
}

.tabs button {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.tabs button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(74, 54, 32, .12);
}

.editor-pane { display: none; flex-direction: column; min-height: 0; }
.editor-pane.active { display: flex; }

.editor-textarea {
  width: 100%;
  min-height: 340px;
  max-height: 52vh;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fffefa;
  font-family: var(--font-kai);
  font-size: 16px;
  line-height: 2;
  resize: vertical;
  outline: none;
}

.editor-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178, 71, 42, .1); }

.diff-wrap {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fffefa;
  padding: 16px 18px;
  max-height: 52vh;
  overflow: auto;
}

.diff-legend {
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-bottom: 10px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line);
}

.diff-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
}

.diff-legend .del { background: #f0c4bb; }
.diff-legend .ins { background: #b9dccf; }

.diff-body {
  font-family: var(--font-kai);
  font-size: 16px;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-body del {
  text-decoration: none;
  color: #a13325;
  background: #fbe3dd;
  border-radius: 3px;
}

.diff-body ins {
  text-decoration: none;
  color: #1f5c49;
  background: #dff0e8;
  border-radius: 3px;
}

.diff-empty { color: var(--ink-faint); font-size: 13px; text-align: center; padding: 30px 0; }

/* ---------------------------------------------------------------- 方格纸 */

.paper-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--ink-soft);
  flex: none;
}

.paper-toolbar .group { display: flex; align-items: center; gap: 7px; }
.paper-toolbar .group > span { color: var(--ink-faint); font-size: 12px; }
.paper-toolbar .select { width: auto; height: 30px; font-size: 12px; padding: 0 26px 0 9px; }
.paper-toolbar .spacer { flex: 1; }

.paper-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 26px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, .6), transparent 50%),
    #e9e2d4;
}

.paper-pages { display: flex; flex-direction: column; align-items: center; gap: 26px; }

.sheet {
  width: 190mm;
  min-height: 272mm;
  padding: 12mm 11mm;
  background: #fffefa;
  box-shadow: 0 12px 34px rgba(60, 42, 22, .18), 0 2px 4px rgba(60, 42, 22, .1);
  color: #2b241c;
  font-family: var(--font-kai);
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.sheet-head { flex: none; margin-bottom: 6mm; }

.sheet-school {
  text-align: center;
  font-size: 4.2mm;
  letter-spacing: .35em;
  color: #6a5a45;
  margin-bottom: 2mm;
}

.sheet-title {
  margin: 0;
  text-align: center;
  font-size: 7.4mm;
  font-weight: 600;
  letter-spacing: .18em;
  line-height: 1.5;
  color: #241d15;
  word-break: break-word;
}

.sheet-meta {
  display: flex;
  justify-content: center;
  gap: 9mm;
  margin-top: 3.4mm;
  font-size: 3.6mm;
  color: #5c4f3e;
  flex-wrap: wrap;
}

.sheet-meta span { display: inline-flex; align-items: center; gap: 1.6mm; }

.sheet-meta i {
  display: inline-block;
  width: 19mm;
  border-bottom: .45mm solid #bba98d;
  height: 4.4mm;
}

.paper-grid {
  --cols: 20;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  border-top: 1px solid #cdbda3;
  border-left: 1px solid #cdbda3;
  font-size: calc((190mm - 22mm) / var(--cols) * .68);
  line-height: 1;
  flex: none;
}

.paper-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-right: 1px solid #d8cab3;
  border-bottom: 1px solid #d8cab3;
  font-family: var(--font-kai);
  color: #1f1a14;
  overflow: hidden;
}

.paper-cell.is-blank { background: transparent; }

.paper-grid.show-guides .paper-cell::before,
.paper-grid.show-guides .paper-cell::after {
  content: "";
  position: absolute;
  background: #efe6d8;
  pointer-events: none;
}

.paper-grid.show-guides .paper-cell::before {
  left: 0; right: 0; top: 50%;
  height: 1px;
}

.paper-grid.show-guides .paper-cell::after {
  top: 0; bottom: 0; left: 50%;
  width: 1px;
}

.sheet-foot {
  margin-top: auto;
  padding-top: 3mm;
  display: flex;
  justify-content: space-between;
  font-size: 3.2mm;
  color: #8a7a63;
  letter-spacing: .1em;
}

/* ---------------------------------------------------------------- 预览图 */

.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(30, 20, 10, .35);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 253, 248, .9);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-nav:disabled { opacity: .35; cursor: default; }

/* ---------------------------------------------------------------- 提示 */

.toast-root {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(560px, 86vw);
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(36, 30, 24, .94);
  color: #f7f1e6;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 12px 30px rgba(20, 12, 6, .3);
  animation: toastIn .22s cubic-bezier(.2, .9, .3, 1);
}

.toast.err { background: #8c2f26; }
.toast.ok { background: #26604f; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.toast.leaving { animation: toastOut .2s ease forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ---------------------------------------------------------------- 批改 */

.stat.is-gold b { color: #9a6b1f; }

.score-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #fdf1d6;
  border: 1px solid #ecd8a8;
  color: #8a5a12;
}

.score-chip b { font-size: 15px; font-variant-numeric: tabular-nums; }
.score-chip em { font-style: normal; font-size: 11px; }

.meta-right { display: inline-flex; align-items: center; gap: 8px; }

.upload-rows { display: flex; flex-direction: column; gap: 10px; }

.upload-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.upload-row-no {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--font-kai);
  font-size: 14px;
  color: var(--ink-soft);
  flex: none;
}

.upload-fields {
  display: grid;
  grid-template-columns: 1.2fr 1fr .8fr;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.upload-fields .input { height: 36px; }

.upload-images {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 300px;
}

.upload-thumbs { display: flex; gap: 6px; }

.upload-thumb {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.upload-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.upload-thumb i {
  position: absolute;
  left: 2px;
  bottom: 2px;
  min-width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(30, 22, 14, .7);
  color: #fff;
  font-size: 9px;
  font-style: normal;
}

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

.student-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.student-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.student-row label span { flex: none; }
.student-row .input { height: 36px; }

.paper-mode { flex: none; }
.paper-mode button { padding: 5px 12px; }

/* ---------------------------------------------------------------- 批改稿 */

.paper-pages.is-graded { gap: 30px; }

.g-sheet {
  width: 190mm;
  min-height: 277mm;
  padding: 5mm 5mm 4mm;
  background: #fffefa;
  color: #241d15;
  font-family: var(--font-kai);
  box-shadow: 0 12px 34px rgba(60, 42, 22, .18), 0 2px 4px rgba(60, 42, 22, .1);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.g-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6mm;
  padding-bottom: 2mm;
  border-bottom: .45mm solid #c9b28e;
}

.g-title { margin: 0; font-size: 6.4mm; line-height: 1.35; letter-spacing: .12em; font-weight: 700; }
.g-student { margin-top: 1.2mm; font-size: 3.4mm; color: #6a5a45; letter-spacing: .08em; }

.g-score { text-align: center; min-width: 24mm; flex: none; }
.g-score b {
  display: block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11mm;
  line-height: 1;
  color: #b2472a;
}
.g-score span {
  display: inline-block;
  margin-top: .6mm;
  font-size: 3.4mm;
  padding: .3mm 2.2mm;
  border-radius: 1mm;
  background: #f6e4dd;
  color: #8d341c;
}
.g-score em { display: block; margin-top: .8mm; font-size: 2.5mm; color: #9a8b76; font-style: normal; }

.g-legend {
  display: flex;
  align-items: center;
  gap: 5mm;
  padding: 1.8mm 0 0;
  font-size: 2.8mm;
  color: #6a5a45;
}

.g-legend i {
  display: inline-block;
  width: 3.2mm;
  height: 3.2mm;
  border-radius: .5mm;
  margin-right: 1mm;
  vertical-align: -.4mm;
}

.lg-good { background: #fdeaa8; border: .2mm solid #d9ae35; }
.lg-fix { background: #ffd6cc; border: .2mm solid #d1715e; }
.g-legend-tip { margin-left: auto; color: #a09280; font-size: 2.5mm; }

.g-body { display: flex; gap: 4mm; margin-top: 2.2mm; height: 158.4mm; }
.g-grid-wrap { width: 132mm; flex: none; height: 100%; }

.g-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  border-top: 1px solid #cdbda3;
  border-left: 1px solid #cdbda3;
  font-size: 4.55mm;
  line-height: 1;
}

.g-grid .paper-cell {
  aspect-ratio: 1 / 1;
  border-right: 1px solid #d8cab3;
  border-bottom: 1px solid #d8cab3;
}

.g-notes {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-left: .3mm dashed #cbb89b;
  padding-left: 2.8mm;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
  overflow: hidden;
}

.g-notes-head {
  font-size: 3mm;
  letter-spacing: .35em;
  color: #8a7a63;
  border-bottom: .2mm solid #ddd0ba;
  padding-bottom: .8mm;
}

.g-note { display: flex; gap: 1.4mm; font-size: 2.62mm; line-height: 1.5; }

.g-no {
  flex: none;
  width: 4.6mm;
  height: 4.6mm;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 2.5mm;
}

.g-note--good .g-no { background: #f0d274; color: #5a4100; }
.g-note--fix .g-no { background: #ec9f90; color: #6f1f11; }
.g-note-body { min-width: 0; }

.g-quote { margin: 0 0 .6mm; color: #4a4034; font-size: 2.55mm; }
.g-comment { margin: 0; color: #5c4f3e; }
.g-issue { margin: 0; color: #a13a28; }
.g-fix { margin: .7mm 0 0; color: #1f5c49; }
.g-fix b { font-weight: 400; background: #dff0e8; padding: 0 .7mm; margin-right: .7mm; border-radius: .5mm; }

.g-quote, .g-comment, .g-issue, .g-fix {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.g-quote { -webkit-line-clamp: 2; }
.g-comment { -webkit-line-clamp: 4; }
.g-issue { -webkit-line-clamp: 3; }
.g-note-empty { font-size: 2.6mm; color: #a09280; }

.g-bottom {
  margin-top: 2.4mm;
  border-top: .45mm solid #cbb89b;
  padding-top: 2mm;
  display: flex;
  flex-direction: column;
  gap: 2mm;
}

.g-bottom-top { display: flex; gap: 5mm; }
.g-bottom-left { flex: 1.6; min-width: 0; }
.g-bottom-right { width: 52mm; flex: none; }

.g-fix-table h4 { margin: 0 0 .8mm; font-size: 2.9mm; letter-spacing: .25em; color: #8d341c; }

.g-fix-row {
  display: flex;
  align-items: flex-start;
  gap: 1.4mm;
  padding: .9mm 0;
  border-top: .2mm dashed #e2d6c0;
  font-size: 2.45mm;
  line-height: 1.55;
}

.g-fix-no {
  flex: none;
  width: 4.2mm;
  height: 4.2mm;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ec9f90;
  color: #6f1f11;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 2.3mm;
}

.g-fix-from { flex: 1; min-width: 0; color: #6a5a45; }
.g-fix-arrow { flex: none; color: #b2472a; }
.g-fix-to { flex: 1; min-width: 0; color: #1f5c49; }

.g-summary h4, .g-suggest h4 {
  margin: 0 0 .8mm;
  font-size: 2.9mm;
  letter-spacing: .25em;
  color: #8d341c;
}

.g-summary p { margin: 0; font-size: 2.9mm; line-height: 1.8; color: #3a3128; text-indent: 2em; }
.g-suggest { margin-top: 2mm; }
.g-suggest ol { margin: 0; padding-left: 4mm; font-size: 2.7mm; line-height: 1.65; color: #5c4f3e; }

.g-dim { display: flex; align-items: center; gap: 1.4mm; font-size: 2.6mm; color: #6a5a45; margin-bottom: 1.1mm; }
.g-dim-name { width: 6.5mm; }
.g-dim-bar { flex: 1; height: 1.7mm; background: #eee5d5; border-radius: 2mm; overflow: hidden; }
.g-dim-bar i { display: block; height: 100%; background: linear-gradient(90deg, #d9b25c, #b2472a); }
.g-dim-score { width: 11mm; text-align: right; }
.g-dim-score em { font-style: normal; color: #a09280; }

.g-sign { margin-top: 2mm; font-size: 2.6mm; color: #8a7a63; }
.g-sign i { display: inline-block; width: 13mm; border-bottom: .2mm solid #bba98d; margin: 0 1.5mm 0 .8mm; }

.g-foot {
  margin-top: auto;
  padding-top: 1.4mm;
  display: flex;
  justify-content: space-between;
  font-size: 2.4mm;
  color: #9a8b76;
  letter-spacing: .1em;
}

.g-head--cont { align-items: center; }
.g-page-mark { font-size: 2.9mm; color: #8a7a63; }
.g-empty { padding: 60px; text-align: center; color: #8a7a63; }

.paper-cell.mark-good { background: #fdeaa8; }
.paper-cell.mark-fix { background: #ffd6cc; }

.paper-cell .mk {
  position: absolute;
  top: 0;
  right: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-style: normal;
  font-size: 2.1mm;
  line-height: 1;
  padding: .3mm .45mm;
  border-radius: 0 0 0 1.1mm;
}

.mark-good .mk { background: #dfa72a; color: #3a2a00; }
.mark-fix .mk { background: #c9503a; color: #fff; }

/* ---------------------------------------------------------------- 打印 */

.print-root { display: none; }

@media print {
  @page { size: A4; margin: 10mm; }

  html, body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }

  body::before { display: none; }
  .app, .modal-root, .toast-root { display: none !important; }

  .print-root { display: block; }

  .print-root .sheet {
    width: 190mm;
    height: 272mm;
    min-height: 0;
    box-shadow: none;
    margin: 0;
    padding: 12mm 11mm;
    page-break-after: always;
    break-after: page;
    overflow: hidden;
  }

  .print-root .sheet:last-child { page-break-after: auto; break-after: auto; }

  .print-root .g-sheet {
    width: 190mm;
    height: 277mm;
    min-height: 0;
    box-shadow: none;
    margin: 0;
    padding: 5mm 5mm 4mm;
    page-break-after: always;
    break-after: page;
    overflow: hidden;
  }

  .print-root .g-sheet:last-child { page-break-after: auto; break-after: auto; }
  .print-root .g-grid .paper-cell,
  .print-root .g-grid { border-color: #9d8a70 !important; }

  .paper-cell { border-color: #9d8a70 !important; }
  .paper-grid { border-color: #9d8a70 !important; }
  .sheet-head, .sheet-foot { color: #333 !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 720px) {
  .topbar { gap: 10px; }
  .brand-copy p { display: none; }
  .board { grid-template-columns: 1fr; padding: 14px 14px 30px; gap: 14px; }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .field > label { text-align: left; }
  .field-note { margin-left: 0; }
  .provider-switch { grid-template-columns: 1fr; }
  .card-actions .btn { min-width: 60px; }
  .paper-scroll { padding: 12px; }
}
