:root {
  --bg: #f7f6f3;
  --ink: #1a1917;
  --muted: #787774;
  --line: rgba(0, 0, 0, 0.08);
  --surface: #ffffff;
  --accent: #1a1917;
  --pale-red: #fdebec;
  --pale-red-ink: #9f2f2d;
  --pale-blue: #e1f3fe;
  --pale-blue-ink: #1f6c9f;
  --pale-green: #edf3ec;
  --pale-green-ink: #346538;
  --pale-yellow: #fbf3db;
  --pale-yellow-ink: #956400;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "DM Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #efece4 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8ebe4 0%, transparent 50%),
    var(--bg);
}

.shell {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

.top {
  margin-bottom: 2rem;
  animation: rise 0.55s var(--ease) both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 12px;
  height: 12px;
  background: var(--ink);
  border-radius: 2px;
  transform: rotate(12deg);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
}

.lede {
  margin: 0.85rem 0 0;
  color: var(--muted);
  max-width: 28rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  display: grid;
  gap: 1rem;
  animation: rise 0.65s var(--ease) 0.05s both;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field.grow {
  flex: 1;
  min-width: 0;
}

.label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfbfa;
  color: var(--ink);
  padding: 0.72rem 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.token-box {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.token-box summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}

.token-box summary::-webkit-details-marker {
  display: none;
}

.token-box[open] summary {
  margin-bottom: 0.75rem;
  color: var(--ink);
}

.hint {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: #33312e;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  background: #f3f2ee;
}

.status {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.95rem;
  animation: rise 0.35s var(--ease) both;
}

.status.error {
  background: var(--pale-red);
  border-color: transparent;
  color: var(--pale-red-ink);
}

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

.result {
  margin-top: 1.25rem;
  animation: rise 0.45s var(--ease) both;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chip {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: #eceae4;
  color: var(--ink);
}

.chip.pale-blue {
  background: var(--pale-blue);
  color: var(--pale-blue-ink);
}

.chip.pale-green {
  background: var(--pale-green);
  color: var(--pale-green-ink);
}

.chip.pale-yellow {
  background: var(--pale-yellow);
  color: var(--pale-yellow-ink);
}

.transcript {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: min(62vh, 720px);
  overflow: auto;
  font-size: 0.98rem;
  line-height: 1.65;
}

.chunk {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.85rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.chunk:last-child {
  border-bottom: none;
}

.chunk time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 0.15rem;
}

.foot {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
  animation: rise 0.7s var(--ease) 0.1s both;
}

.foot a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.foot a:hover {
  border-bottom-color: currentColor;
}

.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

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

@media (max-width: 560px) {
  .shell {
    padding-top: 2rem;
  }

  .panel {
    padding: 1.1rem;
  }

  .chunk {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
