/* Design tokens -- THE single source for every colour in this project.
 * No call site below may use a raw hex; add a token here instead.
 *
 * Started as a verbatim copy of branding/tokens.css (blue accent family,
 * GATE M0), then went blue -> vermilion -> indigo (docs/DEVIATIONS.md has
 * the full record and the reasoning for each hop).
 *
 * The neutral ramp is a DELIBERATE deviation from branding/tokens.css,
 * which states neutrals are "brand-level, do not vary per project". The
 * shared warm ramp (--bg #fbfbf9, hue ~60) sits nearly opposite indigo
 * (hue ~250) on the wheel, and that opposition -- not indigo itself -- is
 * what made the accent read as "off". This ramp is a cool neutral with a
 * trace of the accent's own hue mixed in, so the accent sits on it
 * instead of fighting it. Confirmed with the owner before changing, and
 * scoped to paste only: branding/ and the other 13 projects keep the warm
 * ramp. paste's own favicon/OG scripts are updated to match (they bake
 * these values in and can't read CSS variables).
 *
 * Dark mode is still not implemented (deferred since v1.5); the dark
 * values from the migration spec are recorded in docs/DEVIATIONS.md so
 * turning it on later is a @media block, not a colour decision. */
:root {
  /* Corner radius, Fibonacci, same scale as spacing so that
     inner = outer - padding lands on another step.
     See branding/tokens.css. */
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius-md: 13px;
  --radius-lg: 21px;
  --radius-pill: 999px;
  --radius-circle: 50%;

  /* ---- Indigo ramp (accent family) ------------------------------------
     Slightly desaturated vs. stock Tailwind indigo -- still clearly
     indigo, less "framework default". */
  --indigo-50: #f4f4fd;
  --indigo-100: #e5e5fa;
  --indigo-200: #cfcff4;
  --indigo-300: #adacea;
  --indigo-400: #8583dc;
  --indigo-500: #6462ce;
  --indigo-600: #4f4cbe;
  --indigo-700: #413fa0;
  --indigo-800: #363481;
  --indigo-900: #2b2a63;

  /* ---- Neutral ramp (cool, trace of indigo hue) ---------------------- */
  --neutral-0: #ffffff;
  --neutral-25: #fafafb;
  --neutral-50: #f5f4f7;
  --neutral-100: #f2f1f5;
  --neutral-200: #eae9ef;
  --neutral-300: #dddce4;
  --neutral-400: #c4c2ce;
  /* Off-ramp value: the spec assigns neutral-400 to "border strong", but
     that is 1.76:1 on --surface -- under the 3:1 the same spec requires
     for borders/UI components. This step exists so the one border that
     genuinely needs to be seen can hit 3.08:1. Not a fifth text tier;
     the four-tier text rule is untouched. */
  --neutral-450: #94919f;
  --neutral-500: #a9a7b3;
  --neutral-600: #6e6c7a;
  --neutral-700: #55535f;
  --neutral-900: #1c1b22;

  /* ---- Surfaces ------------------------------------------------------ */
  --bg: var(--neutral-25);
  --surface: var(--neutral-0);
  /* Neutral fill for pills/panels that are NOT in an accent state --
     replaces four separate hardcoded #f0efeb call sites. */
  --surface-sunken: var(--neutral-50);
  --border: var(--neutral-200);
  /* Stronger than --border on purpose -- reserved for the two boxes that
     hold the note's actual content (the create textarea, the view page's
     content box), which read as barely-there at the ambient --border
     weight (reported). Every other border keeps the subtler --border.
     3.08:1 on --surface, clearing the 3:1 non-text-contrast bar these two
     need as the visible boundary of the primary input. */
  --border-strong: var(--neutral-450);

  /* ---- Text: exactly four tiers, do not add a fifth -------------------
     A fifth grey is almost always a size/spacing problem wearing a colour
     costume. Contrast on --bg is measured in docs/DEVIATIONS.md.
       primary   body text, note content, headings
       secondary labels, helper sentences, default nav/button text
       tertiary  metadata, timestamps, line numbers, placeholders, icons
                 -- short labels only, never a full sentence
       disabled  inert controls; deliberately below AA */
  --text: var(--neutral-900);
  --text-secondary: var(--neutral-700);
  --text-tertiary: var(--neutral-600);
  /* Brand mark only -- deliberately NOT part of the text ramp, so retuning a
     text tier never silently redraws the logo. Same value on every d4t0 site
     (branding/tokens.css --logo-color). */
  --logo-color: #293133;
  --text-disabled: var(--neutral-500);
  --on-accent: var(--neutral-0);
  /* Legacy alias -- every call site has been re-pointed at the tier it
     actually wanted; kept only so a stray/future reference still resolves
     to something sane rather than breaking. Prefer the named tiers. */
  --text-muted: var(--text-tertiary);

  /* ---- Accent roles --------------------------------------------------
     --accent-surface marks a genuinely active/selected thing (current nav
     item, a "copied" confirmation). --neutral-hover is for hovering
     something that is NOT selected, so hover never impersonates "chosen"
     -- if every button turned indigo on hover, indigo would stop meaning
     anything. */
  --accent: var(--indigo-600);
  --accent-strong: var(--indigo-700);
  --accent-pressed: var(--indigo-800);
  --accent-hover-fill: var(--indigo-500);
  --accent-surface: var(--indigo-100);
  --accent-surface-hover: #dcdcf7;
  --accent-border: var(--indigo-200);
  --accent-underline: var(--indigo-300);
  --neutral-hover: var(--neutral-100);

  --focus-ring: var(--indigo-600);
  --selection-bg: var(--indigo-100);
  --selection-text: var(--neutral-900);

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  /* Scrim over the page behind a modal / over an image thumbnail. */
  --scrim: rgba(28, 27, 34, 0.4);
  --scrim-strong: rgba(28, 27, 34, 0.6);


  --sp-1: 8px;
  --sp-2: 13px;
  --sp-3: 21px;
  --sp-4: 34px;
  --sp-5: 55px;
  --sp-6: 89px;

  /* ---- Semantic -------------------------------------------------------
     Each is a hue the accent does not occupy, so "error"/"success"/
     "warning" never read as "selected". There is deliberately NO separate
     blue "info" colour: a blue info state would collide with indigo and
     blur "here is information" into "this is active" -- info reuses the
     accent itself. */
  --danger: #c0392b;
  --danger-surface: #fdf1ef;
  --ok: #17794a;
  --ok-surface: #ecf7f0;
  --warning: #9a5b0b;
  --warning-surface: #fdf4e7;

  --dur: 180ms;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  /* Native controls (checkbox/radio/range, and the OS focus tint on some
     platforms) follow the accent instead of the browser default blue. */
  accent-color: var(--accent);
  /* No dark theme is implemented yet, so tell the UA not to auto-invert
     native widgets against this light palette. */
  color-scheme: light;
}

@media (min-width: 640px) {
  html, body {
    font-size: 17px;
  }
}


.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

/* Base <a> stays inherit-coloured and undecorated: almost every link in
   this app is navigation/button-like (topbar, nav panel, action pills),
   which per the link spec must NOT be underlined or accent-coloured by
   default. Prose links opt IN via .prose-link (or by living inside
   .page-sub, the only prose block that currently contains links). */
a {
  color: inherit;
}

/* Prose links (link type A): underline is mandatory, not decorative.
   Inside a block of text, colour alone as the only link signal fails
   WCAG 1.4.1 -- a colour-blind reader gets no cue at all. Before this,
   the two real prose links in the app ("Đăng ký" / "Đăng nhập" on the
   login/register pages) rendered identically to the surrounding
   sentence. */
.page-sub a,
.prose-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--dur) var(--ease), text-decoration-color var(--dur) var(--ease);
}

.page-sub a:hover,
.prose-link:hover {
  color: var(--accent-strong);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

.page-sub a:active,
.prose-link:active {
  color: var(--accent-pressed);
}

/* The focus ring is the affordance here; the browser's own underline on
   top of ours would double up. */
.page-sub a:focus-visible,
.prose-link:focus-visible {
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ============================================================== shell */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============================================================== topbar */

.topbar {
  /* No max-width here -- it comes from the same .col-narrow/.col-normal/
     .col-wide class as <main> and <footer> (shell() passes all three the
     same colClass), so the logo, the input/button column, and the footer
     text always share one left/right edge instead of each picking its own
     width. */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

.topbar--minimal {
  /* Logo stays left, the optional back-link (topbar-link) sits at the
     opposite edge instead of crowding right next to the logo. */
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}

.topbar-logo {
  display: block;
  /* 36×36 — repo-wide since 22/08/2026 (branding/chrome.css). */
  width: 36px;
  height: 36px;
  /* --logo-color, not a text tier (repo-wide decision, 2026-08-22). The old
     note here said full near-black read too heavy for a corner mark -- still
     true, and that is what the token already is: #293133 is a lifted
     near-black, not #000. */
  background-color: var(--logo-color);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("/logo.svg");
  /* No rotate() here: logo.svg is generated pre-rotated by
     branding/build-icons.py (LOGO_ROTATE = 45). Rotating again gives 90° --
     the exact bug five other sites hit on 2026-08-21. */
  mask-image: url("/logo.svg");
}

.topbar-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

/* Nav link (link type B) hover: goes to the neutral fill + primary text,
   never to the accent -- the accent is reserved for "this one is
   selected", and if every nav item turned indigo on hover it would stop
   carrying that meaning. */
.topbar-link:hover {
  color: var(--text);
  background: var(--neutral-hover);
}

.topbar-icon-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 40px;
  padding: 4px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-icon-btn:hover {
  /* --neutral-hover, not an accent surface -- Link/Raw/Sao chép have no
     "selected" state, they're one-off actions, so hover shouldn't read as
     "now chosen" (accent migration role split, docs/DEVIATIONS.md). */
  background: var(--neutral-hover);
  color: var(--text);
}

/* Short caption under each icon (requested) -- readable without widening
   the row into the text-pill row this replaced. */
.topbar-icon-caption {
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

/* copy-link/copy-text only: default icon fades into a checkmark on click
   (view.js toggles .copied), same stacked-icon technique as .link-copy-icon
   below -- the button itself is the feedback, not just a toast elsewhere. */
.btn-ico-wrap {
  position: relative;
  width: 18px;
  height: 18px;
}

.btn-ico-wrap svg {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn-ico-wrap .btn-ico-done {
  opacity: 0;
  color: var(--ok);
  transform: scale(0.6);
}

.topbar-icon-btn.copied .btn-ico-default {
  opacity: 0;
}

.topbar-icon-btn.copied .btn-ico-done {
  opacity: 1;
  transform: scale(1);
}

/* --- hamburger: 2 bars morphing into an X, Apple.com style. Shown below
   720px only; above it the panel becomes a plain link row (see the media
   query after .menu-panel-divider). No border and no fill, which is now the
   repo-wide rule -- branding/chrome.css. ---- */

.menu-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.menu-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  /* Centred with margin, not translate(-50%,-50%) -- combined with the open
     state's rotate() that produces a lopsided chevron, not an X. */
  margin: -0.75px 0 0 -8px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.menu-bar--top {
  transform: translateY(-3px);
}

.menu-bar--bottom {
  transform: translateY(3px);
}

.menu-btn[aria-expanded="true"] .menu-bar--top {
  transform: rotate(45deg);
}

.menu-btn[aria-expanded="true"] .menu-bar--bottom {
  transform: rotate(-45deg);
}

.menu-panel {
  position: absolute;
  top: 56px;
  right: 20px;
  z-index: 50;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--radius-md);
  /* No border (GATE M0, explicit request) -- shadow alone separates the
     panel from the page, matching the plan's own "no border except focus
     state" principle (§9.2.1). Differs from vote/public/style.css, which
     still has `border: 1px solid var(--line)` here. */
  box-shadow: var(--shadow);
}

.menu-panel[hidden] {
  display: none;
}

.menu-panel-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.menu-panel-item:hover {
  /* Not-yet-selected hover -- neutral, not accent (see .topbar-icon-btn). */
  background: var(--neutral-hover);
}

.menu-panel-item.active {
  /* Genuinely active/selected (the current page) -- accent-surface. */
  background: var(--accent-surface);
  color: var(--accent);
}

.menu-panel-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* Desktop: no hamburger, links laid out in a row (branding/chrome.css, 720px).
   CSS only -- the button and panel keep their ids, so menu.js is untouched and
   still drives the dropdown below the breakpoint.

   Both `.menu-panel` and `.menu-panel[hidden]` have to be overridden: [hidden]
   is a UA default that a bare class rule loses to, and the failure mode is a
   nav that looks empty rather than an error. */
@media (min-width: 720px) {
  .menu-btn {
    display: none;
  }

  .menu-panel,
  .menu-panel[hidden] {
    display: flex;
  }

  .menu-panel {
    position: static;
    flex-direction: row;
    align-items: center;
    min-width: 0;
    padding: 0;
    background: none;
    box-shadow: none;
  }

  .menu-panel-item {
    width: auto;
    padding: 8px 10px;
    white-space: nowrap;
  }

  .menu-panel-divider {
    width: 1px;
    height: 14px;
    margin: 0 4px;
  }
}

/* ================================================================ main */

main {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-4) 20px var(--sp-6);
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

.col-narrow { max-width: 440px; }
.col-normal { max-width: 560px; }
.col-wide { max-width: 720px; }

/* ============================================================== footer */

.footer {
  /* max-width comes from .col-narrow/.col-normal/.col-wide, same as
     .topbar/main -- see the comment on .topbar. Centred: this used to be
     paste's own sanctioned exception to a repo-wide left-aligned rule, and on
     22/08/2026 the owner made paste's version the rule for every project.
     See branding/chrome.css. */
  margin: auto auto 0;
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: 20px 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.footer p {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  /* --text-muted, not --text -- bold near-black read as too prominent
     next to the footer's own muted copyright line (reported). */
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.btn-ico {
  width: 14px;
  height: 14px;
}

/* ============================================================= buttons */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.btn-primary.btn-inline {
  width: auto;
}

.btn-link {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: var(--sp-2);
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* 38px, not the usual 44px touch target -- these sit in a row of 2-3
     alongside each other (created-actions, the images-panel "Thêm ảnh"),
     where a slimmer pill reads as a toolbar instead of a stack of primary
     buttons. Still comfortably tappable, just not full-size. */
  min-height: 38px;
  padding: 7px 14px;
  /* A real background fill (not --surface, which sits only ~1-3 RGB units
     from --bg) instead of a border -- same reasoning as .editor-more-inner:
     a border-based boundary reads as thin/fussy at this size, a filled
     pill reads as a button on sight. */
  border: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

/* .pill-btn's own --surface-sunken fill is the same tone as
   .editor-more-inner's section background -- the one pill-btn that lives
   inside that section ("Thêm ảnh") would otherwise vanish into it. Flip
   to the lighter --bg instead, matching how .opt-input/.pick already read
   as lighter inset controls against the same darker section. */
.editor-more-inner .pill-btn {
  background: var(--bg);
}

.pill-btn:hover {
  /* Not-yet-selected hover -- neutral, not accent (see .topbar-icon-btn). */
  background: var(--neutral-hover);
}

.pill-btn:active {
  transform: scale(0.98);
}

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

.pill-btn--danger {
  color: var(--danger);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-circle);
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- switch (on/off toggle) -------------------------------------------- */

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur) var(--ease);
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-circle);
  background: var(--neutral-0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur) var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::before {
  transform: translateX(18px);
}

/* =============================================================== editor */

.editor-sheet {
  background: var(--surface);
  /* --surface sits only a hair above --bg -- too close to read as a
     distinct card on its own, so the main input gets a border.
     --border-strong, not the ambient --border every other field uses
     (.opt-input, .field input) -- this is the main input, requested to
     stand out more clearly. */
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-1);
  margin-bottom: var(--sp-2);
}

.editor-sheet:focus-within {
  border-color: var(--accent);
}

.editor-textarea {
  display: block;
  width: 100%;
  /* aspect-ratio (not a height/40vh) sets the default first-load size --
     16:9, adjusted from an initial 1:1 after seeing 1:1 render too tall on
     a wide viewport -- while still just being a starting point: the resize
     handle sets an explicit height once dragged, same as before. min-height
     is the resize floor, kept low so dragging can shrink this a lot
     further than a fixed height would allow. */
  aspect-ratio: 16 / 9;
  min-height: 120px;
  border: none;
  background: transparent;
  resize: vertical;
  font: inherit;
  color: var(--text);
  outline: none;
}

/* .mono's font-family alone loses to .editor-textarea's `font: inherit`
   shorthand above -- same specificity (one class each), and
   .editor-textarea comes later in this file, so it wins the cascade and
   the "Hiển thị dạng code" switch silently did nothing visually (reported,
   real bug: affects both the create page's live preview and the edit
   page). Two classes here beats one, regardless of source order. */
.editor-textarea.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Native resize grip. ::-webkit-resizer is Chrome/Safari-only; Firefox
   ignores this rule entirely and keeps drawing its own default grip, which
   is fine -- dragging still works everywhere, only the glyph differs.

   Drawn with background-image, NOT background-color + mask-image: Chrome
   ignores every mask-* property on this pseudo-element, so the mask never
   clips anything and all that survives is the flat fill -- i.e. a solid
   14x14 grey square sitting in the corner of the input. That is exactly
   what this rule used to ship, and what the owner saw on a real machine.
   Verified with a 4-textarea control test in one frame: unstyled -> normal
   glyph, background-color+mask -> solid square, background-image (same SVG)
   -> correct glyph, transparent -> empty. Only the mask variant is broken.

   Consequence: the grip colour has to be hardcoded inside the SVG data URI
   (#a29fae) because a data: URL cannot read CSS custom properties. It is
   deliberately lighter than --text-tertiary so the grip doesn't compete
   with the note content for attention.

   Gotcha when testing: the resizer does not repaint on a runtime CSS
   change. Toggle the textarea's resize value (set `none`, then back to
   `vertical`) to force a redraw, or a DevTools edit will look like it did
   nothing. */
.editor-textarea::-webkit-resizer {
  width: 14px;
  height: 14px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a29fae'%3E%3Ccircle cx='19' cy='19' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3Ccircle cx='12' cy='19' r='2'/%3E%3Ccircle cx='19' cy='5' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='5' cy='19' r='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1px bottom 1px;
  background-size: 13px;
}

.editor-textarea::placeholder {
  color: var(--text-tertiary);
}

.editor-textarea:focus-visible {
  /* The parent .editor-sheet already shows focus via border-color
     (:focus-within) -- a second ring directly on the textarea would double
     up the emphasis. */
  outline: none;
}

.editor-more {
  margin-bottom: var(--sp-2);
}

.editor-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.editor-more-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--dur) var(--ease);
}

.editor-more-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.editor-more-panel {
  /* margin-top matches .editor-sheet's and .editor-more-inner's own
     margin-bottom -- lives here (not on .editor-more-btn) so it only
     exists while the panel is actually open. On [hidden] this rule still
     applies, but display:none means it takes up no space either way --
     the collapsed state stays exactly as tight as it was.
     margin-bottom is deliberately larger (--sp-4, not --sp-2) -- requested,
     so the gap below the whole options section to the Tạo button reads as
     a group boundary, not just another row gap. */
  margin-top: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.editor-more-panel[hidden] {
  display: none;
}

.editor-more-inner {
  /* A visibly darker fill (not --surface, which sits only ~1-3 RGB units
     from --bg) reads as its own section on sight, the way vote/public/
     create.css's --fill does for the same "options card" role -- so the
     border that used to be the only thing separating this box from the
     page can go. The inner controls (.opt-input/.pick/.pill-btn) keep
     their own lighter --bg/--surface fills, which now reads as an
     intentional "inset control on a darker panel" hierarchy instead of
     competing flat blocks. */
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}

/* No divider line between rows -- with the card's own border, the control
   borders (select/input/button), AND a rule between every row, the panel
   read as boxes-inside-boxes-inside-boxes. The icon + label + sub-label
   block already separates one row from the next; padding alone carries
   that the rest of the way. (This also sidesteps the border-bottom-except-
   last-child bug the old rule had: "Ảnh" is followed by .image-thumbs, a
   sibling div present even when empty, so it was never truly :last-child.) */
.opt-row + .opt-row {
  margin-top: var(--sp-1);
}

/* Icon + label(+sub) as one block, matching vote/public/create.css's
   .vc-opt-main -- keeps each row at exactly two flex items so the mobile
   stack (below) only has the control to push onto its own line. */
.opt-main {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.opt-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.opt-label {
  font-size: 14px;
  font-weight: 500;
}

.opt-sub {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

.opt-input {
  min-height: 36px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  width: 160px;
  max-width: 50%;
}

.pick-wrap {
  position: relative;
}

.pick {
  appearance: none;
  -webkit-appearance: none;
  min-height: 36px;
  padding: 6px 30px 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.image-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
}

/* Replaces the old "Ảnh · Tối đa 3 ảnh" options-panel row (removed --
   paste is now the only way to add an image, so a static row explaining a
   button that no longer exists made no sense) with a live count, since
   there's otherwise no visible cue that pasting an image even works. */
.image-count-hint {
  margin: 0 0 var(--sp-2);
  font-size: 12px;
  color: var(--text-tertiary);
}

.image-thumbs:empty {
  display: none;
}

.image-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-circle);
  background: var(--scrim-strong);
  color: var(--neutral-0);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.image-thumb-remove svg {
  width: 12px;
  height: 12px;
}

.note-images {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.note-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: var(--sp-1) 0 0;
}

.form-error[hidden] {
  display: none;
}

/* --- created overlay ---------------------------------------------------- */

.created-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim);
  padding: 0;
}

@media (min-width: 640px) {
  .created-overlay {
    align-items: center;
  }
}

.created-overlay[hidden] {
  display: none;
}

.created-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-4) var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom));
  text-align: center;
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .created-card {
    border-radius: var(--radius-lg);
  }
}

.created-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-circle);
  color: var(--text-tertiary);
}

.created-close svg {
  width: 18px;
  height: 18px;
}

/* "Tạo ghi chú khác" moved from a text link at the bottom to an icon
   button mirroring .created-close's position/size on the opposite
   corner (requested) -- same #created-again id, so editor.js's click
   handler needs no change. */
.created-again {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-circle);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.created-again svg {
  width: 18px;
  height: 18px;
}

.created-check {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-2);
  border-radius: var(--radius-circle);
  background: var(--accent-surface);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.created-check svg {
  width: 28px;
  height: 28px;
}

.created-sub {
  color: var(--text-secondary);
  margin: 0 0 var(--sp-3);
}

.link-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.link-copy.copied {
  background: var(--accent-surface);
  border-color: var(--accent-border);
}

.link-copy-url {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-copy-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: relative;
}

.ico-copy, .ico-done {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.ico-done {
  opacity: 0;
  color: var(--ok);
  transform: scale(0.6);
}

.link-copy.copied .ico-copy {
  opacity: 0;
}

.link-copy.copied .ico-done {
  opacity: 1;
  transform: scale(1);
}

.link-copy-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 6px 0 var(--sp-3);
}

.created-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: var(--sp-2);
}

/* Pill-shaped (requested), distinct colors so Share (primary) and View
   note (secondary) don't read as the same weight of action. */
.action-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.action-pill:active {
  transform: scale(0.98);
}

.action-pill-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.action-pill--accent {
  background: var(--accent);
  color: var(--on-accent);
}

.action-pill--neutral {
  background: var(--surface-sunken);
  color: var(--text);
}

.edit-code-block {
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--warning-surface);
  text-align: left;
}

.edit-code-block[hidden] {
  display: none;
}

.edit-code-title {
  margin: 0 0 var(--sp-1);
  font-size: 13px;
  font-weight: 600;
}

.edit-code-warning {
  margin: var(--sp-1) 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ================================================================= view */

.note-meta-row {
  /* Back above the content box (moved below, then back above, requested
     both times), now as a small pill instead of bare text. Space-between
     flex row (requested, shown as an arrow on a screenshot) so
     .note-actions (Link/Raw/Sao chép, moved out of the topbar) lands at
     the box's top-right corner, opposite the view-count pill. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Slim, dark-filled chip -- matches vote/public/style.css's .status-pill
   (requested, shown as a reference screenshot), not the light-outlined
   style used elsewhere in this file. No icon (requested) -- text only. */
.note-meta {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.note-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
  /* Boxed by default now (used to be plain-format-only, unboxed text) --
     every note format shares the same contained look, matching the
     editor's own .editor-sheet. */
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
}

/* Line numbers by default (requested) -- native <ol> numbering as the
   gutter rather than a CSS counter hack, so wrapped lines still line up
   correctly under list-style-position: outside. */
.note-lines {
  margin: 0;
  list-style: decimal;
  list-style-position: outside;
  white-space: pre-wrap;
}

.note-content.note-lines {
  padding-left: 3em;
}

.note-lines li {
  padding-left: 0.5em;
}

.note-lines li::marker {
  color: var(--text-tertiary);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}

.note-content--mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
}


/* --- locked / burn cards ------------------------------------------------ */

.locked-card, .burn-card {
  text-align: center;
  padding-top: var(--sp-4);
}

.locked-icon, .burn-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--sp-2);
  color: var(--text-tertiary);
}

.locked-icon svg, .burn-icon svg {
  width: 100%;
  height: 100%;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
}

@media (min-width: 640px) {
  .page-title { font-size: 28px; }
}

.page-sub {
  color: var(--text-secondary);
  margin: 0 0 var(--sp-3);
}

.field {
  display: block;
  text-align: left;
  margin-bottom: var(--sp-2);
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.field input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.shake {
  animation: shake var(--dur) var(--ease);
}

.edit-form-actions {
  margin-top: var(--sp-2);
}

/* Same pill shape as .pill-btn (var(--radius-pill)), kept on .btn-primary
   instead so "Lưu" stays full-width/48px/accent-filled -- requested to read
   as the same button language as "Xoá ghi chú" below it. */
.btn-primary--pill {
  border-radius: var(--radius-pill);
}

/* "Xoá ghi chú" used to sit right next to "Lưu" in the same row -- a
   mis-tap while reaching for Lưu could land on delete instead (reported).
   Moved to its own row below the error message, with a wide gap
   (--sp-5) and full pill width so it still reads as a real button, not a
   throwaway link, while being nowhere near the save button's tap area. */
.pill-btn--wide {
  display: flex;
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

.edit-delete-btn {
  margin-top: var(--sp-5);
}

.edit-form[hidden], .edit-gate[hidden] {
  display: none;
}

/* ==================================================================== me */

.me-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.me-head .page-title {
  margin: 0;
}

.me-head .btn-link {
  width: auto;
  margin: 0;
}

.me-list {
  list-style: none;
  margin: var(--sp-3) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.me-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: var(--sp-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.me-row-id {
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.me-row-meta {
  color: var(--text-tertiary);
  font-size: 12px;
  flex: 1;
}

/* ================================================================= toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
}

/* iOS Safari auto-zooms the whole page on focus for any input/select/
   textarea rendering under 16px, and never zooms back out on blur -- every
   control needs to clear that floor on a touch device (not on desktop,
   where 14px reads better in the compact options rows). Same gotcha noted
   in vote/DECISIONS.md #17. Placed at the end of the file deliberately:
   this has to out-rank .opt-input/.pick/.field input by source order,
   since it matches with the same specificity (one class) and an earlier
   position lost the cascade tie silently -- caught by computed-style
   inspection during iPhone 14 Pro testing, not by eye. */
@media (pointer: coarse) {
  .opt-input,
  .pick,
  .field input,
  .editor-textarea,
  #editcode-input,
  #edit-content {
    font-size: 16px;
  }
}

/* Below 640px, .opt-row's label+control no longer fit on one line without
   squeezing the control into a narrow, truncating box (the password
   placeholder used to clip to "Để trống nếu không c..."). Stack them and
   let the control take the row's full width instead -- same fix as
   vote/public/create.css's .vc-opt-row at its own narrow breakpoint. The
   burn-after-read and images rows are the exception: a 42px switch or a
   short "Thêm ảnh" button don't need a line of their own, and dropping
   them below the label just adds height for no legibility gain. */
@media (max-width: 639px) {
  .opt-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
  }

  .opt-row:has(.switch),
  .opt-row:has(.pill-btn) {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .opt-row .pick-wrap,
  .opt-row .opt-input {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
  }
}
