﻿@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #0f0f10;
  --bg-elev: #16161a;
  --panel: #1a1a1f;
  --panel-soft: #1e1e24;
  --text: #f4f3fb;
  --muted: #b9b6ce;
  --accent: #8a2be2;
  --accent-2: #b46dff;
  --border: #2b2a34;
  --ok: #3bd28f;
  --danger: #ff6b7a;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.42);
  --dur-fast: 160ms;
  --dur-mid: 260ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f7f7fb;
    --bg-elev: #ffffff;
    --panel: #ffffff;
    --panel-soft: #f7f4ff;
    --text: #1c1a28;
    --muted: #66617b;
    --accent: #7b2cd6;
    --accent-2: #a960f6;
    --border: #e6e1f1;
    --shadow-sm: 0 6px 14px rgba(45, 36, 78, 0.08);
    --shadow-md: 0 14px 32px rgba(45, 36, 78, 0.14);
    --shadow-lg: 0 22px 60px rgba(45, 36, 78, 0.18);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f10;
  --bg-elev: #16161a;
  --panel: #1a1a1f;
  --panel-soft: #1e1e24;
  --text: #f4f3fb;
  --muted: #b9b6ce;
  --accent: #8a2be2;
  --accent-2: #b46dff;
  --border: #2b2a34;
  --ok: #3bd28f;
  --danger: #ff6b7a;
  --shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.42);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f7fb;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f7f4ff;
  --text: #1c1a28;
  --muted: #66617b;
  --accent: #7b2cd6;
  --accent-2: #a960f6;
  --border: #e6e1f1;
  --ok: #177a51;
  --danger: #c83548;
  --shadow-sm: 0 6px 14px rgba(45, 36, 78, 0.08);
  --shadow-md: 0 14px 32px rgba(45, 36, 78, 0.14);
  --shadow-lg: 0 22px 60px rgba(45, 36, 78, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  scroll-behavior: smooth;
}

html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

.lenis.lenis-autoToggle {
  transition-property: overflow;
  transition-duration: 1ms;
  transition-behavior: allow-discrete;
}

.lenis.lenis-stopped {
  overflow: clip;
}

body {
  font-family: 'Space Grotesk', 'Noto Sans TC', 'Noto Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 12% -20%, rgba(138, 43, 226, 0.22), transparent 62%),
    radial-gradient(900px 460px at 92% -16%, rgba(180, 109, 255, 0.18), transparent 58%),
    linear-gradient(160deg, color-mix(in oklab, var(--bg) 95%, #000 5%), var(--bg));
  line-height: 1.55;
  letter-spacing: 0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1140px, 94vw);
  margin-inline: auto;
}

.muted {
  color: var(--muted);
}

.row {
  display: grid;
  gap: 12px;
}

main {
  display: grid;
  gap: 16px;
  padding: 16px 20px;
}

.panel,
.card {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklab, var(--border) 86%, transparent);
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--panel) 94%, #fff 6%), var(--panel));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    var(--shadow-md);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-mid) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.panel {
  padding: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .panel:hover,
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in oklab, var(--accent) 38%, var(--border));
  }
}

.group-label {
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

label.inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

label.inline.wide {
  display: grid;
  gap: 6px;
  margin-right: 0;
}

.controls {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

.controls > * {
  min-width: 0;
}

.controls .wide {
  grid-column: 1 / -1;
}

.io {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

textarea,
pre.output,
input[type='text'],
select,
button {
  font: inherit;
}

textarea,
pre.output,
input[type='text'],
select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel-soft) 92%, #000 8%);
  color: var(--text);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

textarea,
pre.output {
  min-height: 300px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.output {
  margin: 0;
  overflow: auto;
}

input[type='text'],
select {
  padding: 9px 10px;
}

textarea:focus-visible,
input[type='text']:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: none;
  border-color: color-mix(in oklab, var(--accent) 60%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 34%, transparent);
}

button {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in oklab, var(--panel-soft) 92%, #000 8%);
  color: var(--text);
  padding: 10px 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-mid) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button.primary,
.download-btn {
  border-color: color-mix(in oklab, var(--accent) 68%, var(--border));
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
}

button.ghost {
  background: color-mix(in oklab, var(--panel-soft) 82%, transparent);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-weight: 700;
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-mid) var(--ease-out),
    filter var(--dur-fast) var(--ease-out);
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.04);
}

.feature-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.feature-card::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: right var(--dur-mid) var(--ease-out);
}

.feature-card:hover::after {
  right: 0;
}

.stats-cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel-soft) 88%, #000 12%);
  padding: 10px 12px;
}

.stat-title {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

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

.stop-row {
  position: relative;
  display: grid;
  gap: 8px;
  align-items: center;
  grid-template-columns: 24px auto 1fr 140px auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel-soft) 88%, #000 12%);
  padding: 8px;
}

.stop-row.dragging {
  border-color: color-mix(in oklab, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 25%, transparent);
}

.stop-row.drop-before::before,
.stop-row.drop-after::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.stop-row.drop-before::before { top: -1px; }
.stop-row.drop-after::after { bottom: -1px; }

.preview-block {
  min-height: 68px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel-soft) 88%, #000 12%);
  padding: 12px;
}

.preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 3px 7px;
  background: color-mix(in oklab, var(--panel-soft) 86%, #000 14%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 12px;
}

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

.out-card {
  display: grid;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel-soft) 88%, #000 12%);
  padding: 10px;
}

.hint,
.note {
  color: var(--muted);
  font-size: 12px;
}

.success {
  color: var(--ok);
}

@media (max-width: 900px) {
  .io {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  main {
    padding: 12px;
  }

  button,
  select,
  input[type='text'] {
    min-height: 42px;
  }

  .stop-row {
    grid-template-columns: 24px 1fr;
  }

  .stop-row > *:not(.drag-handle) {
    grid-column: 2 / -1;
  }
}

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