:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-strong: #1f2630;
  --line: #303946;
  --text: #f0f6fc;
  --muted: #a8b3c2;
  --accent: #2f81f7;
  --accent-strong: #1f6feb;
  --ok: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(47, 129, 247, 0.16), transparent 34rem), var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.workspace {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.intro {
  grid-column: 1 / -1;
  padding: 4px 2px 12px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: #7aa2f7;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

h2 {
  font-size: 1.1rem;
}

.lede {
  margin: 12px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 1.02rem;
}

.tool-panel,
.result-panel,
.history-panel {
  border: 1px solid var(--line);
  background: rgba(21, 27, 35, 0.92);
  box-shadow: var(--shadow);
}

.tool-panel,
.result-panel {
  border-radius: 8px;
  padding: 22px;
}

.history-panel {
  grid-column: 1 / -1;
  border-radius: 8px;
  padding: 18px;
}

.field-row {
  display: grid;
  gap: 8px;
}

label,
legend {
  color: var(--text);
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
}

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

.lab-picker {
  border: 0;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lab-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}

.lab-picker label {
  position: relative;
}

.lab-picker input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.lab-picker span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  color: var(--muted);
  cursor: pointer;
}

.lab-picker input:checked + span {
  border-color: var(--accent);
  background: rgba(47, 129, 247, 0.14);
  color: var(--text);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent-strong);
}

.primary-button:hover {
  background: var(--accent);
}

.secondary-button {
  border-color: var(--line);
  background: var(--panel-strong);
}

.secondary-button:hover,
.icon-button:hover:not(:disabled) {
  border-color: #6e7681;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-color: var(--line);
  background: var(--panel-strong);
}

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

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.token-output {
  min-height: 150px;
  margin: 18px 0 10px;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  color: #dbeafe;
  font-size: 0.92rem;
  line-height: 1.55;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.history-list:empty::before {
  content: "No tokens generated in this session yet.";
  color: var(--muted);
}

.history-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
}

.history-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.history-token {
  overflow-wrap: anywhere;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

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

.status-warning {
  color: var(--warning);
}

.status-danger {
  color: var(--danger);
}

@media (max-width: 760px) {
  .app-shell {
    align-items: stretch;
    padding: 24px 14px;
  }

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

  .lab-picker {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .history-list li {
    grid-template-columns: 1fr;
  }
}
