:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ed;
  --ink: #17201a;
  --muted: #667067;
  --line: #dce3dc;
  --primary: #2c6f58;
  --primary-2: #1f5946;
  --accent: #c26a31;
  --danger: #b84242;
  --ok: #2f7d4d;
  --shadow: 0 18px 42px rgba(28, 41, 32, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  background: linear-gradient(120deg, #f6f7f4 0%, #eff4ef 100%);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 7vw, 92px);
}

.auth-panel h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 1;
  letter-spacing: 0;
}

.auth-panel p {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.auth-card {
  align-self: center;
  width: min(440px, calc(100% - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h2,
.panel-title {
  margin: 0;
  font-size: 24px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

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

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

.field textarea {
  min-height: 138px;
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 88, 0.13);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

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

.btn.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.btn.secondary:hover {
  background: var(--surface-2);
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--primary);
}

.btn.full {
  width: 100%;
  margin-top: 20px;
}

.message {
  min-height: 22px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand strong {
  font-size: 22px;
}

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

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

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.user-strip {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-strip small {
  color: var(--muted);
}

.content {
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

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

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

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

.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

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

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

.quiz-card {
  display: grid;
  gap: 18px;
}

.prompt {
  display: grid;
  gap: 10px;
  min-height: 172px;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 24px;
}

.prompt-label {
  color: var(--muted);
  font-size: 14px;
}

.zh {
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 800;
  line-height: 1.12;
}

.letters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 8px;
  max-width: 620px;
}

.letter {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.letter.filled {
  color: var(--ink);
  border-color: rgba(44, 111, 88, 0.45);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.list-item strong {
  display: block;
}

.list-item small {
  color: var(--muted);
}

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

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

.table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary-2);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
}

.result-score {
  font-size: clamp(44px, 8vw, 78px);
  font-weight: 900;
}

.weakness {
  display: grid;
  gap: 10px;
}

.weakness-item {
  display: grid;
  gap: 6px;
  border-left: 4px solid var(--accent);
  background: #fff8f2;
  padding: 12px;
}

.answer-state {
  font-weight: 800;
}

.answer-state.ok {
  color: var(--ok);
}

.answer-state.bad {
  color: var(--danger);
}

@media (max-width: 920px) {
  .auth-view,
  .layout,
  .grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .content,
  .sidebar,
  .auth-panel,
  .auth-card {
    padding: 18px;
  }

  .stats,
  .nav {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .list-item {
    align-items: flex-start;
    flex-direction: column;
  }
}
