:root {
  color-scheme: light dark;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
  background: var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 0; overflow-x: clip; }
body, #app { min-width: 0; }
#app:empty, #app > p.page[role='status'] { min-height: 100vh; }
figure, h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .54; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--sage); outline-offset: 2.5px; }
.shell { width: min(calc(100% - 2rem), var(--shell)); margin-inline: auto; }
.skip-link {
  position: fixed; top: .75rem; left: .75rem; transform: translateY(-180%);
  background: var(--paper); border: 1px solid var(--line); border-radius: .65rem;
  padding: .6rem 1rem; box-shadow: var(--shadow-md); z-index: 20;
}
.skip-link:focus { transform: none; }

.header-inner { min-height: 4.8rem; display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.brand {
  display: inline-flex; flex: none; gap: .68rem; align-items: center;
  text-decoration: none; line-height: 1.2; font-weight: 750; font-size: 1.12rem; letter-spacing: .015em;
}
.brand-en {
  display: block; margin-top: .16rem;
  color: var(--muted); font-family: Georgia, 'Times New Roman', serif;
  font-style: italic; font-weight: 400; font-size: .74rem; letter-spacing: .02em;
}

.button {
  display: inline-flex; gap: .4rem; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: .7rem;
  padding: .62rem 1.15rem; min-height: 2.65rem;
  font-weight: 650; font-size: .94rem; line-height: 1.3;
  background: var(--paper); text-decoration: none; white-space: nowrap;
  transition: background-color .18s var(--ease-out), border-color .18s var(--ease-out),
    color .18s var(--ease-out), transform .16s var(--ease-out), box-shadow .18s var(--ease-out);
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary {
  color: #fffdf8; background: var(--action-fill);
  box-shadow: 0 2px 6px light-dark(rgba(53, 85, 68, .22), rgba(0, 0, 0, .32));
}
.button.primary:hover:not(:disabled) {
  background: light-dark(#2c4839, #4c765f);
  box-shadow: 0 4px 12px light-dark(rgba(53, 85, 68, .28), rgba(0, 0, 0, .42));
}
.button.outline {
  border-color: var(--line);
  background: light-dark(rgba(255, 253, 248, .85), rgba(38, 34, 30, .9));
  color: var(--ink);
}
.button.outline:hover:not(:disabled) {
  background: var(--paper); border-color: var(--sage); color: var(--sage);
}
.button.small { min-height: 2.35rem; padding: .42rem .88rem; font-size: .88rem; }

.text-link {
  display: inline-flex; align-items: center; gap: .25rem; min-height: 2.35rem;
  color: var(--sage); text-decoration: none;
  border-bottom: 1px solid transparent; font-weight: 630;
  transition: color .16s ease, border-color .16s ease;
}
.text-link:hover { border-bottom-color: currentColor; }

.page-title h1 { font-family: var(--font-display); letter-spacing: .025em; line-height: 1.3; }
.footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem 1.25rem;
  border-top: 1px solid var(--line); margin-top: 2.6rem; padding-block: 1.2rem 1.8rem;
  color: var(--muted); font-size: .86rem;
}
.footer a { color: var(--sage); text-underline-offset: .22em; }

.page { padding-block: clamp(1.1rem, 3vw, 2.2rem) 1.5rem; min-height: 60vh; }
.page-title { margin-bottom: 1.4rem; }
.page-title h1 { font-size: clamp(1.85rem, 1.5rem + 1.6vw, 2.85rem); }
.page-title p { margin-top: .4rem; color: var(--muted); font-size: .98rem; }

.filter-bar { display: flex; align-items: center; gap: .65rem; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: .45rem; }
.pill {
  display: inline-flex; align-items: center; min-height: 2.45rem; padding: .35rem .88rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  text-decoration: none; font-size: .9rem;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.pill:hover { border-color: var(--sage); background: var(--inset); }
.pill[aria-current], .pill[aria-pressed='true'] {
  border-color: light-dark(#98ae95, #6c8870);
  background: var(--mint); color: var(--sage); font-weight: 660;
}

input[type='search'], textarea, input[type='url'], select {
  width: 100%; min-height: 2.65rem; padding: .5rem .78rem;
  border: 1px solid var(--line); background: var(--field);
  border-radius: .6rem; color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
input[type='search']:focus, textarea:focus, input[type='url']:focus, select:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px light-dark(rgba(59, 93, 75, .14), rgba(168, 202, 162, .16));
  outline: none;
}
input[type='search'] { width: min(100%, 19rem); }

.catalog { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem; }
.list-card, .panel, .login-panel {
  border: 1px solid var(--line); border-radius: 1rem;
  background: var(--paper); padding: 1.3rem; min-width: 0;
  box-shadow: var(--shadow-sm);
}
.list-card { display: grid; gap: .48rem; transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), border-color .2s ease; }
.list-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.list-card h2 { font-size: 1.15rem; line-height: 1.42; }
.card-meta { color: var(--clay); font-size: .86rem; font-weight: 650; }
.card-subtitle, .muted { color: var(--muted); }
.list-card .text-link { justify-self: start; }

.work-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1.15rem; align-items: start; }
.work-layout h2, .panel h2 { font-size: 1.24rem; margin-bottom: .55rem; }
.prompt-text, .model-copy {
  font-family: Georgia, 'Times New Roman', serif; font-size: 1.09rem; line-height: 1.68;
  white-space: pre-line; overflow-wrap: anywhere;
}
.prompt-text { margin: .55rem 0 .85rem; }
.writing-editor {
  width: 100%; min-height: 19rem; resize: vertical; line-height: 1.72;
  font-family: Georgia, 'Times New Roman', serif; font-size: 1.06rem;
}
.work-toolbar { display: flex; gap: .6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-block: .6rem; }
.status-line { color: var(--sage); font-size: .9rem; font-weight: 550; }

.table-scroll { overflow-x: auto; border-radius: .6rem; }
.task-data { width: 100%; border-collapse: collapse; border-spacing: 0; font-size: .93rem; font-variant-numeric: tabular-nums; }
.task-data th, .task-data td { padding: .48rem .6rem; border: 1px solid var(--line); text-align: center; }
.task-data th { background: var(--inset); font-weight: 650; }
.task-data caption { color: var(--muted); text-align: start; margin-bottom: .38rem; font-size: .88rem; }

dialog {
  width: min(calc(100% - 1.5rem), 46rem); max-height: min(86vh, 44rem);
  padding: clamp(1.1rem, 3.2vw, 1.85rem); border: 1px solid var(--line);
  border-radius: 1.15rem; color: var(--ink); background: var(--paper);
  box-shadow: var(--shadow-lg);
}
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: light-dark(rgba(36, 26, 20, .42), rgba(10, 8, 7, .74)); backdrop-filter: blur(4px); overflow: hidden; overscroll-behavior: contain; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 1.2rem; font-family: var(--font-display); }

.lesson-body { display: grid; gap: .85rem; }
.lesson-body ol { padding-left: 1.45rem; margin-block: 0; }
.lesson-body li + li { margin-top: .4rem; }
.login-panel { max-width: 30rem; margin-inline: auto; padding: clamp(1rem, 4vw, 2rem); }
.login-panel h1 { margin-block: .25rem .5rem; font-size: 1.9rem; }
.login-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.balance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.balance-grid dd { font-size: 1.5rem; font-weight: 700; }
.empty { grid-column: 1 / -1; padding: 1.4rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 1rem; text-align: center; }

@media (max-width: 56rem) {
  .work-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 43.75rem) {
  .catalog { grid-template-columns: minmax(0, 1fr); gap: .72rem; }
}

.question-visual { margin-block: .75rem; }
.question-visual img { max-width: 100%; max-height: 38rem; height: auto; display: block; margin-inline: auto; border-radius: .5rem; }
.balance-grid + .panel { margin-bottom: 1rem; }
.mock-session {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  flex-wrap: wrap; margin: .85rem 0; padding: .85rem 1.05rem;
  border: 1px solid var(--line); border-radius: .75rem; background: var(--inset);
}
.mock-session [role=timer] { font-variant-numeric: tabular-nums; font-weight: 700; }
.mock-session small:empty { display: none; }
.mock-session small { flex-basis: 100%; color: var(--muted); }
.mock-other { text-align: right; margin-bottom: .7rem; }
