/* ------------------------------------------------------------------
   Design tokens
------------------------------------------------------------------ */
:root {
  --font-sans: "Inter", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "D2Coding", monospace;

  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-subtle: #eef0f3;
  --bg-hover: #e7eaef;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e6ec;
  --border-strong: #cbd2db;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --on-accent: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --brand: #f50c14;              /* the red of the NOW icon */
  --brand-soft: rgba(245, 12, 20, 0.12);
  --mark-bg: #dcfce7;
  --mark-text: #14532d;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 24px -8px rgba(15, 23, 42, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elev: #111827;
  --bg-subtle: #0f172a;
  --bg-hover: #1e293b;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  --border: #1f2937;
  --border-strong: #334155;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #1e3a8a;
  --on-accent: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px -8px rgba(0, 0, 0, 0.6);
  --brand: #ff3b42;              /* a touch lighter so it stays readable on dark */
  --brand-soft: rgba(255, 59, 66, 0.16);
  --mark-bg: #2f5233;
  --mark-text: #ecfdf5;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

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

/* ------------------------------------------------------------------
   Top bar
------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--bg-elev); /* fallback where color-mix() is unsupported */
  background: color-mix(in srgb, var(--bg-elev) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__logo { display: block; width: 28px; height: 28px; border-radius: 7px; flex: none; }
.topbar__tagline {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cheatsheet-btn { color: var(--text); }
.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.4;
}
a.lang-btn { display: inline-block; text-decoration: none; }
a.lang-btn:hover { text-decoration: none; color: var(--text); }
.lang-btn.is-active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------
   Workspace layout (fills the viewport below the top bar)
------------------------------------------------------------------ */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "actions actions"
    "editor  preview";
  gap: 12px 14px;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  padding-top: 12px;
  padding-bottom: 14px;
  max-width: none;
}
.pane--editor { grid-area: editor; }
.pane--preview { grid-area: preview; }
.actionbar { grid-area: actions; }

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.pane__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.pane__tools { display: flex; align-items: center; gap: 4px; padding-bottom: 6px; }
.pane__body { flex: 1; min-height: 0; position: relative; }
.pane__footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  min-height: 32px;
}
.stat { white-space: nowrap; }
.stat--right { margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs */
.tabs { display: flex; gap: 2px; }
.tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--bg-subtle); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; position: absolute; inset: 0; }
.tab-panel.is-active { display: block; }
.tab-panel[hidden] { display: none; }
.raw-html:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Editor */
.editor {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 16px 18px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow: auto;
}
.editor::placeholder { color: var(--text-faint); }
/* The textarea has no outline of its own, so show keyboard focus on the pane */
.pane:focus-within { border-color: var(--border-strong); }
.pane--editor:focus-within { border-color: var(--accent); }

/* Preview */
.preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.raw-html {
  margin: 0;
  height: 100%;
  overflow: auto;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  background: transparent !important;
}
.raw-html code { font-family: inherit; background: transparent !important; white-space: pre; }

.badge {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding-right: 6px;
}

/* ------------------------------------------------------------------
   Action bar
------------------------------------------------------------------ */
.actionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.actionbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.field { display: inline-flex; align-items: center; gap: 8px; }
.field__label { font-size: 13px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 34px 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 13.5px;
  font-weight: 500;
  min-width: 170px;
}
.select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-subtle); }
.btn:active { transform: translateY(1px); }
.btn .icon { flex: none; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn--ghost:hover { color: var(--text); background: var(--bg-subtle); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--accent { color: var(--accent); border-color: var(--accent); background: var(--bg-elev); }
.btn--accent { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.btn--accent:hover { background: var(--bg-subtle); }
.btn--accent:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.btn.is-success { background: var(--success); border-color: var(--success); color: #fff; }

/* Theme guide: one-line hint + "?" panel comparing the output themes */
.field__hint {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.theme-help { position: relative; flex: none; }
.icon-btn--help {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}
.icon-btn--help[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.theme-help__panel {
  position: absolute;
  left: -120px;
  top: calc(100% + 8px);
  z-index: 70;                       /* popovers sit above the story card (60), below the drawer (80/90) */
  width: min(480px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  overflow-y: auto;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  word-break: keep-all;
}
.theme-help__panel[hidden] { display: none; }
.theme-help__title { margin: 0 0 4px; font-size: 15px; }
.theme-help__intro { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.theme-help__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.theme-option {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-align: left;
}
.theme-option:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.theme-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-option[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-subtle); }
.theme-option__swatch {
  flex: none;
  width: 46px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-bottom: 3px solid;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
}
.theme-option__body { display: grid; gap: 2px; min-width: 0; }
.theme-option__name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.theme-option__badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.theme-option__badge.is-recommended { background: var(--mark-bg); color: var(--mark-text); }
.theme-option__badge.is-current { background: var(--accent); color: var(--on-accent); }
.theme-option__use { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.theme-help__note {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 70;                       /* same layer as the theme guide panel */
  min-width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
}
.dropdown__menu[hidden] { display: none; }
.dropdown__title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}
.dropdown__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
  line-height: 1.45;
}
.check:hover { background: var(--bg-subtle); }
.check input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }

/* ------------------------------------------------------------------
   Cheatsheet drawer
------------------------------------------------------------------ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.35);
  opacity: 0;
  transition: opacity .2s;
}
.drawer-backdrop[hidden] { display: none; }
.drawer-backdrop.is-visible { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(560px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px -16px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.drawer[hidden] { display: none; }
.drawer.is-open { transform: translateX(0); }
.drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.drawer__title { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.01em; }
.drawer__desc { margin: 0; font-size: 13px; }
.drawer__body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; }
.drawer__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  background: var(--bg-elev);
}

.cheatsheet__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.card p { margin: 0 0 10px; color: var(--text-muted); font-size: 14px; }
.card p:last-child, .card pre:last-child, .card ul:last-child { margin-bottom: 0; }
.card ul { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
.card li { margin: 3px 0; }
.card code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.card pre {
  margin: 0 0 10px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.6;
}
.card pre code { background: transparent; border: 0; padding: 0; }
.card table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.card th, .card td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.card th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }
.card tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------------
   Info section (below the editor; crawlable content for search engines)
------------------------------------------------------------------ */
.info {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  scroll-margin-top: var(--topbar-h);
  /* Below the fold: skip layout/paint until scrolled near. Text stays in the DOM for crawlers. */
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}
.info__inner { padding-top: 20px; padding-bottom: 24px; }
.info h2, .info h3, .info h4 { letter-spacing: -0.01em; line-height: 1.35; }
.info__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.info__title { margin: 0; font-size: 18px; }
.info__intro { margin: 0 0 14px; color: var(--text-muted); font-size: 13.5px; line-height: 1.6; }
.info__intro strong { color: var(--text); font-weight: 600; }
/* Column widths follow content length (Features is the longest list) so the
   three cards end up nearly the same height; stretch then aligns their bottoms. */
.info__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.6fr) minmax(0, 0.95fr);
  gap: 12px;
  align-items: stretch;
}
.info__card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}
.info__card h3 { margin: 0 0 6px; font-size: 14px; }
.info__card strong { font-weight: 600; }
.info__steps, .info__list { margin: 0; padding-left: 18px; }
.info__steps li + li, .info__list li + li { margin-top: 3px; }
.info__faq details { border-top: 1px solid var(--border); }
.info__faq details:first-child { border-top: 0; }
.info__faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  list-style: none;
}
.info__faq summary::-webkit-details-marker { display: none; }
.info__faq summary::after { content: "+"; color: var(--text-faint); font-weight: 600; flex: none; }
.info__faq details[open] summary::after { content: "−"; }
.info__faq summary:hover h4 { color: var(--accent); }
.info__faq summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.info__faq h4 { margin: 0; font-size: 13px; font-weight: 600; }
.info__faq p { margin: 0 0 8px; color: var(--text-muted); }
.info__faq code, .info__intro code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.noscript {
  margin: 16px auto;
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
}

/* ------------------------------------------------------------------
   "Why I made this" card: bottom center, rises 1 s after every load.
   Low and wide so it covers as little of the editor as possible.
------------------------------------------------------------------ */
.story {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;                       /* above the page, below popovers (70), the cheatsheet drawer (80/90) and toast (100) */
  width: min(660px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "heart title btn" "text text btn";
  column-gap: 9px;
  row-gap: 4px;
  align-items: center;
  padding: 10px 38px 10px 14px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  word-break: keep-all;              /* Korean: break between words, never inside one */
  overflow-wrap: anywhere;           /* ...but very long URLs/words can still wrap */
  transform: translate(-50%, 24px);
  opacity: 0;
  visibility: hidden;                /* hidden = also out of the Tab order */
  transition: transform .35s ease, opacity .35s ease, visibility 0s linear .35s;
}
.story.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition: transform .35s ease, opacity .35s ease, visibility 0s;
}
.story__heart {
  grid-area: heart;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  line-height: 26px;
  text-align: center;
}
.story__title { grid-area: title; margin: 0; font-size: 15.5px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.story__title .now { color: var(--brand); font-weight: 900; }
.story__text { grid-area: text; margin: 0; font-size: 14px; line-height: 1.5; }
.story__text mark { background: var(--mark-bg); color: var(--mark-text); padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.story__close {
  position: absolute;
  right: 6px;
  top: 7px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 19px;
  line-height: 26px;
  text-align: center;
}
.story__close:hover, .story__close:focus-visible { background: var(--bg-subtle); color: var(--text); outline: none; }

/* KakaoTalk-style share box on the right of the card */
.kakao {
  grid-area: btn;
  align-self: center;
  margin-left: 6px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: #fee500;               /* KakaoTalk brand yellow */
  color: #191919;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}
.kakao:hover { filter: brightness(0.95); }
.kakao:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kakao svg { width: 26px; height: 26px; }
.kakao span { display: inline-block; max-width: 6.5em; }  /* folds into two lines so the box hugs the text */
.kakao.is-done { background: var(--mark-bg); color: var(--mark-text); }

/* Keep the toast clear of the card while the card is up */
body.has-story .toast { bottom: 150px; }

@media (max-width: 520px) {
  .story {
    grid-template-columns: auto 1fr;
    grid-template-areas: "heart title" "text text" "btn btn";
    padding-right: 34px;
    bottom: 12px;
  }
  .kakao { flex-direction: row; margin: 6px 0 0; padding: 8px 12px; }
  .kakao svg { width: 18px; height: 18px; }
  .kakao span { max-width: none; }
  body.has-story .toast { bottom: 230px; }
}
@media (prefers-reduced-motion: reduce) { .story { transition: none; } }

/* ------------------------------------------------------------------
   Toast
------------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------
   Responsive
------------------------------------------------------------------ */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "actions"
      "editor"
      "preview";
    height: auto;
  }
  .pane { height: 70vh; min-height: 420px; }
  .topbar__tagline { display: none; }
  /* Tablet: How-to and FAQ stacked on the left, the long Features list on the right */
  .info__grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); grid-template-rows: auto 1fr; }
  .info__grid > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .info__grid > :nth-child(2) { grid-column: 2; grid-row: 1 / 3; }
  .info__grid > :nth-child(3) { grid-column: 1; grid-row: 2; }
}
/* Narrow tablets: the Features column wraps more, so give it a bit more room */
@media (max-width: 760px) {
  .info__grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
}
@media (max-width: 600px) {
  .cheatsheet-btn span { display: none; }
  .about-link { display: none; }
  .info__grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .info__grid > * { grid-column: auto !important; grid-row: auto !important; }
  .info__head { flex-wrap: wrap; }

  .actionbar { flex-direction: column; align-items: stretch; }
  .actionbar__group { justify-content: flex-start; }
  .field { width: 100%; flex: 1; }
  .actionbar__group:first-child { flex-wrap: wrap; }
  .field__hint { flex-basis: 100%; white-space: normal; }
  .theme-help__panel { position: fixed; left: 16px; right: 16px; top: auto; width: auto; margin-top: 8px; }
  .select { flex: 1; }
  .dropdown__menu { left: 0; right: auto; min-width: min(320px, calc(100vw - 32px)); }
  .stat--right { display: none; }
  /* Phones: keep the title visible. Tighter spacing makes room for it; on very
     narrow screens it shortens with "…" instead of pushing the buttons off. */
  .topbar__inner { gap: 8px; }
  .topbar__actions { gap: 2px; flex: none; }
  .brand { min-width: 0; gap: 6px; }
  .brand__text { font-size: 14px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lang-btn { padding: 4px 7px; }
  .icon-btn { width: 32px; height: 32px; }
  .cheatsheet-btn { padding: 6px; }
  .pane__header { flex-wrap: wrap; }
  .pane__tools { width: 100%; justify-content: flex-end; border-top: 1px solid var(--border); padding: 4px 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
