:root {
  --ink: #17211b;
  --muted: #69756e;
  --paper: #fffdf7;
  --surface: #ffffff;
  --green: #176b4d;
  --green-dark: #0d543b;
  --green-soft: #e7f2eb;
  --gold: #c88c2d;
  --gold-soft: #f7edd8;
  --red: #a53d35;
  --red-soft: #faeae7;
  --line: #dfe5df;
  --shadow: 0 18px 55px rgba(34, 53, 42, .08);
  --radius: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #f4f6f1; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 0%, rgba(220, 238, 225, .9), transparent 27rem),
    linear-gradient(180deg, #fafbf7 0%, #f2f5ef 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.55;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.site-header {
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 33, 27, .08);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px 14px 14px 5px;
  color: white;
  background: var(--green);
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 8px 20px rgba(23, 107, 77, .22);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }

.account-area { display: flex; align-items: center; gap: 14px; }
.account-area form { margin: 0; }
.account-name { font-weight: 650; }
.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 0;
  cursor: pointer;
}
.text-button:hover { color: var(--red); }

.main-nav {
  width: min(1180px, calc(100% - 48px));
  margin: 18px auto 0;
  display: flex;
  gap: 8px;
}
.main-nav a {
  padding: 8px 16px;
  color: var(--muted);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
}
.main-nav a.active { color: var(--green-dark); background: var(--green-soft); }

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 46px 0 80px;
}

.flash-stack { display: grid; gap: 10px; margin-bottom: 22px; }
.flash {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 24px rgba(34, 53, 42, .05);
  font-size: 14px;
}
.flash-error { background: var(--red-soft); border-color: #edc6c0; color: #7e2e28; }
.flash-success { background: var(--green-soft); border-color: #bddbc8; color: var(--green-dark); }
.flash-info { background: #edf3f8; border-color: #c9d9e5; color: #315975; }

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(32px, 4vw, 52px); line-height: 1.14; letter-spacing: -.035em; margin-bottom: 15px; }
h2 { font-size: 22px; line-height: 1.3; margin-bottom: 6px; }

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 34px;
}
.hero-row > div:first-child { max-width: 720px; }
.hero-row p, .panel-heading p, .result-heading p { color: var(--muted); margin-bottom: 0; }

.quota-card {
  min-width: 210px;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  border: 1px solid #bddbc8;
  border-radius: 18px;
  background: var(--green-soft);
}
.quota-card strong { grid-row: 1 / span 2; font-size: 42px; line-height: 1; color: var(--green); }
.quota-card span { font-weight: 700; }
.quota-card small { color: var(--muted); font-size: 11px; }
.quota-card.quota-empty { border-color: #e8cbc6; background: var(--red-soft); }
.quota-card.quota-empty strong { color: var(--red); }

.panel {
  border: 1px solid rgba(23, 33, 27, .09);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}
.lookup-panel { padding: 30px; }
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.filled-counter {
  min-width: 72px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.filled-counter b { color: var(--green); }

.expression-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.expression-field {
  min-width: 0;
  height: 54px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcf9;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  overflow: hidden;
}
.expression-field:focus-within {
  border-color: #65a588;
  background: white;
  box-shadow: 0 0 0 4px rgba(23, 107, 77, .1);
}
.expression-field > span {
  width: 48px;
  flex: 0 0 48px;
  text-align: center;
  color: #9aa39d;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--line);
}
.expression-field input {
  width: 100%;
  height: 100%;
  padding: 0 15px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}
.expression-field input::placeholder { color: #acb4af; }
.expression-field input:disabled { background: #f0f1ee; cursor: not-allowed; }

.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.submit-row p { margin: 0; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .small-button, .table-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.primary-button {
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid var(--green);
  color: white;
  background: var(--green);
  box-shadow: 0 8px 20px rgba(23, 107, 77, .2);
}
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled { border-color: #a9b3ad; background: #a9b3ad; box-shadow: none; cursor: not-allowed; transform: none; }
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #bfcac2;
  background: rgba(255, 255, 255, .8);
  color: var(--green-dark);
}
.secondary-button:hover { background: white; box-shadow: 0 8px 18px rgba(34, 53, 42, .08); }
.full-button { width: 100%; }
.button-loading { display: none; }
.is-submitting .button-label { display: none; }
.is-submitting .button-loading { display: inline; }

.history-section { margin-top: 48px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; }
.section-heading span { color: var(--muted); font-size: 13px; }
.history-list { display: grid; gap: 9px; }
.history-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(23, 33, 27, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .75);
}
.history-list a:hover { border-color: #a8c9b6; background: white; }
.history-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--green); background: var(--green-soft); font-weight: 800; }
.history-main { display: grid; flex: 1; }
.history-main small { color: var(--muted); }
.history-arrow { color: var(--green); font-size: 13px; font-weight: 700; }

.result-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 30px;
}
.result-heading h1 { margin-bottom: 10px; }
.print-actions { display: flex; align-items: center; gap: 10px; }
.print-actions form { margin: 0; }
.back-link { display: block; margin-bottom: 22px; color: var(--muted); font-size: 13px; }
.result-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.result-card {
  display: flex;
  gap: 16px;
  padding: 20px;
  border: 1px solid #cfd4d0;
  border-radius: 10px;
  background: white;
  box-shadow: none;
}
.result-number { color: #4e5551; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.result-content { min-width: 0; flex: 1; display: grid; gap: 12px; }
.result-content span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.result-source strong { font-size: 17px; }
.result-japanese { padding: 10px 0; border-block: 1px solid #d8dcd9; }
.result-japanese strong { color: #111; font-size: 21px; line-height: 1.8; word-break: break-word; }
.result-example p { margin: 0; color: #242a26; line-height: 1.8; overflow-wrap: anywhere; }
.result-example-legacy { padding-top: 1px; }
.result-example-legacy p { color: #525a55; }
.ruby-text { font-variant-east-asian: normal; }
.ruby-text ruby { ruby-align: center; ruby-position: over; }
.ruby-text rb { white-space: nowrap; }
.ruby-text rt {
  color: #3f4642;
  font-size: .5em;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .02em;
  text-align: center;
  user-select: none;
}
.bottom-actions { display: flex; justify-content: center; gap: 12px; margin-top: 34px; }
.bottom-actions form { margin: 0; }

.admin-shell { width: min(1260px, calc(100% - 48px)); }
.admin-hero { align-items: center; }
.admin-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 20px; }
.batch-panel, .batch-result-panel { padding: 27px; min-height: 490px; }
.textarea-label span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.textarea-label textarea {
  width: 100%;
  resize: vertical;
  min-height: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: #fbfcf9;
  line-height: 1.7;
}
.textarea-label textarea:focus { border-color: #65a588; background: white; box-shadow: 0 0 0 4px rgba(23, 107, 77, .1); }
.security-note { margin: 13px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.batch-result-panel.empty-result { display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-result h2 { color: var(--ink); }
.empty-result p { max-width: 360px; }
.empty-illustration { width: 92px; height: 92px; display: grid; place-items: center; margin-bottom: 20px; border: 1px solid #d7c28f; border-radius: 50%; color: var(--gold); background: var(--gold-soft); font: 700 46px/1 Georgia, serif; }
.success-eyebrow { color: var(--green); }
.small-button { min-height: 34px; padding: 0 12px; border: 1px solid #a8c9b6; color: var(--green-dark); background: var(--green-soft); font-size: 12px; }
.credential-copybox { position: fixed; left: -10000px; top: -10000px; }
.credential-list { max-height: 346px; overflow: auto; display: grid; gap: 8px; padding-right: 4px; }
.credential-list > div { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-radius: 11px; background: #f5f7f3; }
.credential-list code, .password-code { padding: 4px 8px; border-radius: 7px; color: #6b4a15; background: var(--gold-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; letter-spacing: .08em; }

.users-panel { margin-top: 20px; padding: 27px; }
.table-search { width: 230px; height: 40px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fbfcf9; }
.table-search:focus { border-color: #65a588; box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { padding: 11px 12px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; letter-spacing: .06em; }
.users-table td { padding: 14px 12px; border-bottom: 1px solid #edf0ec; vertical-align: middle; }
.users-table tbody tr:last-child td { border-bottom: 0; }
.users-table td:first-child strong, .users-table td:first-child small { display: block; }
.users-table td:first-child small { color: var(--muted); font-size: 11px; }
.actions-column { text-align: right !important; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-actions form { margin: 0; }
.table-button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); color: #425049; background: white; font-size: 12px; }
.table-button:hover { border-color: #a8c9b6; background: var(--green-soft); }
.danger-text { color: var(--red); }
.status-pill { display: inline-flex; padding: 3px 9px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 700; }
.status-pill.inactive { color: #6c716e; background: #eceeeb; }
.empty-table { padding: 45px !important; color: var(--muted); text-align: center; }

.login-page { background: #f1f5ef; }
.login-page .site-header { position: static; background: transparent; border: 0; }
.login-shell { min-height: calc(100vh - 76px); display: grid; align-items: center; padding-top: 32px; }
.login-card {
  min-height: 540px;
  display: grid;
  grid-template-columns: 1.12fr .88fr;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 27, .08);
  border-radius: 28px;
  background: white;
  box-shadow: 0 28px 80px rgba(34, 53, 42, .13);
}
.login-intro {
  padding: 70px 62px;
  color: white;
  background:
    linear-gradient(145deg, rgba(10, 73, 50, .88), rgba(23, 107, 77, .95)),
    radial-gradient(circle at 80% 10%, #85bba0, transparent 50%);
  position: relative;
  overflow: hidden;
}
.login-intro::after { content: "あ"; position: absolute; right: -30px; bottom: -95px; color: rgba(255,255,255,.08); font-family: serif; font-size: 360px; line-height: 1; }
.login-intro .eyebrow { color: #cfe4d7; }
.login-intro h1 { max-width: 520px; margin-top: 95px; font-size: clamp(40px, 5vw, 66px); position: relative; z-index: 1; }
.login-intro p { color: rgba(255, 255, 255, .72); position: relative; z-index: 1; }
.login-form { padding: 70px 56px; display: flex; flex-direction: column; justify-content: center; }
.form-heading { margin-bottom: 30px; }
.form-heading h2 { font-size: 30px; }
.form-heading p { margin: 0; color: var(--muted); }
.login-form label { display: block; margin-bottom: 18px; }
.login-form label span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.login-form input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: 0; background: #fbfcf9; }
.login-form input:focus { border-color: #65a588; background: white; box-shadow: 0 0 0 4px rgba(23, 107, 77, .1); }
.form-help { margin: 16px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

.error-card { max-width: 520px; margin: 70px auto; padding: 48px; border-radius: 22px; background: white; box-shadow: var(--shadow); text-align: center; }
.error-code { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 30px; font-weight: 800; }
.error-card p { color: var(--muted); margin-bottom: 28px; }

/* 作文任务与提交 */
.button-count {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-size: 11px;
}
.task-hero { align-items: center; margin-bottom: 22px; }
.task-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  border-block: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
}
.task-summary > div {
  min-height: 60px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-right: 1px solid var(--line);
}
.task-summary > div:last-child { border-right: 0; }
.task-summary span { color: var(--muted); font-size: 13px; font-weight: 700; }
.task-summary strong { color: var(--green); font: 800 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.task-list, .draft-list { display: grid; gap: 12px; }
.task-card {
  min-height: 170px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  align-items: stretch;
  border: 1px solid rgba(23, 33, 27, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 30px rgba(34, 53, 42, .05);
  overflow: hidden;
}
.task-card-main { min-width: 0; padding: 23px 26px; }
.task-card-main h2 { margin: 9px 0 7px; font-size: 24px; }
.task-meta-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.composition-type {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border: 1px solid #a9beb1;
  border-radius: 999px;
  color: var(--green-dark);
  background: #f1f6f2;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.composition-type-small { color: #735116; border-color: #d8c18d; background: #faf4e6; }
.task-deadline { color: var(--muted); font-size: 12px; font-weight: 650; }
.task-deadline.is-overdue { color: var(--red); }
.task-instructions {
  max-width: 820px;
  margin: 0 0 10px;
  display: -webkit-box;
  overflow: hidden;
  color: #4f5b54;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: pre-line;
}
.task-minimum { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.task-card-action {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-left: 1px solid var(--line);
  background: #f8faf7;
  text-align: center;
}
.task-card-action small { color: var(--muted); font-size: 11px; }
.task-state { display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-weight: 800; }
.task-state-submitted { color: var(--green); }
.task-state-closed { color: var(--muted); }
.task-card-closed { opacity: .82; }
.empty-state-card { padding: 52px 24px; color: var(--muted); text-align: center; }
.empty-state-card strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 20px; }
.empty-state-card p { margin: 0; }
.compact-empty { padding: 46px 20px; }

/* 作文输入与暂存 */
.writing-shell { width: min(960px, calc(100% - 48px)); }
.writing-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.writing-heading h1 { margin: 9px 0 0; font-size: clamp(30px, 4vw, 46px); }
.word-rule {
  min-width: 130px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}
.word-rule strong { grid-row: 1 / span 2; color: var(--green); font-size: 29px; line-height: 1; }
.word-rule span { color: var(--muted); font-size: 12px; font-weight: 700; }
.task-requirement-panel { margin-bottom: 14px; padding: 20px 24px; border-radius: 14px; box-shadow: none; }
.task-requirement-panel h2 { margin-bottom: 7px; font-size: 17px; }
.task-requirement-panel p { margin: 0; color: #465149; white-space: pre-wrap; }
.writing-panel { padding: 24px; border-radius: 15px; }
.writing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.writing-toolbar > div { display: grid; gap: 2px; }
.writing-toolbar > div > strong { font-size: 16px; font-weight: 800; }
.writing-toolbar > div > small { color: var(--muted); font-size: 11px; }
.character-counter { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.character-counter strong { color: var(--red); font-size: 22px; }
.character-counter.is-ready strong { color: var(--green); }
.character-counter.is-over strong { color: var(--red); }
.optional-section-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 15px 0;
  padding: 11px 12px;
  border: 1px dashed #cbd5ce;
  border-radius: 10px;
  background: #f8faf8;
}
.optional-section-controls > span { margin-right: 3px; color: var(--muted); font-size: 12px; font-weight: 750; }
.composition-points { display: grid; gap: 14px; }
.composition-section {
  padding: 15px;
  border: 1px solid #dfe5e0;
  border-radius: 12px;
  background: #fbfcfb;
}
.composition-section-optional { margin: 14px 0; border-style: dashed; background: #f7faf7; }
.composition-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.composition-section-heading > label { color: var(--ink); font-size: 14px; font-weight: 800; }
.composition-section-heading > label small { color: var(--muted); font-size: 11px; font-weight: 650; }
.section-character-counter { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.writing-panel textarea {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  padding: 20px;
  border: 1px solid #cfd7d1;
  border-radius: 11px;
  outline: 0;
  color: #171c19;
  background: #fff;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "PingFang SC", sans-serif;
  font-size: 18px;
  line-height: 1.95;
}
.composition-section-optional textarea { min-height: 125px; }
.writing-panel textarea:focus { border-color: #5e957b; box-shadow: 0 0 0 4px rgba(23, 107, 77, .09); }
.writing-panel textarea[readonly] { color: #38423c; background: #f5f6f3; }
.count-help { min-height: 22px; margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.count-help.is-short { color: var(--red); }
.writing-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.writing-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.writing-actions > div { display: flex; gap: 9px; }
.writing-locked-note { margin-top: 16px; padding: 12px 14px; border: 1px solid #d7dcd8; color: var(--muted); background: #f3f4f2; text-align: center; font-size: 13px; }
.draft-card { min-height: 150px; display: grid; grid-template-columns: minmax(0, 1fr) 165px; overflow: hidden; }
.draft-card-main { min-width: 0; padding: 21px 24px; }
.draft-card-main h2 { margin: 8px 0 7px; }
.draft-preview {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  color: #59645d;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: pre-wrap;
}
.draft-card-side { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; padding: 18px; border-left: 1px solid var(--line); background: #fafbf9; text-align: center; }
.draft-card-side > strong { color: var(--green); font-size: 22px; }
.draft-card-side > small { margin-bottom: 6px; color: var(--muted); font-size: 11px; }

/* 任务管理 */
.admin-task-layout { display: grid; grid-template-columns: minmax(320px, .78fr) minmax(480px, 1.22fr); gap: 18px; align-items: start; }
.task-editor, .task-manager-panel, .submissions-panel { padding: 26px; }
.form-field { display: grid; gap: 7px; margin-bottom: 17px; color: var(--ink); font-size: 13px; font-weight: 700; }
.form-field > small { color: var(--muted); font-size: 11px; font-weight: 500; }
.form-field input, .form-field select, .submission-filters input, .submission-filters select, .overview-controls input, .overview-controls select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: #fff;
}
.form-field input:focus, .form-field select:focus, .submission-filters input:focus, .submission-filters select:focus, .overview-controls input:focus, .overview-controls select:focus {
  border-color: #65a588;
  box-shadow: 0 0 0 3px rgba(23, 107, 77, .1);
}
.type-choice { margin: 0 0 17px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; border: 0; }
.type-choice legend { width: 100%; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.type-choice label { position: relative; cursor: pointer; }
.type-choice input { position: absolute; opacity: 0; }
.type-choice label > span { min-height: 65px; display: grid; align-content: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcf9; }
.type-choice strong, .type-choice small { display: block; }
.type-choice small { color: var(--muted); }
.type-choice input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.task-editor .textarea-label textarea { min-height: 150px; }
.task-manager-heading { align-items: center; }
.managed-task-list { max-height: 780px; display: grid; align-content: start; gap: 8px; overflow: auto; padding-right: 3px; }
.managed-task { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.managed-task[hidden] { display: none; }
.managed-task summary { min-height: 72px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 14px; cursor: pointer; list-style: none; }
.managed-task summary::-webkit-details-marker { display: none; }
.managed-task summary::after { content: "展开"; grid-column: 3; color: var(--muted); font-size: 10px; }
.managed-task[open] summary::after { content: "收起"; }
.managed-task-title { min-width: 0; display: grid; }
.managed-task-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.managed-task-title small { color: var(--muted); font-size: 11px; }
.managed-task summary .status-pill { grid-column: 3; grid-row: 1; margin-bottom: 21px; }
.managed-task-form { padding: 18px 16px 12px; border-top: 1px solid var(--line); background: #fafbf9; }
.managed-task-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.managed-task-form .textarea-label textarea { min-height: 120px; }
.publish-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.publish-toggle input { width: 18px; height: 18px; }
.managed-task-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.managed-task-delete { display: flex; justify-content: flex-end; margin: 0; padding: 0 16px 12px; background: #fafbf9; }
.managed-task-archived-note { padding: 16px; border-top: 1px solid var(--line); color: var(--muted); background: #f5f6f4; text-align: center; font-size: 12px; }

/* 提交记录与详情 */
.submission-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px minmax(150px, .7fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 17px;
  border-radius: 13px;
  box-shadow: none;
}
.submission-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.submission-filters .secondary-button { height: 46px; }
.submission-filters-simple { grid-template-columns: 180px minmax(180px, 1fr) auto; }
.submissions-table { min-width: 960px; }
.compact-search-label { min-width: 220px; display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.compact-search-label input { height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #fff; }
.compact-search-label input:focus { border-color: #65a588; box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.table-subline { display: block; color: var(--muted); font-size: 11px; }
.review-status { display: inline-flex; padding: 3px 8px; border-radius: 999px; color: #5f5541; background: #f2eee5; font-size: 11px; font-weight: 800; white-space: nowrap; }
.review-status-completed { color: var(--green-dark); background: var(--green-soft); }
.review-status-failed { color: #842f29; background: var(--red-soft); }
.review-status-processing { color: #2e5877; background: #e8f1f7; }
.submission-detail-heading h1 { font-size: clamp(30px, 4vw, 46px); }
.review-waiting-card { margin-bottom: 15px; padding: 30px; text-align: center; }
.review-waiting-card h2 { margin: 12px 0 6px; }
.review-waiting-card p { margin: 0; color: var(--muted); }
.original-composition-panel { padding: 25px 28px; border-radius: 15px; }
.detail-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.detail-section-heading strong { color: var(--ink); font-size: 14px; }
.original-composition { padding-top: 17px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; line-height: 1.9; }
.sentence-review-section { margin-top: 30px; }
.sentence-review-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sentence-review-card { min-width: 0; padding: 20px; border-radius: 13px; box-shadow: none; }
.sentence-review-card header { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: start; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sentence-review-card header > span { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid #9fb2a6; border-radius: 7px; color: var(--green); font-size: 11px; font-weight: 800; }
.sentence-review-card header p { margin: 1px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; font-weight: 700; }
.sentence-review-card dl { margin: 12px 0 0; display: grid; gap: 10px; }
.sentence-review-card dl > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
.sentence-review-card dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.sentence-review-card dd { margin: 0; overflow-wrap: anywhere; }
.handwriting-upload-panel { margin-bottom: 14px; padding: 26px; }
.handwriting-upload-panel form { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.2fr) auto; align-items: end; gap: 12px; }
.handwriting-upload-panel .form-field { margin-bottom: 0; }
.handwriting-upload-panel input[type="file"] { padding: 10px 12px; font-size: 13px; }
.handwriting-ocr-details { margin-top: 22px; }
.handwriting-ocr-details .original-composition { margin: 0 16px 16px; color: var(--muted); font-size: 14px; }

/* 学生 × 任务总览 */
.overview-shell { width: min(1600px, calc(100% - 32px)); padding-top: 34px; }
.overview-hero { margin-bottom: 20px; }
.overview-controls {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}
.overview-controls label { min-width: 150px; display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.overview-controls .overview-search-label { min-width: 220px; flex: 1; }
.overview-controls .secondary-button, .overview-refresh { height: 46px; }
.overview-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 7px; border-block: 1px solid var(--line); background: #fff; }
.overview-summary > div { min-height: 56px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 10px 14px; border-right: 1px solid var(--line); }
.overview-summary > div:last-child { border-right: 0; }
.overview-summary span { color: var(--muted); font-size: 13px; font-weight: 800; }
.overview-summary strong { font: 900 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.overview-summary > div:first-child strong { color: var(--green); }
.overview-summary > div:last-child strong { color: var(--red); }
.overview-legend { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; margin: 6px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.overview-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.composition-matrix-wrap { width: 100%; max-height: calc(100dvh - 285px); min-height: 260px; overflow: auto; border: 1px solid var(--line); background: #fff; }
.matrix-empty { min-height: 260px; display: grid; place-items: center; padding: 28px; color: var(--muted); text-align: center; }
.composition-matrix { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.composition-matrix th, .composition-matrix td { height: 32px; padding: 2px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid #edf0ec; text-align: center; }
.composition-matrix thead th { position: sticky; top: 0; z-index: 4; width: 150px; min-width: 150px; max-width: 150px; height: 82px; color: #fff; background: var(--green); border-color: rgba(255, 255, 255, .23); }
.composition-matrix tbody tr:nth-child(even) td, .composition-matrix tbody tr:nth-child(even) th { background: #f8faf8; }
.composition-matrix .matrix-sticky { position: sticky; left: 0; z-index: 3; width: 92px; min-width: 92px; max-width: 92px; background: #fff; box-shadow: 4px 0 7px rgba(21, 32, 30, .08); }
.composition-matrix thead .matrix-sticky { z-index: 6; color: #fff; background: var(--green-dark); }
.matrix-task-heading > strong, .matrix-task-heading > span, .matrix-task-heading > small { display: block; }
.matrix-task-heading > strong { max-height: 31px; overflow: hidden; font-size: 12px; line-height: 1.25; }
.matrix-task-heading > span { margin-top: 4px; color: rgba(255, 255, 255, .78); font-size: 9px; font-weight: 600; white-space: nowrap; }
.matrix-task-heading > small { margin-top: 2px; color: rgba(255, 255, 255, .82); font-size: 9px; }
.matrix-task-heading b { color: white; }
.matrix-student-name { white-space: nowrap; font-size: 12px; }
.matrix-student-name > span { display: inline-block; min-width: 13px; margin-right: 4px; color: var(--muted); font: 900 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.matrix-student-name > strong { display: inline-block; max-width: 64px; overflow: hidden; vertical-align: middle; }
.matrix-cell-link, .matrix-cell-static { min-height: 25px; position: relative; display: grid; place-items: center; }
.matrix-symbol { width: 19px; height: 19px; display: inline-grid; place-items: center; border: 1px solid #cbd3ce; border-radius: 4px; font-style: normal; font-size: 12px; font-weight: 900; line-height: 1; }
.matrix-submitted { color: white; border-color: var(--green); background: var(--green); }
.matrix-draft { color: #735116; border-color: #d7bc7f; background: #faf2df; font-size: 9px; }
.matrix-missing { color: #929c96; background: white; }
.matrix-cell-link > small { position: absolute; right: calc(50% - 23px); bottom: 0; color: var(--red); font-size: 8px; font-weight: 900; }
.composition-matrix tr[hidden] { display: none; }

@media (max-width: 860px) {
  .page-shell, .admin-shell { width: min(100% - 28px, 720px); padding-top: 30px; }
  .site-header { height: 68px; padding: 0 14px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand strong { font-size: 14px; }
  .account-name { display: none; }
  .main-nav { width: calc(100% - 28px); margin-top: 12px; }
  .hero-row, .result-heading { align-items: stretch; flex-direction: column; }
  .quota-card { width: 100%; }
  .expression-grid, .result-list, .admin-grid { grid-template-columns: 1fr; }
  .login-card { grid-template-columns: 1fr; }
  .login-intro { display: none; }
  .login-form { padding: 48px 30px; }
  .login-card { min-height: 480px; }
  .batch-panel, .batch-result-panel { min-height: auto; }
  .main-nav { overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { flex: 0 0 auto; }
  .task-card { grid-template-columns: minmax(0, 1fr) 150px; }
  .admin-task-layout { grid-template-columns: 1fr; }
  .managed-task-list { max-height: none; }
  .submission-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sentence-review-list { grid-template-columns: 1fr; }
  .handwriting-upload-panel form { grid-template-columns: 1fr; }
  .overview-shell { width: calc(100% - 16px); padding-top: 22px; }
  .overview-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-controls label, .overview-controls .overview-search-label { min-width: 0; }
  .composition-matrix-wrap { max-height: 70dvh; }
}

@media (max-width: 560px) {
  h1 { font-size: 34px; }
  .lookup-panel, .batch-panel, .batch-result-panel, .users-panel { padding: 20px 16px; border-radius: 17px; }
  .expression-field { height: 52px; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .submit-row .primary-button { width: 100%; }
  .result-heading .print-action { width: 100%; }
  .print-actions { align-items: stretch; flex-direction: column; }
  .print-actions a, .print-actions button, .print-actions form { width: 100%; }
  .result-card { padding: 18px 15px; gap: 11px; }
  .result-japanese strong { font-size: 19px; }
  .bottom-actions { align-items: stretch; flex-direction: column; }
  .bottom-actions a, .bottom-actions button, .bottom-actions form { width: 100%; }
  .panel-heading { flex-direction: column; }
  .table-search { width: 100%; }
  .row-actions { align-items: flex-end; flex-direction: column; }
  .users-table { min-width: 720px; }
  .task-hero { align-items: stretch; }
  .task-summary > div { min-height: 52px; padding: 10px 12px; }
  .task-card, .draft-card { grid-template-columns: 1fr; }
  .task-card-main, .draft-card-main { padding: 19px 16px; }
  .task-card-main h2 { font-size: 21px; }
  .task-card-action, .draft-card-side { min-height: 90px; border-top: 1px solid var(--line); border-left: 0; }
  .task-card-action .primary-button { width: 100%; }
  .writing-heading { align-items: stretch; flex-direction: column; }
  .word-rule { width: 100%; }
  .writing-panel, .task-requirement-panel { padding: 18px 15px; }
  .writing-toolbar { align-items: flex-start; }
  .composition-section { padding: 12px; }
  .writing-panel textarea { min-height: 155px; padding: 14px; font-size: 17px; }
  .composition-section-optional textarea { min-height: 115px; }
  .writing-actions { align-items: stretch; flex-direction: column; }
  .writing-actions > div { display: grid; grid-template-columns: 1fr 1.3fr; }
  .task-editor, .task-manager-panel, .submissions-panel { padding: 20px 15px; }
  .type-choice, .managed-task-row, .submission-filters, .overview-controls { grid-template-columns: 1fr; }
  .managed-task summary { grid-template-columns: auto minmax(0, 1fr); }
  .managed-task summary .status-pill, .managed-task summary::after { display: none; }
  .submission-filters .secondary-button { width: 100%; }
  .original-composition-panel { padding: 20px 16px; }
  .sentence-review-card { padding: 16px 14px; }
  .sentence-review-card dl > div { grid-template-columns: 64px minmax(0, 1fr); }
  .overview-hero { margin-bottom: 12px; }
  .overview-hero h1 { font-size: 29px; }
  .overview-summary > div { min-height: 48px; padding: 7px 8px; }
  .overview-summary span { font-size: 10px; }
  .overview-summary strong { font-size: 20px; }
  .overview-legend { justify-content: flex-start; font-size: 10px; }
  .composition-matrix-wrap { max-height: 72dvh; }
  .composition-matrix thead th { width: 104px; min-width: 104px; max-width: 104px; height: 72px; }
  .composition-matrix .matrix-sticky { width: 68px; min-width: 68px; max-width: 68px; }
  .matrix-task-heading > strong { font-size: 10px; }
  .matrix-task-heading > span, .matrix-task-heading > small { font-size: 7px; }
  .matrix-student-name > span { display: none; }
  .matrix-student-name > strong { max-width: 59px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
