:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-2: #f7fafb;
  --ink: #172126;
  --muted: #66747c;
  --line: #dce5ea;
  --primary: #187b68;
  --primary-dark: #0d5f50;
  --navy: #162326;
  --gold: #f3bf42;
  --coral: #f06f4f;
  --blue: #336fbd;
  --ok: #148a56;
  --warn: #bb6a13;
  --bad: #ba3731;
  --shadow: 0 18px 52px rgba(19, 35, 44, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(24, 123, 104, 0.1), transparent 34%),
    linear-gradient(220deg, rgba(240, 111, 79, 0.12), transparent 30%),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.hidden {
  display: none !important;
}

.auth-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 460px);
  min-height: 100vh;
}

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

.auth-panel h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3rem, 8vw, 6.5rem);
  line-height: 0.95;
}

.auth-panel p {
  max-width: 620px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

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

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

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

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

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--gold);
  font-weight: 950;
}

.brand strong {
  display: block;
  font-size: 1.24rem;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
  font-weight: 800;
}

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

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

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

.content {
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.05;
}

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

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

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

.stat,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(19, 35, 44, 0.06);
}

.stat {
  padding: 14px;
}

.stat span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.stat strong {
  display: block;
  margin-top: 8px;
  color: var(--primary-dark);
  font-size: 1.65rem;
}

.panel {
  padding: 18px;
}

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

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

.field span,
.field-label,
.prompt-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

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

.field textarea {
  min-height: 136px;
  padding: 12px;
  line-height: 1.6;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(24, 123, 104, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(19, 35, 44, 0.12);
}

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

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

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

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

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

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

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--bad);
  font-size: 0.9rem;
}

.prompt {
  min-height: 190px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
}

.zh {
  margin-top: 14px;
  font-size: clamp(2.2rem, 7vw, 5.4rem);
  font-weight: 950;
  line-height: 1;
  overflow-wrap: anywhere;
}

.hint {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 750;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef2;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--coral));
  transition: width 180ms ease;
}

.answer-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.feedback {
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 850;
}

.feedback.ok {
  border-left-color: var(--ok);
  background: #f3fbf6;
}

.feedback.bad {
  border-left-color: var(--bad);
  background: #fff4f2;
}

.feedback.warn {
  border-left-color: var(--warn);
  background: #fff8ec;
}

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

.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: var(--radius);
  padding: 12px;
}

.list-item strong {
  display: block;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary-dark);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

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

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

.table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

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

.result-score {
  color: var(--primary-dark);
  font-size: clamp(3rem, 9vw, 5.4rem);
  font-weight: 950;
  line-height: 1;
}

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

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

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

@media (max-width: 960px) {
  .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: 620px) {
  .auth-panel,
  .auth-card,
  .content,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .list-item {
    align-items: stretch;
    flex-direction: column;
  }

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