:root {
  --ink: #1b2430;
  --muted: #667085;
  --line: #dde3ea;
  --page: #f4f7fb;
  --panel: #ffffff;
  --primary: #176b87;
  --primary-strong: #0f4d63;
  --accent: #d7572b;
  --ok: #177245;
  --warn: #b65f00;
  --bad: #b42318;
  --shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

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

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef4f7;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 28px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-brand span {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: #102331;
  color: #f7fbff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #d9f0f4;
  color: #102331;
  font-weight: 800;
  border-radius: 8px;
}

.brand strong, .brand span { display: block; }
.brand span { color: #b8c7d3; font-size: 13px; margin-top: 4px; }

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.sidebar .field span { color: #d4e2ec; }

.current-user-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(212, 226, 236, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.current-user-box span {
  color: #d4e2ec;
  font-size: 13px;
}

.current-user-box strong {
  color: #fff;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea { resize: vertical; min-height: 120px; }
select[multiple] { min-height: 220px; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f8fbfd;
}

.rich-editor {
  min-height: 240px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  line-height: 1.75;
  outline: none;
}

.rich-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rich-editor h3,
.content-box h3 {
  margin: 14px 0 8px;
  font-size: 16px;
}

.rich-editor p,
.content-box p {
  margin: 8px 0;
}

.rich-editor ul,
.rich-editor ol,
.content-box ul,
.content-box ol {
  margin: 8px 0 8px 22px;
  padding: 0;
}

.rich-editor blockquote,
.content-box blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--line);
  background: #f7fbfc;
  color: var(--muted);
}

.rich-editor hr,
.content-box hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  text-align: left;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #d7e7f1;
  cursor: pointer;
}

.nav-item.active, .nav-item:hover {
  background: #1c3a4e;
  color: #fff;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
.topbar p { color: var(--muted); margin-top: 6px; }

.view { display: none; }
.view.active { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-width: 0;
  text-align: left;
}

.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 32px; margin-top: 8px; }

.panel {
  padding: 18px;
  min-width: 0;
}

.auth-notice {
  display: none;
  margin-bottom: 14px;
  border: 1px solid #f2c488;
  border-radius: 8px;
  background: #fff8ea;
  color: #7a4100;
  padding: 12px 14px;
  line-height: 1.5;
}

.auth-notice.show {
  display: block;
}

.form-grid.locked {
  opacity: 0.62;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
}

.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { color: var(--primary); background: #e9f4f6; }
.button.danger { color: #fff; background: var(--bad); }
.button.small { padding: 7px 10px; min-height: 32px; font-size: 13px; }

.notice-list {
  display: grid;
  gap: 12px;
}

.notice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
}

.notice-card:hover { border-color: #9abac6; }
.notice-card.selected { outline: 2px solid var(--primary); }

.notice-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.notice-title strong { line-height: 1.45; }
.notice-card p { color: var(--muted); margin-top: 8px; line-height: 1.6; }
.notice-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.notice-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  color: #28414e;
  background: #eef5f7;
}

.tag.warn { background: #fff4df; color: var(--warn); }
.tag.ok { background: #e8f6ee; color: var(--ok); }
.tag.bad { background: #fff0ef; color: var(--bad); }
.tag.accent { background: #fff0e9; color: var(--accent); }

.form-grid, .split {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.todo-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.todo-detail-panel {
  min-height: 420px;
}

#teacherBackBtn {
  display: none;
}

.form-panel h2 { margin-bottom: 14px; }

.radio-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.radio-line input { width: auto; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.check-item input { width: auto; }

.empty {
  color: var(--muted);
  padding: 36px 0;
  text-align: center;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.publish-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.quick-row .button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.ai-generate-box {
  display: grid;
  gap: 10px;
}

.ai-summary-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.search-field {
  margin-bottom: 12px;
}

.content-box {
  border-left: 4px solid var(--primary);
  background: #f7fbfc;
  padding: 12px;
  line-height: 1.7;
}

.notice-content-box {
  text-align: left;
}

.notice-content-box p {
  text-indent: 2em;
}

.notice-content-box ul,
.notice-content-box ol,
.notice-content-box blockquote,
.notice-content-box h3 {
  text-indent: 0;
}

.attachment-section {
  text-align: left;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
}

.attachments a {
  color: var(--primary);
  background: #edf7f9;
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
}

.attachment-manager {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.attachment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachment-name {
  min-width: 0;
}

.attachment-name strong {
  display: block;
  overflow-wrap: anywhere;
}

.attachment-name span {
  color: var(--muted);
  font-size: 13px;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 35, 49, 0.5);
}

.modal-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  display: grid;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(16, 35, 49, 0.22);
  padding: 20px;
}

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

.modal-head h2 {
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.4;
}

.compact-title {
  margin-bottom: 10px;
  font-size: 16px;
}

.reminder-panel {
  max-width: 620px;
}

.share-panel {
  max-width: 680px;
}

.reminder-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.share-box {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: start;
}

.share-qr {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.share-fields {
  display: grid;
  gap: 10px;
}

.share-fields input {
  font-family: inherit;
}

.share-actions {
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 0;
}

.muted-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.timeline {
  display: grid;
  gap: 12px;
}

.settings-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px;
  gap: 14px;
  margin-bottom: 12px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-backup-panel {
  margin-top: 18px;
}

.backup-select-field {
  min-width: 280px;
  margin-bottom: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.group-select {
  min-width: 150px;
}

.table-input {
  min-width: 120px;
  padding: 7px 8px;
}

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

.timeline-item {
  border-left: 4px solid var(--accent);
  background: #fff8f4;
  padding: 12px;
  border-radius: 0 8px 8px 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #102331;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.2s ease;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 12px 10px; }
  .metric span { font-size: 12px; }
  .metric strong { font-size: 24px; }
  .form-grid, .split, .settings-toolbar, .share-box, .todo-layout { grid-template-columns: 1fr; }
  .todo-layout:not(.detail-open) .todo-detail-panel { display: none; }
  .todo-layout.detail-open .todo-list-panel { display: none; }
  #teacherView.detail-open .metric-grid { display: none; }
  #teacherBackBtn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 25;
    display: inline-flex;
    box-shadow: var(--shadow);
  }
  .share-qr { justify-self: center; }
  .main { padding: 18px; }
  .topbar { align-items: flex-start; }
}
