:root {
  --font: 'Fira Sans', 'Ubuntu', 'Segoe UI', 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  --shadow-soft: 0 14px 35px rgba(0, 0, 0, 0.14);
}

:root[data-theme='light'] {
  --bg: #edf1f7;
  --surface: #ffffff;
  --surface-muted: #f5f7fb;
  --border: #dfe4ef;
  --text: #0f162c;
  --muted: #6c7385;
  --accent: #5c7cfa;
  --accent-strong: #3b5bdb;
}

:root[data-theme='dark'] {
  --bg: #0c0f1a;
  --surface: #181c2c;
  --surface-muted: #101221;
  --border: #242a3d;
  --text: #e8ecf9;
  --muted: #9aa3ba;
  --accent: #7dc4ff;
  --accent-strong: #4fa0ff;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition:
    background 180ms ease,
    color 180ms ease;
}

#root {
  min-height: 100vh;
}
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(124, 155, 255, 0.08), transparent),
    radial-gradient(120% 80% at 90% 0%, rgba(255, 173, 91, 0.07), transparent), var(--bg);
  color: var(--text);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.icon {
  display: inline-block;
  vertical-align: middle;
}

.btn .icon {
  margin-right: 6px;
}

.inline-help {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  color: var(--muted);
}

.inline-help .icon {
  margin: 0;
}

.copy-container {
  position: relative;
}

.copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.copy-button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.copy-button:active {
  transform: translateY(1px);
}

.pill-action {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.16);
}

.pill-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.16);
}

.main-content {
  display: flex;
  gap: 18px;
  padding: 16px 18px 24px;
  width: min(1200px, 100%);
  margin: 0 auto;
  flex: 1;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.display-panel {
  flex: 1 1 60%;
  position: relative;
  overflow: hidden;
  min-height: clamp(420px, 70vh, 780px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-surface {
  background: color-mix(in srgb, var(--surface) 90%, var(--surface-muted) 10%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.section-heading.compact h3 {
  font-size: 1.05rem;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.display-canvas {
  position: relative;
  margin-top: 10px;
  border-radius: var(--radius-lg);
  padding: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(125, 199, 255, 0.12), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(255, 173, 91, 0.1), transparent 35%),
    color-mix(in srgb, var(--surface-muted) 50%, transparent);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #ffffff 20%, transparent);
  min-height: clamp(360px, 72vh, 900px);
  height: min(78vh, 880px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.display-shell {
  position: absolute;
  inset: 6px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid.align-end {
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.label {
  font-size: 0.9rem;
  color: var(--muted);
}

.control {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.98rem;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.control:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 80%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.control.color {
  padding: 0;
  height: 46px;
}

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

.color-value {
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--mono);
}

.toolbox {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.toolbox-header {
  background: none;
  border: none;
  padding: 0;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
}

.toolbox-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.toolbox-header:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, var(--border));
  outline-offset: 2px;
}

.toolbox-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

.chevron {
  font-size: 1rem;
}

.toolbox-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-muted);
  color: var(--text);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease,
    border 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border: none;
}

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

.btn.subtle {
  background: transparent;
  color: var(--muted);
}

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

.muted.small {
  font-size: 0.85rem;
}

.space-top {
  margin-top: 6px;
}

.code-block {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-muted) 80%, transparent);
  color: var(--text);
  font-family: var(--mono);
  resize: vertical;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-muted) 85%, transparent);
}

.history-main {
  display: grid;
  gap: 6px;
}

.history-title {
  font-weight: 700;
}

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

.history-actions {
  display: flex;
  gap: 8px;
}

.history-preview {
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 8px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

.span-two {
  grid-column: span 2;
}

.history-accordion {
  border: none;
  padding: 0;
}

.history-summary-toggle {
  list-style: none;
  cursor: pointer;
}

.history-summary-toggle::-webkit-details-marker {
  display: none;
}

.tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-bubble {
  pointer-events: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -6px) scale(0.98);
  background: var(--text);
  color: var(--bg);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-line;
  max-width: 320px;
  text-align: left;
  opacity: 0;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
  z-index: 10;
}

.tooltip-bubble.visible {
  opacity: 1;
  transform: translate(-50%, -10px) scale(1);
}

@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }

  .sidebar {
    flex: 1 1 auto;
    min-width: 0;
  }

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

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
  }

  .pill-action {
    width: 100%;
    justify-content: center;
  }

  .main-content {
    padding: 12px;
    gap: 14px;
  }

  .display-panel {
    min-height: auto;
  }

  .display-canvas {
    padding: 12px;
    min-height: clamp(300px, 70vh, 520px);
    height: auto;
  }

  .card-surface {
    padding: 14px;
  }

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

  .brand-text h1 {
    font-size: 1.05rem;
  }
}
