:root {
  --ink: #17242d;
  --ink-2: #24343d;
  --paper: #f2f5f1;
  --surface: #ffffff;
  --surface-2: #e8ede8;
  --surface-3: #f8faf7;
  --line: #d4dbd5;
  --line-strong: #b7c2bb;
  --muted: #65736c;
  --muted-2: #7d8a83;
  --red: #9d3d31;
  --red-dark: #843126;
  --red-soft: #f3e3df;
  --green: #456653;
  --green-soft: #dfeae2;
  --blue: #315a78;
  --blue-soft: #e2edf4;
  --amber: #8a6819;
  --amber-soft: #f3ead3;
  --danger: #a33b32;
  --shadow: 0 16px 46px rgba(23, 36, 45, .08);
  --shadow-strong: 0 26px 80px rgba(13, 28, 35, .25);
  --serif: "Songti SC", "STSong", "SimSun", serif;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.65 var(--sans);
  text-wrap: pretty;
}

body.is-dialog-open { overflow: hidden; }

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

button {
  color: inherit;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
p {
  text-wrap: pretty;
}

code {
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--red-dark);
  background: var(--red-soft);
  font: 12px/1.6 var(--mono);
}

[hidden] { display: none !important; }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  padding: 24px 18px 18px;
  display: flex;
  flex-direction: column;
  color: #f3f5f1;
  background: var(--ink);
  overflow: auto;
}

.brand {
  padding: 0 10px 23px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.brand-kicker,
.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .15em;
}

.brand-kicker {
  color: #b6c5bc;
  letter-spacing: .14em;
}

.brand h1 {
  margin: 0;
  font: 700 25px/1.25 var(--serif);
  letter-spacing: .04em;
}

.main-nav {
  display: grid;
  gap: 5px;
  margin-top: 21px;
}

.main-nav button {
  width: 100%;
  min-height: 45px;
  padding: 0 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #d3ddd6;
  background: transparent;
  text-align: left;
  transition: color .16s ease, background .16s ease;
}

.main-nav button:hover { color: #fff; background: rgba(255, 255, 255, .07); }

.main-nav button.is-active {
  color: var(--ink);
  background: #f4f0e9;
}

.main-nav svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 22px;
  display: grid;
  gap: 9px;
}

.identity-card-button {
  width: 100%;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: rgba(255, 255, 255, .05);
  text-align: left;
}

.identity-card-button span:first-child {
  display: grid;
}

.identity-card-button small {
  color: #aebbb3;
  font-size: 11px;
}

.identity-card-button strong {
  font-size: 14px;
}

.identity-card-button > span:last-child {
  color: #cbd6cf;
  font-size: 12px;
}

.settings-button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd6cf;
  background: transparent;
  text-align: left;
}

.settings-button:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.settings-button svg { width: 17px; height: 17px; }

.main {
  min-width: 0;
  padding: 0 clamp(20px, 3.8vw, 54px) 58px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(242, 245, 241, .94);
  backdrop-filter: blur(14px);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb b { color: #aab4ae; font-weight: 400; }
.breadcrumb strong { color: var(--ink); }

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

.search-trigger {
  width: min(380px, 31vw);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, .82);
  text-align: left;
}

.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger svg { width: 17px; flex: 0 0 auto; }
.search-trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-trigger kbd {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: var(--surface-3);
  font: 10px/1.4 var(--mono);
  white-space: nowrap;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: var(--surface);
  white-space: nowrap;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}

.button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.button:active { transform: none; }

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

.button.primary:hover {
  border-color: var(--red-dark);
  background: var(--red-dark);
}

.button.subtle {
  color: var(--muted);
  background: var(--surface-3);
}

.button.danger {
  color: var(--danger);
  border-color: #dec7c2;
  background: #fff6f4;
}

.button svg { width: 16px; height: 16px; flex: 0 0 auto; }

.privacy-notice {
  margin: 18px 0 0;
  min-height: 58px;
  padding: 12px 14px 12px 13px;
  border: 1px solid #d9b8b1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #6f433c;
  background: #f4e7e3;
  box-shadow: 0 8px 22px rgba(125, 81, 72, .07);
  font-size: 14px;
}

.privacy-notice-icon {
  width: 34px;
  height: 34px;
  border: 1px solid #cf9f96;
  border-radius: 3px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #a75b4f;
  flex: 0 0 auto;
}

.privacy-notice-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.privacy-notice-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.privacy-notice-copy strong {
  color: #7d382f;
  font: 700 16px/1.4 var(--serif);
  letter-spacing: .06em;
  white-space: nowrap;
}

.privacy-notice-copy > span {
  color: #6f4b45;
}

.privacy-notice-tag {
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid #d8afa7;
  border-radius: 3px;
  color: #7f3b32;
  background: #fff9f7;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.view { display: none; }

.view.is-active {
  display: block;
  animation: settle .28s ease both;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.overview-intro,
.page-heading {
  padding: 34px 0 25px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.overview-intro h2,
.page-heading h2 {
  max-width: 890px;
  margin: 0;
  font: 700 clamp(32px, 4vw, 50px)/1.17 var(--serif);
  letter-spacing: 0;
}

.overview-intro p:not(.eyebrow),
.page-heading p:not(.eyebrow) {
  max-width: 720px;
  margin: 9px 0 0;
  color: var(--muted);
}

.page-heading h2 { font-size: clamp(31px, 3.6vw, 45px); }

.intro-actions,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
}

.panel-head {
  min-height: 62px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h3,
.section-heading h3 {
  margin: 0;
  font: 700 18px/1.4 var(--serif);
}

.panel-head p,
.section-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  padding: 0;
  color: var(--red);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.text-button:hover { color: var(--red-dark); }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.overview-grid > .panel {
  grid-column: span 6;
}

.overview-grid > .wide {
  grid-column: span 8;
}

.compact-table-wrap,
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.task-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: auto;
}

.task-table.compact { min-width: 680px; }

.task-table th,
.task-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.task-table th {
  color: var(--muted);
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.task-table tbody tr:last-child td { border-bottom: 0; }
.task-table tbody tr:hover { background: #fbfcfa; }

.task-table td strong {
  display: block;
  font-size: 13px;
  line-height: 1.5;
}

.task-table td small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.task-table .check-cell {
  width: 44px;
  text-align: center;
}

.task-table .action-cell {
  width: 108px;
  text-align: right;
}

.task-check {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #aab5ae;
  border-radius: 2px;
  display: grid;
  place-items: center;
  color: transparent;
  background: #fff;
}

.task-check:hover { border-color: var(--green); }

.task-check.is-done {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.task-check svg { width: 13px; height: 13px; stroke-width: 2.4; }

.status-badge,
.priority-badge,
.category-badge {
  display: inline-flex;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 3px;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge { color: var(--blue); background: var(--blue-soft); }
.status-badge.doing { color: var(--amber); background: var(--amber-soft); }
.status-badge.done { color: var(--green); background: var(--green-soft); }
.priority-badge.high { color: var(--red); background: var(--red-soft); }
.priority-badge.normal { color: var(--green); background: var(--green-soft); }
.priority-badge.low { color: var(--muted); background: var(--surface-2); }
.category-badge { color: var(--red-dark); background: var(--red-soft); }

.status-select {
  min-height: 34px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface-3);
}

.icon-button.danger:hover {
  color: var(--danger);
  border-color: #dfc5bf;
  background: #fff5f3;
}

.icon-button svg { width: 16px; height: 16px; }

.agenda-list {
  margin: 0;
  padding: 3px 20px 16px;
  list-style: none;
}

.agenda-list li {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
}

.agenda-list li:first-child { border-top: 0; }

.agenda-list time {
  color: var(--red);
  font: 800 12px/1.7 var(--mono);
}

.agenda-list strong {
  display: block;
  font-size: 13px;
}

.agenda-list small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.document-list,
.mini-template-list {
  padding: 5px 20px 14px;
}

.document-row,
.mini-template-row {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.document-row:first-child,
.mini-template-row:first-child { border-top: 0; }

.document-row h4,
.mini-template-row h4 {
  margin: 7px 0 3px;
  font: 700 15px/1.45 var(--serif);
}

.document-row p,
.mini-template-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 38px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  font: 700 17px/1.4 var(--serif);
}

.empty-state p {
  margin: 5px 0 0;
  font-size: 13px;
}

.empty-state.compact { padding: 20px; }

.study-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.study-tabs {
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  gap: 3px;
  background: var(--surface-3);
  overflow-x: auto;
}

.study-tabs button {
  min-height: 37px;
  padding: 0 14px;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.study-tabs button:hover { color: var(--ink); background: #fff; }

.study-tabs button.is-active {
  color: #fff;
  background: var(--ink);
}

.study-tab-panel { display: none; }
.study-tab-panel.is-active { display: block; animation: settle .22s ease both; }

.subsection-heading {
  margin: 18px 0 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.semester-hero {
  min-height: 174px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  color: #fff;
  background: var(--ink);
}

.semester-hero .eyebrow { color: #d8a89f; }

.semester-hero h3 {
  margin: 0;
  font: 700 clamp(24px, 3vw, 34px)/1.3 var(--serif);
}

.semester-hero p {
  max-width: 640px;
  margin: 8px 0 0;
  color: #c6d1ca;
}

.semester-progress {
  min-width: 190px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
}

.semester-progress strong {
  display: block;
  font: 800 28px/1.2 var(--mono);
}

.semester-progress span {
  display: block;
  margin-top: 5px;
  color: #c6d1ca;
  font-size: 12px;
}

.semester-course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.semester-course-card {
  min-height: 208px;
  padding: 19px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #fff;
}

.semester-course-card h4 {
  margin: 13px 0 7px;
  font: 700 19px/1.4 var(--serif);
}

.semester-course-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.course-meta-list {
  margin: 14px 0 0;
  display: grid;
  gap: 8px;
}

.course-meta-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.course-meta-row strong {
  color: var(--ink-2);
  font-weight: 700;
}

.course-card-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.case-workbench {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.case-list-panel { position: sticky; top: 88px; }

.case-list {
  padding: 10px;
  display: grid;
  gap: 5px;
}

.case-list-button {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
}

.case-list-button:hover { border-color: var(--line); background: var(--surface-3); }
.case-list-button.is-active { color: #fff; border-color: var(--green); background: var(--green); }
.case-list-button strong { display: block; font-size: 13px; }
.case-list-button small { display: block; margin-top: 4px; color: var(--muted); }
.case-list-button.is-active small { color: #d8e5dd; }

.case-editor {
  padding: 22px;
}

.case-editor-head {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.case-editor-head h3 {
  margin: 0;
  font: 700 25px/1.35 var(--serif);
}

.case-editor-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.case-editor-actions { display: flex; gap: 6px; }

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

.case-section {
  padding: 15px;
  border: 1px solid var(--line);
  background: var(--surface-3);
}

.case-section label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
}

.case-section textarea {
  width: 100%;
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  resize: vertical;
  background: #fff;
  line-height: 1.7;
}

.case-section.span-2 { grid-column: span 2; }

.source-toolbar {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.source-toolbar .search-field { flex: 1; }

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

.source-card {
  min-height: 188px;
  padding: 18px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #fff;
}

.source-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.source-card h4 {
  margin: 13px 0 7px;
  font: 700 18px/1.43 var(--serif);
}

.source-citation {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
}

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

.source-card-foot {
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.course-item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.course-item-panel { min-height: 520px; }

.course-item-list {
  padding: 0 18px 10px;
}

.course-item {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.course-item:first-child { border-top: 0; }

.course-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.course-item h4 {
  margin: 8px 0 5px;
  font: 700 17px/1.43 var(--serif);
}

.course-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.course-item-actions {
  display: flex;
  gap: 3px;
}

.question-status {
  display: inline-flex;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 3px;
  align-items: center;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 11px;
  font-weight: 800;
}

.question-status.resolved {
  color: var(--green);
  background: var(--green-soft);
}

.course-panel { position: sticky; top: 88px; }

.course-list {
  padding: 12px;
  display: grid;
  gap: 7px;
}

.course-button {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  text-align: left;
}

.course-button:hover { border-color: var(--line); background: var(--surface-3); }

.course-button.is-active {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.course-button strong {
  display: block;
  font-size: 13px;
}

.course-button small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.course-button.is-active small { color: #d4e3da; }

.course-count {
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
}

.course-button.is-active .course-count {
  color: #fff;
  background: rgba(255, 255, 255, .16);
}

.study-content { min-width: 0; }

.section-heading {
  min-height: 58px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.inline-search,
.search-field,
.global-search-input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
}

.inline-search { width: min(280px, 100%); }
.inline-search svg,
.search-field svg,
.global-search-input svg { width: 17px; color: var(--muted); flex: 0 0 auto; }

.inline-search input,
.search-field input,
.global-search-input input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.note-card {
  position: relative;
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.note-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(23, 36, 45, .07);
}

.note-card h3 {
  margin: 14px 40px 8px 0;
  font: 700 18px/1.42 var(--serif);
}

.note-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.note-card .note-source {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11px;
}

.card-menu {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 2px;
}

.task-status-strip {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #fff;
}

.task-status-card {
  min-height: 86px;
  padding: 16px;
  border-left: 1px solid var(--line);
}

.task-status-card:first-child { border-left: 0; }

.task-status-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.task-status-card strong {
  display: block;
  margin-top: 3px;
  font: 800 25px/1.2 var(--mono);
}

.task-status-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.task-filter-head { min-height: 72px; }

.segmented-control {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  gap: 2px;
  background: var(--surface-3);
}

.segmented-control button {
  min-height: 31px;
  padding: 0 10px;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.segmented-control button.is-active {
  color: #fff;
  background: var(--ink);
}

.template-toolbar {
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px;
  gap: 10px;
}

.search-field { width: 100%; }

.select-wrap {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.select-wrap select {
  width: 100%;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.filter-row {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
}

.filter-chip:hover { color: var(--ink); border-color: var(--line-strong); }

.filter-chip.is-active {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.template-library {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.template-card {
  min-height: 238px;
  padding: 20px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #fff;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.template-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(23, 36, 45, .07);
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.template-card h3 {
  margin: 16px 0 8px;
  font: 700 20px/1.38 var(--serif);
}

.template-card p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 13px;
}

.template-meta {
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.template-actions {
  display: flex;
  gap: 3px;
}

.document-heading {
  align-items: flex-start;
}

.document-toolbar {
  margin-bottom: 16px;
  padding: 13px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.document-template-select,
.draft-select {
  min-width: 0;
}

.document-template-select label,
.draft-select label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.document-template-select select,
.draft-select select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}

.document-workspace {
  display: grid;
  grid-template-columns: minmax(320px, .78fr) minmax(460px, 1.22fr);
  gap: 18px;
  align-items: start;
}

.fields-panel { position: sticky; top: 86px; }

.dynamic-fields {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.field {
  display: block;
}

.field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fbfcfa;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  background: #fff;
}

.field-hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.paper-preview {
  min-height: 760px;
  padding: 54px clamp(34px, 5vw, 76px);
  font-family: var(--serif);
  background: #fff;
  box-shadow: 0 18px 48px rgba(23, 36, 45, .08);
}

.paper-preview h2 {
  margin: 0 0 42px;
  text-align: center;
  font: 700 28px/1.5 var(--serif);
  letter-spacing: .2em;
}

.paper-content {
  font-size: 16px;
  line-height: 2;
  white-space: pre-wrap;
}

.paper-content .missing-value {
  color: var(--red);
  background: var(--red-soft);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
}

.paper-empty {
  min-height: 520px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.paper-empty strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow-strong);
}

.dialog::backdrop {
  background: rgba(13, 27, 34, .66);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  padding: 26px;
}

.dialog-head {
  margin-bottom: 21px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2,
.identity-dialog-copy h2 {
  margin: 0;
  font: 700 27px/1.28 var(--serif);
}

.dialog-head .eyebrow,
.identity-dialog-copy .eyebrow { margin-bottom: 6px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.span-2 { grid-column: span 2; }

.dialog-actions {
  margin-top: 23px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.identity-dialog { width: min(680px, calc(100vw - 32px)); }

.identity-dialog-copy {
  margin-bottom: 22px;
}

.identity-dialog-copy > p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
}

.identity-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.identity-option {
  min-height: 220px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: start;
  background: #fff;
  text-align: left;
}

.identity-option:hover:not(:disabled) { border-color: var(--line-strong); }

.identity-option.is-selected {
  border: 2px solid var(--red);
  background: #fcf5f3;
}

.identity-seal {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--red);
  font: 700 20px/1 var(--serif);
}

.identity-option strong {
  display: block;
  margin-bottom: 6px;
  font: 700 19px/1.4 var(--serif);
}

.identity-option small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.identity-option em {
  display: block;
  margin-top: 12px;
  color: var(--red);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.template-dialog { width: min(900px, calc(100vw - 32px)); }

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

.settings-list article {
  min-height: 88px;
  padding: 15px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.settings-list article strong {
  display: block;
  font-size: 14px;
}

.settings-list article p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.storage-note {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface-3);
}

.storage-note strong { font-size: 13px; }
.storage-note p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.search-dialog { width: min(760px, calc(100vw - 32px)); }

.global-search-input {
  min-height: 50px;
  margin-bottom: 15px;
}

.global-search-input input { font-size: 16px; }

.search-results {
  max-height: min(520px, 58vh);
  overflow: auto;
}

.search-result-group {
  margin-bottom: 16px;
}

.search-result-group h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
}

.search-result {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #fff;
  text-align: left;
}

.search-result:first-of-type { border-top: 1px solid var(--line); }
.search-result:hover { background: var(--surface-3); }
.search-result strong { display: block; font-size: 13px; }
.search-result small { color: var(--muted); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  max-width: min(380px, calc(100vw - 32px));
  padding: 13px 16px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow-strong);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1240px) {
  .overview-grid > .wide { grid-column: span 7; }
  .overview-grid > .daily-panel { grid-column: span 5; }
  .template-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1060px) {
  .app-shell { grid-template-columns: 196px minmax(0, 1fr); }
  .sidebar { padding-left: 14px; padding-right: 14px; }
  .search-trigger { width: 250px; }
  .search-trigger span { display: none; }
  .search-trigger kbd { margin-left: 0; }
  .overview-grid > .panel,
  .overview-grid > .wide,
  .overview-grid > .daily-panel { grid-column: span 12; }
  .study-layout { grid-template-columns: 225px minmax(0, 1fr); }
  .semester-course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-workspace { grid-template-columns: minmax(280px, .85fr) minmax(400px, 1.15fr); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: sticky;
    height: auto;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    overflow: visible;
  }

  .brand {
    padding: 0;
    border-bottom: 0;
  }

  .brand-kicker { display: none; }
  .brand h1 { font-size: 20px; white-space: nowrap; }

  .main-nav {
    margin: 0;
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    overflow-x: auto;
  }

  .main-nav button {
    width: auto;
    min-width: max-content;
    min-height: 40px;
    padding: 0 10px;
  }

  .main-nav button span { display: none; }
  .main-nav button svg { width: 19px; height: 19px; }

  .sidebar-foot {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end;
  }

  .identity-card-button {
    width: auto;
    min-height: 40px;
    padding: 0 10px;
  }

  .identity-card-button small,
  .identity-card-button > span:last-child { display: none; }
  .settings-button { min-height: 40px; }

  .main { padding: 0 18px 48px; }
  .topbar { min-height: 60px; }
  .privacy-notice { margin-top: 14px; }
  .privacy-notice-tag { display: none; }
  .overview-intro,
  .page-heading { align-items: flex-start; flex-direction: column; }
  .intro-actions,
  .heading-actions { width: 100%; flex-wrap: wrap; }
  .study-layout { grid-template-columns: 1fr; }
  .semester-hero { grid-template-columns: 1fr; align-items: start; }
  .semester-progress { min-width: 0; }
  .case-workbench { grid-template-columns: 1fr; }
  .case-list-panel { position: static; }
  .source-toolbar { align-items: stretch; flex-direction: column; }
  .course-item-grid { grid-template-columns: 1fr; }
  .course-panel { position: static; }
  .course-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-workspace { grid-template-columns: 1fr; }
  .fields-panel { position: static; }
  .paper-preview { min-height: auto; }
  .identity-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .identity-option:last-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .sidebar {
    grid-template-columns: 1fr auto;
    padding: 12px;
  }

  .brand h1 { font-size: 18px; }
  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .main-nav button {
    padding: 0 9px;
  }

  .sidebar-foot {
    grid-column: auto;
    grid-row: 1;
  }

  .settings-button { width: 40px; padding: 0; justify-content: center; }
  .settings-button { font-size: 0; }
  .identity-card-button strong { font-size: 12px; }

  .main { padding: 0 12px 42px; }
  .topbar { padding: 10px 0; align-items: stretch; flex-direction: column; }
  .breadcrumb { display: none; }
  .topbar-actions { width: 100%; }
  .search-trigger { flex: 1; width: auto; }
  .topbar-actions > .button.primary { padding: 0 11px; }

  .privacy-notice {
    align-items: flex-start;
    padding: 13px;
  }

  .privacy-notice-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .overview-intro,
  .page-heading { padding-top: 25px; }
  .overview-intro h2,
  .page-heading h2 { font-size: 32px; }

  .panel-head {
    min-height: auto;
    padding: 15px;
    align-items: flex-start;
    flex-direction: column;
  }

  .task-filter-head { align-items: stretch; }
  .segmented-control { width: 100%; overflow-x: auto; }
  .segmented-control button { flex: 1; min-width: max-content; }

  .course-list,
  .note-grid,
  .template-library,
  .task-status-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .semester-course-grid,
  .source-grid,
  .case-form-grid {
    grid-template-columns: 1fr;
  }

  .case-section.span-2 { grid-column: span 1; }
  .case-editor { padding: 17px; }
  .case-editor-head { flex-direction: column; }
  .study-tabs { padding: 3px; }
  .study-tabs button { padding: 0 11px; }

  .identity-options { grid-template-columns: 1fr; }
  .identity-option:last-child { grid-column: auto; }

  .task-status-card {
    min-height: 72px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .task-status-card:first-child { border-top: 0; }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-search { width: 100%; }
  .template-toolbar { grid-template-columns: 1fr; }
  .document-toolbar { grid-template-columns: 1fr; }
  .document-toolbar .button { width: 100%; }
  .paper-preview { padding: 38px 22px; }
  .paper-preview h2 { font-size: 23px; }
  .paper-content { font-size: 15px; }
  .dialog-shell { padding: 20px; }
  .span-2 { grid-column: span 1; }

  .dialog,
  .identity-dialog,
  .template-dialog,
  .search-dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    margin: 8px auto !important;
    overflow-x: hidden;
  }

  .identity-dialog .dialog-shell { padding: 20px 18px; }
  .identity-dialog-copy > p:last-child { overflow-wrap: anywhere; }
  .identity-option { min-width: 0; }

  .settings-list article {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .privacy-notice,
  .page-heading,
  .document-toolbar,
  .fields-panel,
  .toast {
    display: none !important;
  }

  .app-shell,
  .main,
  .document-workspace {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .view { display: none !important; }
  .view[data-view="document"] { display: block !important; }
  .paper-preview {
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}

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