:root {
  --bg: #ebe5da;
  --card: #f7f4ec;
  --card-soft: #f2eee5;
  --ink: #0f2f38;
  --ink-muted: #4f6469;
  --line: #d3d0c8;
  --accent: #c5822f;
  --primary: #105866;
  --primary-hover: #0c4b57;
  --primary-soft: #dde8ea;
  --danger: #9f2e2a;
  --danger-soft: #f7e4e1;
  --success: #2f6c4f;
  --success-soft: #e2efe6;
  --warning: #895b1f;
  --warning-soft: #f6ebda;
  --shadow: 0 10px 26px rgba(63, 54, 37, 0.08);
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    radial-gradient(220px 220px at 92% 10%, #eadfcf 0%, transparent 72%),
    radial-gradient(200px 200px at 8% 86%, #ece2d5 0%, transparent 72%),
    var(--bg);
}

body.login-page {
  background: #f5f7fa;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding-left: 18px;
}

.container {
  width: min(940px, 92vw);
  margin: 0 auto;
}

.page {
  padding: 18px 0 52px;
  display: grid;
  gap: 14px;
}

.page > * {
  width: 100%;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel,
.page-head,
.banner,
.entry-panel,
.login-header,
.exam-info,
.home-footnote {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel,
.page-head,
.login-header,
.home-footnote {
  padding: 22px 24px;
}

.panel h2,
.page-head h1,
.login-header h1,
.note-card h3,
.danger-card h3,
.empty-state h3 {
  font-family: var(--font-display);
}

.page-head h1 {
  margin-top: 8px;
  font-size: clamp(34px, 5.2vw, 56px);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.page-head p {
  margin-top: 10px;
  color: var(--ink-muted);
  font-size: 16px;
}

.page-head.with-side-action {
  position: relative;
  padding-right: 170px;
}

.page-head-actions {
  position: absolute;
  top: 22px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-home-link {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #c9d6d9;
  background: #ffffff;
  color: #486870;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.header-home-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-home-link:hover {
  background: #f0f7f8;
  border-color: #a9c2c8;
  color: #29484f;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #d8d5cd;
  background: #f3dedb;
  color: #7b2a27;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.logout-btn:hover {
  background: #eed2ce;
}

.login-page .container {
  width: min(900px, 94vw);
}

.login-header,
.exam-info,
.entry-panel,
.home-footnote {
  background: #ffffff;
  border: 1px solid #e6eaf0;
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(17, 39, 64, 0.08);
}

.login-header h1 {
  margin: 4px 0 10px;
  color: #333333;
  font-family: var(--font-ui);
  font-size: 28px;
  line-height: 1.3;
  font-weight: 700;
}

.school-name {
  margin: 0;
  color: #888888;
  font-size: 14px;
}

.login-note {
  margin: 0;
  color: #77879a;
  font-size: 13px;
}

.login-page .login-header .login-header-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  column-gap: 16px;
  width: 100%;
  margin-bottom: 10px;
}

.login-page .login-header .login-header-home-link {
  justify-self: end;
}

.login-page .login-header h1 {
  margin: 0;
  min-width: 0;
}

.exam-info {
  padding: 16px 18px;
}

.task-status.has-task {
  background: #f4f9ff;
  border-color: #d6e5f8;
}

.task-status.no-task {
  background: #fffaf2;
  border-color: #f0e1c7;
}

.task-status-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: #31485f;
  font-size: 14px;
}

.task-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #2f6eb5;
  background: #e5f0ff;
  border: 1px solid #bfd4f2;
}

.task-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.task-pill.active {
  color: #2f6eb5;
  background: #e8f2ff;
}

.task-pill.empty {
  color: #94692f;
  background: #fff0d9;
}

.exam-info p {
  margin: 0;
  color: #516276;
  font-size: 14px;
  line-height: 1.7;
}

.entry-stack {
  display: grid;
  gap: 24px;
}

.entry-panel {
  padding: 24px;
}

.teacher-panel {
  border-color: #d2e2f5;
  box-shadow: 0 10px 26px rgba(47, 110, 181, 0.14);
  padding: 28px 28px 26px;
}

.admin-panel {
  border-color: #e8edf4;
  box-shadow: 0 2px 10px rgba(18, 34, 55, 0.07);
  padding: 20px 22px;
}

.entry-panel h2,
.admin-entry-title {
  margin: 0 0 14px;
  color: #333333;
  font-family: var(--font-ui);
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
}

.admin-entry-title {
  color: #6a7d92;
  font-size: 16px;
}

.home-footnote {
  padding: 14px 16px;
  color: #7b8797;
  font-size: 12px;
  line-height: 1.75;
}

.home-footnote p + p {
  margin-top: 4px;
}

.form-grid,
.stack-form {
  display: grid;
  gap: 12px;
}

.inline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.teacher-step-grid {
  gap: 14px;
  padding: 12px;
  border: 1px solid #d9e6f8;
  border-radius: 8px;
  background: #f6faff;
}

.teacher-entry-form {
  gap: 14px;
}

.teacher-entry-form .step-pick span {
  color: #2f6eb5;
  font-weight: 700;
}

.teacher-entry-form .step-pick select {
  border: 2px solid #b8d0ee;
  background: #ffffff;
  font-weight: 600;
  min-height: 54px;
  padding: 11px 14px;
  font-size: 17px;
}

.teacher-entry-form .step-pick select:focus {
  border-color: #2f6eb5;
}

label span,
.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.login-page label span {
  margin-bottom: 7px;
  color: #333333;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid #c3ccd1;
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 16px;
  font-family: var(--font-ui);
  background: #f0f2f3;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.login-page input,
.login-page select,
.login-page textarea {
  min-height: 42px;
  border: 1px solid #dddddd;
  border-radius: 6px;
  padding: 9px 11px;
  color: #333333;
  background: #ffffff;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7ba2ab;
  box-shadow: 0 0 0 4px rgba(123, 162, 171, 0.2);
}

.login-page input:focus,
.login-page select:focus,
.login-page textarea:focus {
  border-color: #2f6eb5;
  box-shadow: 0 0 0 3px rgba(47, 110, 181, 0.15);
}

textarea {
  resize: vertical;
  min-height: 126px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 50px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.btn.wide {
  width: 100%;
}

.btn.small {
  min-height: 38px;
  font-size: 14px;
  padding: 0 14px;
}

.btn.primary {
  color: #eaf5f7;
  background: var(--primary);
}

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

.btn.secondary {
  color: #164754;
  background: var(--primary-soft);
  border-color: #cbdde1;
}

.btn.secondary:hover {
  background: #d2e1e5;
}

.btn.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #e8c5c0;
}

.btn.danger:hover {
  background: #f2d8d4;
}

.btn.warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #ead8b2;
}

.btn.warning:hover {
  background: #f0e3c5;
}

.muted {
  color: var(--ink-muted);
}

.banner {
  padding: 14px 16px;
  display: grid;
  gap: 5px;
  border-radius: 18px;
}

.banner strong {
  font-size: 16px;
}

.banner.info {
  color: #174b58;
  background: #e2ecee;
  border-color: #c6d9dd;
}

.banner.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: #c8e1d2;
}

.banner.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #e6c6c2;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.admin-tool {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.tool-label {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.tool-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.tool-inline-single {
  grid-template-columns: 1fr;
}

.tool-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.yuejuan-toolbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.yuejuan-toolbar .admin-tool {
  min-width: 0;
}

.yuejuan-toolbar .admin-tool-status input[disabled] {
  text-align: center;
}

.panel-head,
.panel-head-wrap,
.roster-head,
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head,
.panel-head-wrap,
.roster-head {
  margin-bottom: 12px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #cfe0f4;
  color: #2f6eb5;
  background: #f2f8ff;
  font-size: 13px;
  font-weight: 700;
}

.selection-card {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid #ddd8cf;
  background: var(--card-soft);
}

.selection-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
}

.selection-label {
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 700;
}

.tag-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid #ddd8cf;
  background: #f9f7f1;
}

.tag-switcher-subjects {
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  background: transparent;
}

.tag-chip:hover {
  background: #ece8dd;
}

.tag-chip-active {
  color: #f7f4ec;
}

.tag-chip-grade.tag-chip-active {
  background: var(--primary);
}

.tag-chip-subject.tag-chip-active {
  background: #c5822f;
}

.upload-dropzone {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-top: 14px;
  background: var(--card-soft);
  border: 1px dashed #cbd6d9;
  border-radius: 18px;
}

.upload-surface {
  display: grid;
  gap: 10px;
  place-items: center;
  min-height: 180px;
  padding: 22px 18px;
  border: 2px dashed #b9cfd4;
  border-radius: 16px;
  background: #f8fbfc;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.upload-surface:hover,
.upload-surface.is-dragover {
  border-color: #7ba2ab;
  background: #f2f7f8;
}

.upload-surface input[type="file"] {
  display: none;
}

[data-upload-form].is-uploading .upload-surface {
  opacity: 0.72;
  pointer-events: none;
}

.upload-surface-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #dde8ea;
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
}

.upload-surface-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.upload-surface-copy,
.upload-surface-state {
  color: var(--ink-muted);
  font-size: 14px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.image-grid-large {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.thumb-card,
.note-card,
.danger-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #ddd8cf;
  background: var(--card-soft);
}

.thumb-button {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: zoom-in;
  color: inherit;
}

.thumb-button img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid #d7dfeb;
  background: #fff;
}

.thumb-inline-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

.thumb-meta {
  display: grid;
  gap: 4px;
  margin: 12px 0;
}

.thumb-meta strong {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
}

.thumb-meta span,
.note-list,
.empty-state p,
.danger-card p {
  color: var(--ink-muted);
}

.empty-state {
  padding: 18px 20px;
  margin-top: 12px;
  border-radius: 18px;
  border: 1px solid #ddd8cf;
  background: var(--card-soft);
}

.table-wrap {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid #ddd8cf;
  background: #fbfaf6;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid #ddd8cf;
  padding: 10px 8px;
  text-align: left;
  font-size: 15px;
  white-space: nowrap;
}

.table th {
  color: var(--ink-muted);
  font-weight: 700;
  background: #f4f0e6;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.tag.success {
  color: var(--success);
  background: var(--success-soft);
}

.tag.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.note-card h3,
.danger-card h3 {
  margin-bottom: 8px;
  font-size: 24px;
}

.note-list li + li {
  margin-top: 6px;
}

.teacher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.teacher-head-main {
  min-width: 0;
  flex: 1;
}

.teacher-head h1 {
  font-size: 34px;
  line-height: 1.2;
}

.teacher-head-divider {
  height: 1px;
  background: #dfe6ef;
  margin: 10px 0;
}

.teacher-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.teacher-meta p {
  margin: 0;
  color: #55677b;
  font-size: 14px;
  line-height: 1.45;
}

.teacher-meta strong {
  color: #2a3645;
}

.teacher-meta-primary p {
  font-size: 16px;
  font-weight: 700;
  color: #1f3552;
  background: #f2f8ff;
  border: 1px solid #d5e4f8;
  border-radius: 8px;
  padding: 8px 10px;
}

.teacher-meta-primary strong {
  color: #2f6eb5;
}

.teacher-head-logout {
  margin: 0;
  flex: 0 0 auto;
}

.teacher-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.teacher-head-logout .btn {
  min-width: 86px;
}

.assignment-form {
  gap: 14px;
}

.assignment-list {
  display: grid;
  gap: 10px;
}

.assignment-row {
  border: 1px solid #ddd8cf;
  border-radius: 14px;
  padding: 12px;
  background: var(--card-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.row-remove {
  min-width: 74px;
}

.flash-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 10px;
  z-index: 1200;
}

.flash {
  min-width: 240px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--ink);
  border: 1px solid #d8d5cd;
  box-shadow: var(--shadow);
  background: #ffffff;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.flash.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
}

.flash-success {
  border-color: #c8e1d2;
}

.flash-warning {
  border-color: #ead8b2;
}

.flash-error {
  border-color: #e6c6c2;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(22, 34, 52, 0.34);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1100;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox-figure {
  width: min(980px, 100%);
  display: grid;
  gap: 12px;
}

.lightbox-figure img {
  max-height: 78vh;
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(20, 36, 61, 0.18);
}

.lightbox figcaption {
  color: #ffffff;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .page-head.with-side-action {
    padding-right: 24px;
  }

  .page-head-actions {
    position: static;
    margin-top: 14px;
  }

  .admin-toolbar,
  .settings-grid,
  .inline-grid,
  .teacher-meta,
  .assignment-row {
    grid-template-columns: 1fr;
  }

  .selection-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 16px, 100%);
  }

  .page {
    padding: 12px 0 28px;
  }

  .panel,
  .page-head,
  .login-header,
  .entry-panel,
  .home-footnote {
    padding: 18px 16px;
  }

  .login-page .login-header .login-header-top {
    align-items: center;
  }

  .page-head h1,
  .teacher-head h1 {
    font-size: 28px;
  }

  .toolbar-row {
    justify-content: stretch;
  }

  .toolbar-row .btn {
    width: 100%;
  }

  .flash-stack {
    left: 12px;
    right: 12px;
  }

  .flash {
    min-width: 0;
    max-width: none;
  }
}
