/* ==========================================================================
   Readability Studio: styles
   1. Design tokens (light + dark)
   2. Base
   3. Layout
   4. Header & footer
   5. Buttons & controls
   6. Editor + highlight layer
   7. Sidebar cards
   8. Toast, utilities, reduced motion
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------- */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --header-h: 68px;

  color-scheme: light;
  --bg: #f6f5f1;
  --bg-glow: rgba(79, 70, 229, .08);
  --header-bg: rgba(246, 245, 241, .82);
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --border: #e8e5de;
  --border-strong: #d6d2c8;
  --text: #1c1b19;
  --text-muted: #67645c;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-contrast: #ffffff;
  --accent-soft: #eef0ff;
  --ring: rgba(79, 70, 229, .22);
  --shadow-sm: 0 1px 2px rgba(28, 25, 18, .05);
  --shadow: 0 1px 2px rgba(28, 25, 18, .04), 0 12px 32px -14px rgba(28, 25, 18, .14);
  --switch-off: #d6d3cb;
  --toast-bg: #1c1b19;
  --toast-text: #f6f5f1;

  /* Highlight colors: solid pastels so overlapping marks never blend into mud. */
  --hl-hard: #fcefb4;          --hl-hard-strong: #d4a20b;
  --hl-very-hard: #fad2d6;     --hl-very-hard-strong: #e5484d;
  --hl-passive: #d2f0db;       --hl-passive-strong: #2f9e5f;
  --hl-adverb: #d9e6fd;        --hl-adverb-strong: #3b7be8;
  --hl-complex: #ebdcfb;       --hl-complex-strong: #8e4ec6;
  --hl-repeated: #fde3cb;      --hl-repeated-strong: #ec7a2c;

  /* Score grades */
  --easy: #15803d;        --easy-soft: #dcfce7;
  --standard: #a16207;    --standard-soft: #fef3c7;
  --difficult: #c62a2f;   --difficult-soft: #fee2e2;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114;
  --bg-glow: rgba(139, 135, 255, .10);
  --header-bg: rgba(17, 17, 20, .78);
  --surface: #19191e;
  --surface-2: #202026;
  --border: #2b2b33;
  --border-strong: #3a3a44;
  --text: #ececf1;
  --text-muted: #a1a1ad;
  --accent: #8b87ff;
  --accent-hover: #a29fff;
  --accent-contrast: #12112a;
  --accent-soft: rgba(139, 135, 255, .14);
  --ring: rgba(139, 135, 255, .28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 36px -16px rgba(0, 0, 0, .6);
  --switch-off: #3a3a44;
  --toast-bg: #ececf1;
  --toast-text: #111114;

  --hl-hard: #4a4120;          --hl-hard-strong: #e9c046;
  --hl-very-hard: #532a33;     --hl-very-hard-strong: #ff6b70;
  --hl-passive: #1f4430;       --hl-passive-strong: #4cc38a;
  --hl-adverb: #22395a;        --hl-adverb-strong: #6ea3ff;
  --hl-complex: #3d2c5c;       --hl-complex-strong: #b98cf0;
  --hl-repeated: #50341f;      --hl-repeated-strong: #f59e58;

  --easy: #4ade80;        --easy-soft: rgba(74, 222, 128, .14);
  --standard: #fbbf24;    --standard-soft: rgba(251, 191, 36, .14);
  --difficult: #f87171;   --difficult-soft: rgba(248, 113, 113, .14);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(1100px 520px at 12% -12%, var(--bg-glow), transparent 65%),
                    radial-gradient(900px 480px at 100% 0%, var(--bg-glow), transparent 60%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

h1, h2, p { margin: 0; }
a { color: var(--accent); }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--ring); }

/* 3. Layout ---------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding-block: 20px 48px;
}

@media (min-width: 640px) {
  .container { padding-inline: 24px; }
  .layout { gap: 24px; padding-block: 28px 56px; }
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }
}

/* 4. Header & footer ------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { flex-shrink: 0; border-radius: 9px; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55); }

.brand-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.brand-tag { font-size: .8125rem; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.site-footer { border-top: 1px solid var(--border); }

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 20px;
  font-size: .8125rem;
  color: var(--text-muted);
}

.footer-inner a { color: inherit; font-weight: 500; text-underline-offset: 3px; }
.footer-inner a:hover { color: var(--accent); }

@media (max-width: 479px) {
  .brand-tag { display: none; }
}

/* 5. Buttons & controls ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 .875rem/1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color .2s var(--ease), border-color .2s var(--ease),
              color .2s var(--ease), transform .15s var(--ease), opacity .2s;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--text); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Show the moon in light mode (go dark) and the sun in dark mode (go light). */
[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun { display: none; }

/* Toggle switch built on a native checkbox, so keyboard and screen readers work out of the box. */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color .2s var(--ease);
}

.switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s var(--ease);
}

.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(16px); }
.switch:focus-visible { outline-offset: 3px; border-radius: 999px; }

/* 6. Editor ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: background-color .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}

.editor-card { overflow: hidden; }
.editor-card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring), var(--shadow); }

.editor-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

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

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--switch-off);
  transition: background-color .2s;
}

.status[data-state="ready"] .status-dot { background: var(--easy); }
.status[data-state="analyzing"] .status-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .3; } }

/*
  THE KEY TRICK: the backdrop and the textarea share every property that affects
  where text lands (font, size, line height, padding, wrapping). If any of these
  differ, the highlights drift away from the words.
*/
.editor {
  position: relative;
  --pad-y: 28px;
  --pad-x: 32px;
}

.editor-layer {
  width: 100%;
  margin: 0;
  border: 0;
  padding: var(--pad-y) var(--pad-x);
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: normal;
  word-spacing: normal;
  tab-size: 4;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
  user-select: none;
  transition: opacity .15s var(--ease);
}

/* While you type, highlights fade a little until the debounced analysis catches up. */
.editor.is-stale .editor-backdrop { opacity: .4; }

.editor-input {
  position: relative; /* paints above the backdrop */
  display: block;
  min-height: 58vh;
  resize: none;
  overflow: hidden;   /* the textarea auto-grows, so it never needs its own scrollbar */
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  outline: none;
}

.editor-input::placeholder { color: var(--text-muted); opacity: .75; }

@media (max-width: 639px) {
  .editor { --pad-y: 20px; --pad-x: 18px; }
  .editor-layer { font-size: 1.0625rem; } /* stays above 16px so iOS doesn't zoom on focus */
  .editor-input { min-height: 50vh; }
  .editor-card-header { padding: 12px 14px; }
  .toolbar { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .btn { justify-content: center; }
  .toolbar .btn-primary { grid-column: 1 / -1; }
}

/* Highlight marks. No padding or borders, since those would shift text; only backgrounds and inset shadows. */
.hl {
  color: transparent;
  background-color: transparent;
  margin: 0;
  padding: 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease);
}

.hl-hard      { background-color: var(--hl-hard); }
.hl-very-hard { background-color: var(--hl-very-hard); }
.hl-passive   { background-color: var(--hl-passive); border-radius: 4px; }
.hl-adverb    { background-color: var(--hl-adverb); border-radius: 4px; }
.hl-complex   { background-color: var(--hl-complex); border-radius: 4px; }
.hl-repeated  {
  background-color: var(--hl-repeated);
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 var(--hl-repeated-strong);
}

/* Toggles add .hide-<type> to the editor, so no re-analysis is needed. */
.editor.hide-hard .hl-hard,
.editor.hide-very-hard .hl-very-hard,
.editor.hide-passive .hl-passive,
.editor.hide-adverb .hl-adverb,
.editor.hide-complex .hl-complex,
.editor.hide-repeated .hl-repeated {
  background-color: transparent;
  box-shadow: none;
}

.editor-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: .8125rem;
  color: var(--text-muted);
}

.editor-hint svg { width: 14px; height: 14px; flex-shrink: 0; }

/* 7. Sidebar --------------------------------------------------------------- */
.sidebar { display: grid; gap: 16px; align-content: start; }

@media (min-width: 640px) and (max-width: 959px) {
  .sidebar { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 960px) {
  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + 20px);
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow-y: auto;
    padding: 4px;      /* room for card shadows inside the scroll area */
    margin: -4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
}

.sidebar .card { padding: 18px 20px 20px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-sub { font-size: .75rem; color: var(--text-muted); }

.card-note { margin: -4px 0 12px; font-size: .875rem; color: var(--text-muted); }

/* Score dial */
.score-card { --grade-color: var(--switch-off); --grade-soft: var(--surface-2); }
.score-card[data-grade="easy"]      { --grade-color: var(--easy);      --grade-soft: var(--easy-soft); }
.score-card[data-grade="standard"]  { --grade-color: var(--standard);  --grade-soft: var(--standard-soft); }
.score-card[data-grade="difficult"] { --grade-color: var(--difficult); --grade-soft: var(--difficult-soft); }

.score-body { display: flex; align-items: center; gap: 18px; }

.dial { position: relative; flex-shrink: 0; width: 124px; height: 124px; }

.dial-svg { width: 100%; height: 100%; transform: rotate(-90deg); /* start the arc at 12 o'clock */ }

.dial-track,
.dial-progress { fill: none; stroke-width: 10; }

.dial-track { stroke: var(--surface-2); }
[data-theme="light"] .dial-track { stroke: #efede8; }

.dial-progress {
  stroke: var(--grade-color);
  stroke-linecap: round;
  /* stroke-dasharray / dashoffset are set from JS based on the circle's length */
  transition: stroke-dashoffset .8s var(--ease), stroke .4s var(--ease);
}

.dial-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.dial-value {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dial-unit { margin-top: 4px; font-size: .75rem; color: var(--text-muted); }

.score-info { min-width: 0; }

.grade-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--grade-soft);
  color: var(--grade-color);
  font-size: .8125rem;
  font-weight: 600;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

.score-card[data-grade="none"] .grade-pill { color: var(--text-muted); }

.score-hint { margin-top: 8px; font-size: .875rem; line-height: 1.45; color: var(--text-muted); }

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.stat {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat dt { font-size: .75rem; color: var(--text-muted); }

.stat dd {
  margin: 2px 0 0;
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat dd small { font-family: var(--font-sans); font-size: .75rem; font-weight: 400; color: var(--text-muted); }

/* Legend + toggles */
.legend { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline: -8px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color .2s var(--ease), opacity .2s var(--ease);
}

.legend-item:hover { background: var(--surface-2); }
.legend-item.is-off { opacity: .55; }

.swatch {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid;
}

.swatch[data-type="hard"]      { background: var(--hl-hard);      border-color: var(--hl-hard-strong); }
.swatch[data-type="very-hard"] { background: var(--hl-very-hard); border-color: var(--hl-very-hard-strong); }
.swatch[data-type="passive"]   { background: var(--hl-passive);   border-color: var(--hl-passive-strong); }
.swatch[data-type="adverb"]    { background: var(--hl-adverb);    border-color: var(--hl-adverb-strong); }
.swatch[data-type="repeated"]  { background: var(--hl-repeated);  border-color: var(--hl-repeated-strong); }
.swatch[data-type="complex"]   { background: var(--hl-complex);   border-color: var(--hl-complex-strong); }

.legend-text { display: grid; flex: 1; min-width: 0; }
.legend-name { font-size: .9375rem; font-weight: 500; }
.legend-desc { font-size: .75rem; color: var(--text-muted); }

.count {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: background-color .2s, color .2s;
}

.count.is-zero { background: var(--surface-2); color: var(--text-muted); }

/* Suggestions */
.suggestions { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}

.suggestion:hover { border-color: var(--hl-complex-strong); }

.suggestion-action {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  transition: opacity .2s var(--ease);
}

.suggestion:hover .suggestion-action,
.suggestion:focus-visible .suggestion-action { opacity: 1; }

@media (hover: none) {
  .suggestion-action { opacity: 1; } /* touch screens can't hover, so always show it */
}

.suggestion-from {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--hl-complex);
}

.suggestion-arrow { color: var(--text-muted); }
.suggestion-to { flex: 1; font-weight: 600; }
.suggestion-count { font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.suggestions-empty { font-size: .875rem; color: var(--text-muted); }

/* Sentence rhythm chart */
.rhythm-chart {
  position: relative;
  height: 84px;
  padding-left: 22px; /* room for the 20 / 30 labels */
}

.rhythm-line {
  position: absolute;
  left: 22px;
  right: 0;
  bottom: var(--at);
  border-top: 1px dashed var(--border-strong);
  pointer-events: none;
}

.rhythm-line span {
  position: absolute;
  left: -22px;
  top: -8px;
  font-size: .625rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.rhythm {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.rhythm.is-empty { border-bottom: 1px solid var(--border); }

.rhythm-bar {
  flex: 1 0 4px;
  max-width: 16px;
  min-height: 4px;
  padding: 0;
  border: 0;
  border-radius: 3px 3px 1px 1px;
  background: var(--accent);
  opacity: .55;
  cursor: pointer;
  transition: opacity .15s var(--ease), height .3s var(--ease);
}

.rhythm-bar[data-level="hard"]      { background: var(--hl-hard-strong); opacity: .85; }
.rhythm-bar[data-level="very-hard"] { background: var(--hl-very-hard-strong); opacity: .85; }
.rhythm-bar:hover,
.rhythm-bar:focus-visible { opacity: 1; }
.rhythm-bar:focus-visible { outline-offset: 1px; border-radius: 3px; }

.rhythm-note { margin-top: 10px; font-size: .8125rem; color: var(--text-muted); }

/* Hover tooltip for highlights */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--tip-color, var(--accent));
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: .8125rem;
  line-height: 1.45;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .35);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s var(--ease), transform .12s var(--ease);
}

.tooltip.is-visible { opacity: 1; transform: none; }
.tooltip-title { font-weight: 600; }
.tooltip-body { opacity: .85; }

.tooltip[data-type="hard"]      { --tip-color: var(--hl-hard-strong); }
.tooltip[data-type="very-hard"] { --tip-color: var(--hl-very-hard-strong); }
.tooltip[data-type="passive"]   { --tip-color: var(--hl-passive-strong); }
.tooltip[data-type="adverb"]    { --tip-color: var(--hl-adverb-strong); }
.tooltip[data-type="repeated"]  { --tip-color: var(--hl-repeated-strong); }
.tooltip[data-type="complex"]   { --tip-color: var(--hl-complex-strong); }

/* 8. Toast, utilities, motion ---------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .35);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 12px);
  transition: opacity .2s var(--ease), transform .2s var(--ease), visibility 0s linear .2s;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

.toast:empty { padding: 0; }

.toast-action {
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(127, 127, 127, .22);
  color: inherit;
  font: 600 .8125rem/1 var(--font-sans);
  cursor: pointer;
}

.toast-action:hover { background: rgba(127, 127, 127, .35); }

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform .2s var(--ease);
}

.skip-link:focus { transform: translateY(0); }

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

.noscript { padding: 16px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
