:root {
  color-scheme: dark;
  font-family: Roboto, "Noto Sans TC", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-synthesis: none;
  text-rendering: optimizeLegibility;

  /* Material Design 3 dark roles, mapped to the Catppuccin Mocha palette. */
  --md-sys-color-primary: #cba6f7;
  --md-sys-color-on-primary: #1e1e2e;
  --md-sys-color-primary-container: #45475a;
  --md-sys-color-on-primary-container: #cdd6f4;
  --md-sys-color-secondary: #b4befe;
  --md-sys-color-secondary-container: #45475a;
  --md-sys-color-on-secondary-container: #cdd6f4;
  --md-sys-color-tertiary: #94e2d5;
  --md-sys-color-tertiary-container: #313e43;
  --md-sys-color-error: #f38ba8;
  --md-sys-color-success: #a6e3a1;
  --md-sys-color-warning: #f9e2af;
  --md-sys-color-background: #1e1e2e;
  --md-sys-color-on-background: #cdd6f4;
  --md-sys-color-surface: #1e1e2e;
  --md-sys-color-surface-container-lowest: #11111b;
  --md-sys-color-surface-container-low: #181825;
  --md-sys-color-surface-container: #313244;
  --md-sys-color-surface-container-high: #45475a;
  --md-sys-color-surface-container-highest: #585b70;
  --md-sys-color-outline: #6c7086;
  --md-sys-color-outline-variant: #45475a;
  --md-shape-corner-small: 8px;
  --md-shape-corner-medium: 12px;
  --md-shape-corner-large: 16px;
  --md-shape-corner-full: 999px;
  --md-elevation-level1: 0 1px 2px rgba(17, 17, 27, 0.35), 0 1px 3px 1px rgba(17, 17, 27, 0.2);
  --muted: #a6adc8;
  --line: var(--md-sys-color-outline-variant);
  --panel: var(--md-sys-color-surface-container);
  --accent: var(--md-sys-color-primary);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -15%, rgba(203, 166, 247, 0.12), transparent 46%),
    var(--md-sys-color-background);
}

button,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: 78px 0 32px;
}

.hero {
  margin-bottom: 32px;
}

.eyebrow,
.step-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.15em;
}

h1 {
  margin: 14px 0 12px;
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.intro {
  max-width: 580px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.runtime-card,
.panel,
.result-card {
  border: 1px solid var(--line);
  border-radius: var(--md-shape-corner-large);
  background: var(--md-sys-color-surface-container);
  box-shadow: var(--md-elevation-level1);
}

.runtime-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 18px;
  padding: 16px 19px;
  background: var(--md-sys-color-surface-container-low);
}

.status-light {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--md-sys-color-warning);
  box-shadow: 0 0 12px rgba(249, 226, 175, 0.3);
}

.status-light[data-state="ready"] {
  background: var(--md-sys-color-success);
  box-shadow: 0 0 12px rgba(166, 227, 161, 0.32);
}

.status-light[data-state="error"] {
  background: var(--md-sys-color-error);
  box-shadow: 0 0 12px rgba(243, 139, 168, 0.3);
}

.runtime-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.9rem;
}

.runtime-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

.panel {
  padding: 25px;
}

.section-heading,
.result-topline,
.result-main,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading {
  margin-bottom: 18px;
}

h2 {
  margin: 7px 0 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.character-count,
.field-note,
.result-time {
  color: var(--muted);
  font-size: 0.78rem;
}

textarea {
  display: block;
  width: 100%;
  min-height: 224px;
  resize: vertical;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-shape-corner-medium);
  outline: none;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-background);
  padding: 16px 17px;
  font-size: 0.98rem;
  line-height: 1.75;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea::placeholder {
  color: #7f849c;
}

textarea:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(203, 166, 247, 0.2);
}

.field-note {
  margin: 9px 0 21px;
}

.actions {
  justify-content: flex-start;
  gap: 11px;
}

.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--md-shape-corner-medium);
  padding: 0 17px;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, filter 120ms ease;
}

.button:not(:disabled):hover {
  filter: brightness(1.08);
}

.button:not(:disabled):active {
  transform: scale(0.98);
}

.button:focus-visible {
  outline: 3px solid rgba(203, 166, 247, 0.55);
  outline-offset: 2px;
}

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

.button-secondary {
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.button-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.button-hint {
  margin-left: 7px;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.68;
}

.model-progress {
  margin-top: 19px;
}

.model-progress-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.model-progress-bar {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--md-shape-corner-full);
  accent-color: var(--md-sys-color-primary);
}

.result-card {
  margin-top: 18px;
  padding: 23px 25px;
  animation: arrive 180ms ease-out;
}

.result-topline {
  margin-bottom: 19px;
}

.result-main {
  justify-content: flex-start;
  gap: 16px;
}

.result-caption {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.score {
  font-size: clamp(2.4rem, 8vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.difficulty-badge {
  border: 1px solid rgba(166, 227, 161, 0.35);
  border-radius: var(--md-shape-corner-full);
  background: rgba(166, 227, 161, 0.12);
  color: var(--md-sys-color-success);
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 650;
}

.difficulty-badge[data-level="hard"] {
  border-color: rgba(243, 139, 168, 0.38);
  background: rgba(243, 139, 168, 0.12);
  color: var(--md-sys-color-error);
}

.difficulty-badge[data-level="medium"] {
  border-color: rgba(249, 226, 175, 0.38);
  background: rgba(249, 226, 175, 0.12);
  color: var(--md-sys-color-warning);
}

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

.page-footer {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.75rem;
}

.footer-separator {
  color: var(--md-sys-color-outline);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

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

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 28px, 760px);
    padding-top: 48px;
  }

  .panel,
  .result-card {
    padding: 19px;
  }

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

  .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
