/* ============================================================
   pulse — layout + components
   ============================================================ */

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

* {
  margin: 0;
}

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

body {
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* The slow-breathing ambient field is the page's resting pulse. */
.ambient {
  position: fixed;
  inset: 0;
  z-index: var(--z-ambient);
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-soft), transparent 55%),
    radial-gradient(80% 70% at 88% 4%, rgba(120, 150, 255, 0.05), transparent 60%);
  opacity: 0.9;
  animation: breathe 9s var(--ease-in-out) infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.62; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* Grain keeps the dark field from banding on cheap panels. */
.ambient::after {
  content: "";
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.025;
  mix-blend-mode: overlay;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

input {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: var(--accent-glow);
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: content-box;
}

/* ---- App shell -------------------------------------------- */
.app {
  position: relative;
  z-index: var(--z-base);
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding:
    max(clamp(var(--s4), 3.5vw, var(--s7)), env(safe-area-inset-top))
    max(clamp(var(--s4), 3.5vw, var(--s7)), env(safe-area-inset-right))
    max(clamp(var(--s4), 3.5vw, var(--s7)), env(safe-area-inset-bottom))
    max(clamp(var(--s4), 3.5vw, var(--s7)), env(safe-area-inset-left));
  gap: var(--s5);
}

/* ---- Top bar ---------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.12em;
  font-weight: 600;
  font-size: var(--text-md);
  letter-spacing: var(--tracking-snug);
  color: var(--ink);
  user-select: none;
}
.wordmark .dot {
  width: 0.42em;
  height: 0.42em;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  transform: translateY(-0.02em);
  animation: heartbeat 2.4s var(--ease-out) infinite;
}

@keyframes heartbeat {
  0%, 42%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  18% { box-shadow: 0 0 0 5px var(--accent-glow-0); }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* ---- Shared controls -------------------------------------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  color: var(--ink-1);
  transition: background var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.icon-btn:hover {
  background: var(--bg-2);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}

.kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 38px;
  padding: 0 var(--s3) 0 var(--s3);
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: var(--text-sm);
  transition: border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}
.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.chip svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.chip.is-loading {
  color: var(--ink-2);
}
.weather-chip.is-stale {
  opacity: 0.7;
  border-style: dashed;
}
.chip[hidden] {
  display: none;
}

.weather-chip .temp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 500;
}
.weather-chip .where {
  color: var(--ink-2);
  max-width: 9ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: var(--text-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--ink);
  transition: background var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-bright); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-1);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-danger {
  color: var(--danger);
  border-color: var(--line-2);
  background: transparent;
}
.btn-danger:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

.field {
  width: 100%;
  height: 44px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  background: var(--field);
  border: 1px solid var(--line-2);
  color: var(--ink);
  transition: border-color var(--dur-1) var(--ease-out),
    background var(--dur-1) var(--ease-out);
}
.field::placeholder { color: var(--ink-2); }
.field:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--field-focus);
}

/* ---- Center stage ----------------------------------------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(var(--s5), 4.5vh, var(--s8));
  text-align: center;
  padding: var(--s5) 0;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

.clock {
  font-family: var(--font-mono);
  font-weight: 200;
  font-size: var(--text-clock);
  line-height: 0.92;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 0.04em;
}
.clock .sep {
  color: var(--accent);
  animation: blink 2s steps(1, end) infinite;
}
.clock .meridiem {
  font-size: 0.26em;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  align-self: center;
  margin-left: 0.2em;
  text-transform: uppercase;
}
.clock .secs {
  font-size: 0.26em;
  font-weight: 400;
  color: var(--ink-3);
  align-self: center;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}

.greeting {
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}
.greeting .name { color: var(--accent); }

.subline {
  font-size: var(--text-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.subline .dot-sep { opacity: 0.5; margin: 0 0.5em; }

/* ---- Pulse line (canvas) ---------------------------------- */
.pulse-wrap {
  width: min(720px, 100%);
  height: 64px;
  position: relative;
}
.pulse-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- Search ----------------------------------------------- */
.searchbar {
  width: min(640px, 100%);
  position: relative;
}
.search-form {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 56px;
  padding: 0 var(--s2) 0 var(--s4);
  border-radius: var(--r-lg);
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out), background var(--dur-2) var(--ease-out);
}
.search-form:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-1), 0 0 0 4px var(--accent-soft);
}
.search-icon {
  color: var(--ink-2);
  width: 21px;
  height: 21px;
  flex: none;
}
.search-form:focus-within .search-icon { color: var(--accent); }
.search-input {
  flex: 1;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: var(--text-md);
  color: var(--ink);
}
.search-input::placeholder { color: var(--ink-2); }

.engine-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s3);
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.engine-switch:hover { background: var(--bg-3); color: var(--ink); }
.engine-switch .glyph { font-size: 1rem; line-height: 1; }
.engine-switch .caret { width: 13px; height: 13px; color: var(--ink-2); }

.search-hint {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + var(--s2));
  font-size: var(--text-xs);
  color: var(--ink-2);
  text-align: center;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
  pointer-events: none;
}
.searchbar:not(:focus-within) .search-hint { opacity: 1; }

/* ---- Menu (engine / generic dropdowns) -------------------- */
.menu {
  position: absolute;
  z-index: var(--z-dropdown);
  min-width: 184px;
  padding: var(--s2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform-origin: top right;
  animation: pop var(--dur-2) var(--ease-out);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  color: var(--ink-1);
  font-size: var(--text-sm);
  text-align: left;
  width: 100%;
}
.menu-item:hover,
.menu-item[aria-selected="true"] { background: var(--bg-3); color: var(--ink); }
.menu-item .glyph { font-size: 1rem; width: 1.2em; text-align: center; }
.menu-item .check { margin-left: auto; color: var(--accent); opacity: 0; }
.menu-item[data-active="true"] .check { opacity: 1; }

/* ---- Quick links ------------------------------------------ */
.links {
  width: min(760px, 100%);
}
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--s3);
}
.link-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4) var(--s2);
  border-radius: var(--r-md);
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--ink-1);
  transition: transform var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}
.link-tile:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--bg-2);
  color: var(--ink);
}
.link-tile:active { transform: translateY(0); }
.link-favicon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--bg-3);
  overflow: hidden;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--ink);
}
.link-favicon img { width: 100%; height: 100%; object-fit: cover; }
.link-label {
  font-size: var(--text-xs);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-edit {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  color: var(--ink-1);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.link-tile:hover .link-edit,
.link-edit:focus-visible { opacity: 1; transform: scale(1); }
.link-edit:hover { background: var(--accent-soft); color: var(--accent); }
.link-edit svg { width: 13px; height: 13px; }

.link-add {
  border-style: dashed;
  border-color: var(--line-2);
  background: transparent;
  color: var(--ink-2);
  justify-content: center;
}
.link-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.link-add .link-favicon { background: transparent; }

/* Drag + drop reordering */
.link-tile.dragging { opacity: 0.4; cursor: grabbing; }
.link-tile.drop-before { box-shadow: -3px 0 0 var(--accent); }
.link-tile.drop-after { box-shadow: 3px 0 0 var(--accent); }

/* ---- Focus dock ------------------------------------------- */
.dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  flex-wrap: wrap;
}

.focus {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  height: 46px;
  padding: 0 var(--s2) 0 var(--s4);
  border-radius: var(--r-full);
  background: var(--bg-1);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.focus-ring {
  --p: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  background:
    conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bg-3) 0);
  display: grid;
  place-items: center;
  flex: none;
  transition: background var(--dur-3) linear;
}
.focus-ring::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--bg-1);
}
.focus.is-running .focus-ring { animation: focuspulse 2s var(--ease-in-out) infinite; }
@keyframes focuspulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 6px var(--accent-glow-0); }
}
.focus-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.focus-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink);
}
.focus-meta { font-size: var(--text-xs); color: var(--ink-2); }
.focus-actions { display: flex; gap: 2px; }

/* ---- Footer area ------------------------------------------ */
.footer-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

/* ---- Footer signal ---------------------------------------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding-top: var(--s2);
}
.signal {
  max-width: 62ch;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-2);
  text-wrap: pretty;
  opacity: 0;
  animation: rise var(--dur-slow) var(--ease-out) forwards;
}
.signal .who { color: var(--ink-1); font-style: normal; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 0.92; transform: translateY(0); }
}

/* ---- Overlays (palette, settings, dialog) ----------------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(7, 8, 11, 0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  animation: fade var(--dur-2) var(--ease-out) forwards;
}
.scrim[hidden] { display: none; }
@keyframes fade { to { opacity: 1; } }

/* Command palette */
.palette {
  position: fixed;
  z-index: var(--z-modal);
  top: 14vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - var(--s6)));
  border-radius: var(--r-lg);
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: lift var(--dur-2) var(--ease-out);
}
@keyframes lift {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.palette[hidden] { display: none; }
.palette-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  height: 58px;
  border-bottom: 1px solid var(--line);
}
.palette-head svg { width: 19px; height: 19px; color: var(--ink-2); flex: none; }
.palette-input {
  flex: 1;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: var(--text-md);
}
.palette-input::placeholder { color: var(--ink-2); }
.palette-list {
  list-style: none;
  padding: var(--s2);
  margin: 0;
  max-height: 46vh;
  overflow-y: auto;
}
.palette-section {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-2);
  padding: var(--s3) var(--s3) var(--s2);
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-sm);
  color: var(--ink-1);
  cursor: pointer;
  scroll-margin: var(--s6);
}
.palette-item[aria-selected="true"] { background: var(--bg-3); color: var(--ink); }
.palette-item .p-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--ink-1);
  flex: none;
}
.palette-item[aria-selected="true"] .p-icon { background: var(--accent-soft); color: var(--accent); }
.palette-item .p-icon svg { width: 17px; height: 17px; }
.palette-item .p-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.palette-item .p-title { font-size: var(--text-sm); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-sub { font-size: var(--text-xs); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-kbd { margin-left: auto; }
.palette-empty { padding: var(--s6); text-align: center; color: var(--ink-2); font-size: var(--text-sm); }
.palette-foot {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.palette-foot .hintset { display: inline-flex; align-items: center; gap: var(--s2); }

/* Settings drawer */
.drawer {
  position: fixed;
  z-index: var(--z-modal);
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(420px, 100vw);
  background: var(--bg-1);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  animation: slidein var(--dur-3) var(--ease-out);
}
@keyframes slidein {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer[hidden] { display: none; }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s5);
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-snug); }
.drawer-body {
  flex: 1;
  min-height: 0; /* let the body shrink so overflow-y actually scrolls */
  padding: var(--s5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}
.setting-group { display: flex; flex-direction: column; gap: var(--s3); }
.setting-group > .label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-2);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}
.setting-row .desc { display: flex; flex-direction: column; }
.setting-row .desc .t { font-size: var(--text-sm); color: var(--ink); }
.setting-row .desc .s { font-size: var(--text-xs); color: var(--ink-2); }

/* segmented control */
.segment {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.segment button {
  padding: 6px 12px;
  border-radius: calc(var(--r-md) - 4px);
  font-size: var(--text-sm);
  color: var(--ink-2);
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.segment button[aria-pressed="true"] { background: var(--bg-3); color: var(--ink); box-shadow: var(--shadow-1); }
.segment button:hover { color: var(--ink); }

/* toggle */
.toggle {
  width: 44px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--bg-3);
  border: 1px solid var(--line);
  position: relative;
  transition: background var(--dur-2) var(--ease-out);
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--ink-1);
  transition: transform var(--dur-2) var(--ease-spring), background var(--dur-2) var(--ease-out);
}
.toggle[aria-pressed="true"] { background: var(--accent); border-color: transparent; }
.toggle[aria-pressed="true"]::after { transform: translateX(18px); background: var(--accent-ink); }

/* accent swatches */
.swatches { display: flex; gap: var(--s2); flex-wrap: wrap; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  border: 2px solid transparent;
  position: relative;
  transition: transform var(--dur-1) var(--ease-out);
}
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.swatch span { position: absolute; inset: 3px; border-radius: var(--r-full); }

.drawer-foot {
  margin-top: auto;
  padding: var(--s5);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.drawer-foot .meta { font-size: var(--text-xs); color: var(--ink-2); text-align: center; }
.drawer-foot .meta a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }

/* Generic dialog (link editor) */
.dialog {
  position: fixed;
  z-index: var(--z-modal);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - var(--s6)));
  border-radius: var(--r-lg);
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  animation: lift var(--dur-2) var(--ease-out);
}
.dialog[hidden] { display: none; }
.dialog h2 { font-size: var(--text-md); font-weight: 600; }
.dialog .form-field { display: flex; flex-direction: column; gap: var(--s2); }
.dialog .form-field label { font-size: var(--text-xs); color: var(--ink-2); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.dialog-actions { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s2); }
.dialog-actions .spacer { flex: 1; }

/* ---- Toasts ----------------------------------------------- */
.toaster {
  position: fixed;
  z-index: var(--z-toast);
  bottom: max(var(--s5), env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
  pointer-events: none;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  font-size: var(--text-sm);
  pointer-events: auto;
  animation: toastin var(--dur-3) var(--ease-out);
}
.toast.out { animation: toastout var(--dur-2) var(--ease-in-out) forwards; }
.toast .toast-accent { color: var(--accent); display: inline-grid; place-items: center; }
.toast .toast-accent svg { width: 17px; height: 17px; }
.toast button { color: var(--ink-1); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
@keyframes toastin {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastout {
  to { opacity: 0; transform: translateY(8px); }
}

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

[hidden] { display: none !important; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 560px) {
  .app { padding: var(--s4); gap: var(--s4); }
  .stage { gap: var(--s4); }
  .search-form { height: 52px; }
  .engine-switch .label-text { display: none; }
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); }
  .pulse-wrap { height: 48px; }
  .topbar .kbd-hint { display: none; }
  .search-hint { display: none; }
}

@media (max-width: 380px) {
  .clock .secs { display: none; }
}

/* ---- Reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .ambient { animation: none; opacity: 0.8; }
  .clock .sep { animation: none; opacity: 1; }
}
