html {
  scrollbar-gutter: stable;
}

:root {
  color-scheme: light dark;
  --gap: 1.5rem;
  --rail-width: 160px;
  --bg: #ffffff;
  --fg: #111111;
  --warning: #b45309;
  --link: #1d4ed8;
  --link-visited: #6d28d9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8e8e8;
    --warning: #f0a949;
    --link: #7dc4ff;
    --link-visited: #c4a3ff;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --warning: #b45309;
  --link: #1d4ed8;
  --link-visited: #6d28d9;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --fg: #e8e8e8;
  --warning: #f0a949;
  --link: #7dc4ff;
  --link-visited: #c4a3ff;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
}

a {
  color: var(--link);
}

a:visited {
  color: var(--link-visited);
}

textarea,
select,
input {
  background: var(--bg);
  color: var(--fg);
  border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.theme-toggle,
.lang-toggle {
  position: fixed;
  top: 1rem;
  z-index: 10;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle {
  right: 1rem;
  width: 2.25rem;
}

.lang-toggle {
  right: 3.5rem;
  min-width: 2.25rem;
  padding: 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.page {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(500px, 1fr) var(--rail-width);
  gap: var(--gap);
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--gap);
}

.ad-rail {
  display: flex;
  justify-content: center;
}

.ad-slot {
  width: 160px;
  min-height: 600px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  border: 1px dashed color-mix(in srgb, currentColor 20%, transparent);
}

.ad-slot-below {
  min-height: 90px;
  width: 100%;
  margin: 2rem 0;
}

.tool {
  min-width: 0;
}

/* The guide page's .page grid has only one child (.guide-content), so CSS
   Grid auto-placement would otherwise drop it into the first track (the
   160px left ad-rail column) instead of the center content column. Span it
   across the full grid width. Scoped to .guide-page so the tool page's
   three-column ad-rail layout (index.html) is unaffected. */
.guide-page .guide-content {
  grid-column: 1 / -1;
}

.tagline {
  color: color-mix(in srgb, currentColor 70%, transparent);
}

.drop-zone {
  display: block;
  border: 2px dashed color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: currentColor;
}

.paste-area {
  margin-top: 1rem;
}

.paste-note {
  margin: 0.5rem 0;
  font-size: 0.875rem;
  color: color-mix(in srgb, currentColor 65%, transparent);
}

.paste-area textarea {
  width: 100%;
  font-family: ui-monospace, monospace;
}

.format-area {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 4%, transparent);
}

.format-controls {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.ambiguous-warning {
  color: var(--warning);
  font-weight: 600;
}

.preview-area {
  margin-top: 1.5rem;
}

.preview-table-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

#preview-table {
  border-collapse: collapse;
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

#preview-table td {
  border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
}

.why-blurb {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

@media (max-width: 1000px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
  }
  .ad-rail {
    display: none;
  }
}
