:root {
  --bg: #171614;
  --panel: #201f1c;
  --panel-2: #2a2825;
  --line: #36332f;
  --text: #ece8e1;
  --muted: #9d978d;
  --accent: #e8483b;
  --accent-2: #f2c94c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-columns: 350px 1fr 280px;
  min-height: 100vh;
}
aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
/* Scrollbars always keep their space reserved (thin, so it costs little), so content never
   narrows or jumps sideways when a panel starts or stops scrolling. */
aside, .favs-section, .history, .font-list { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #4a463f transparent; }
aside::-webkit-scrollbar, .favs-section::-webkit-scrollbar, .history::-webkit-scrollbar, .font-list::-webkit-scrollbar { width: 8px; }
aside::-webkit-scrollbar-thumb, .favs-section::-webkit-scrollbar-thumb, .history::-webkit-scrollbar-thumb, .font-list::-webkit-scrollbar-thumb {
  background: #4a463f; border-radius: 4px; border: 2px solid transparent; background-clip: padding-box;
}
aside::-webkit-scrollbar-track, .favs-section::-webkit-scrollbar-track, .history::-webkit-scrollbar-track, .font-list::-webkit-scrollbar-track { background: transparent; }
aside { padding-right: 12px; }
aside.right { border-right: 0; border-left: 1px solid var(--line); gap: 18px; overflow-y: auto; padding-bottom: 16px; }
/* Favourites fill from the top; History and Shortcuts are anchored to the bottom and unfold upwards. */
aside.right .favs-section { flex: 0 1 auto; min-height: 110px; max-height: 40vh; overflow-y: auto; }
aside.right .hist-section { flex: none; margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
aside.right .history { max-height: 30vh; overflow-y: auto; margin-top: 10px; }
/* Folding sections (History, Shortcuts): the title row stays, a caret shows the state. */
.fold > summary { list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2::after { content: " ▸"; color: var(--muted); font-size: 11px; }
.fold[open] > summary h2::after { content: " ▾"; }
aside h2 {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
aside section { display: flex; flex-direction: column; gap: 10px; }
.msg-options { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: -6px; }
.icon-label { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.brand { user-select: none; }
.logo-canvas { display: block; max-width: 100%; cursor: pointer; margin: -6px auto -4px; }
/* Logo placeholder until the generator renders the real one: a tiny ransom note of its own */
.logo { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 11px; font-size: 21px; line-height: 1; }
.logo .word { display: inline-flex; align-items: center; gap: 1px; }
.logo b {
  display: inline-block; padding: 3px 4px 2px; font-weight: 400;
  box-shadow: 1px 2px 2px rgba(0,0,0,.4);
}
.logo .k1 { background: var(--accent); color: #fff; font-family: "Playfair Display", Georgia, serif; font-weight: 900; transform: rotate(-5deg); }
.logo .k2 { background: #f4f1ea; color: #141414; font-family: "Anton", Impact, sans-serif; transform: rotate(3deg); }
.logo .k3 { background: var(--accent-2); color: #141414; font-family: "Courier Prime", monospace; font-weight: 700; transform: rotate(-2deg); }
.logo .k4 { background: #141414; color: #f4f1ea; font-family: "Abril Fatface", Georgia, serif; transform: rotate(4deg); outline: 1px solid #3b3833; }
.logo .k5 { background: #bfe0f2; color: #1b2a5c; font-family: "Bodoni Moda", Georgia, serif; font-weight: 900; font-style: italic; transform: rotate(-3deg); }
.logo .k6 { background: #fbfaf7; color: #c8102e; font-family: "Alfa Slab One", Georgia, serif; transform: rotate(2deg); font-size: 1.12em; }
.logo .k7 { background: #d6246e; color: #fff; font-family: "Bebas Neue", Impact, sans-serif; transform: rotate(-4deg); font-size: 1.15em; }
.logo .k8 { background: #fdfcfa; color: #141414; font-family: "UnifrakturMaguntia", serif; transform: rotate(3deg); clip-path: polygon(0 4%, 100% 0, 96% 100%, 3% 95%); }
.brand p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

label.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); }
textarea, select, input[type=text], input[type=search] {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
textarea { resize: vertical; min-height: 100px; padding: 10px 11px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
textarea:focus, select:focus, input:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
button {
  font: inherit; font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #57524b; background: #312f2b; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #d33c30; }
button:disabled { opacity: .45; cursor: default; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.hint kbd {
  font: 11px ui-monospace, monospace; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
#status { min-height: 1.4em; font-size: 12.5px; color: var(--accent-2); }

/* Settings: tabs + accordion */
.tabs { display: flex; gap: 3px; background: var(--panel-2); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 6px 8px; font-size: 12.5px; color: var(--muted); border-radius: 7px; }
.tabs button:hover:not(:disabled) { background: #312f2b; border: 0; }
.tabs button[aria-selected=true] { background: var(--text); color: #171614; }
.tab-panel { border-top: 1px solid var(--line); margin-top: -4px; }
.tab-panel.flat { border-top: 0; display: flex; flex-direction: column; gap: 14px; }
details.group { border-bottom: 1px solid var(--line); }
details.group > summary {
  list-style: none; cursor: pointer; padding: 12px 2px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px;
  border-right: 2px solid; border-bottom: 2px solid;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s;
}
details.group[open] > summary { color: var(--text); }
details.group[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
details.group > summary small { text-transform: none; letter-spacing: 0; font-weight: 500; }
/* An open group's contents sit on a slightly brighter band running the full panel width;
   the group title keeps the panel colour. */
.group-body {
  display: flex; flex-direction: column; gap: 14px;
  margin: 0 -12px 0 -20px; padding: 14px 12px 18px 20px; /* matches the panel padding (right side holds the scrollbar lane) */
  background: #262421; border-top: 1px solid #2e2b28;
}
@media (max-width: 860px) { .group-body { margin: 0 -16px; padding: 14px 16px 18px; } }
/* Sliders inside groups: a dark track with the filled part in the accent, instead of the
   browser's bright white track. --fill is kept up to date from script. */
.group-body input[type=range] { -webkit-appearance: none; appearance: none; height: 16px; background: transparent; cursor: pointer; }
.group-body input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--fill, 50%) 100% no-repeat, #403c37;
}
.group-body input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #403c37; }
.group-body input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.group-body input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border: 0; border-radius: 50%; background: #d9d3c9; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.group-body input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #d9d3c9; }
.group-body input[type=range]:focus-visible { outline: none; }
.group-body input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); }
.setting { display: flex; flex-direction: column; gap: 6px; }
.tone-row { display: flex; align-items: center; gap: 8px; }
.tone-row input[type=color] { width: 52px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: none; cursor: pointer; }
.tone-row .arrow { color: var(--muted); }
.tone-chip { width: 52px; height: 28px; border-radius: 7px; border: 1px solid var(--line); }
.setting-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-height: 24px; }
.setting-head .name { flex: 1; }
.group-body > [inert] { opacity: .4; user-select: none; } /* has no effect with the current settings */
.setting-head output { color: var(--text); font-variant-numeric: tabular-nums; margin-right: 2px; }
.icon {
  flex: none; width: 26px; height: 24px; padding: 0;
  display: grid; place-items: center; border-radius: 6px; color: var(--muted);
}
.icon:hover:not(:disabled) { color: var(--text); }
.icon:disabled { opacity: .22; }
.icon.reseed:active svg { transform: rotate(90deg); }
.icon svg { transition: transform .2s; }
.mix { display: grid; grid-template-columns: 92px 1fr 38px; gap: 4px 10px; align-items: center; font-size: 12px; color: var(--muted); }
.mix .num {
  width: 100%; padding: 1px 3px; border: 1px solid transparent; border-radius: 5px; background: none;
  color: var(--text); font: inherit; text-align: right; font-variant-numeric: tabular-nums;
}
.mix .num:hover { border-color: var(--line); }
.mix .num:focus { border-color: var(--accent); background: var(--panel-2); outline: none; }
.range-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.range-pick select { width: auto; flex: 1; padding: 6px 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { position: relative; }
.swatch input[type=color] {
  width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px;
  background: none; cursor: pointer; display: block;
}
.swatch button {
  position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; padding: 0;
  font-size: 11px; line-height: 1; border-radius: 50%; display: none;
}
.swatch:hover button, .swatch:focus-within button { display: grid; place-items: center; }

/* Typefaces */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--muted); }
.chips button.on { background: var(--text); border-color: var(--text); color: #171614; }
.chips button.partial { border-color: var(--text); color: var(--text); }
.font-list {
  max-height: 300px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.font-row {
  display: grid; grid-template-columns: 18px 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.font-row:last-child { border-bottom: 0; }
.font-row input { accent-color: var(--accent); margin: 0; }
.font-row span { font-size: 18px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-row small { color: var(--muted); font-size: 11px; }
.font-row.off span { opacity: .35; }
.font-row button { padding: 0 6px; font-size: 12px; line-height: 20px; }
.upload { display: block; text-align: center; padding: 8px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.upload:hover { color: var(--text); border-color: #57524b; }

/* Export: a round button in the work area's bottom-right corner opens a small pop-up above it. */
/* Bottom-right tools: the two clear buttons and the export button. */
.corner-tools { position: absolute; right: 18px; bottom: 16px; z-index: 4; display: flex; align-items: center; gap: 8px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--accent); border-color: var(--accent); color: #fff; font-size: 13px; box-shadow: 0 6px 16px rgba(0,0,0,.35);
}
.tool-btn:hover:not(:disabled) { background: #d33c30; border-color: #d33c30; }
.tool-btn:disabled { opacity: .4; }
.export-btn {
  width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
/* Small confirm bubble shown above a clear button. */
.confirm-pop {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: 10px; max-width: 280px;
  padding: 7px 7px 7px 12px; font-size: 12.5px; line-height: 1.35; cursor: default;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 26px rgba(0,0,0,.5);
}
.confirm-pop .ok {
  flex: none; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  background: #2f9e5b; border-color: #2f9e5b; color: #fff;
}
.confirm-pop .ok:hover:not(:disabled) { background: #268a4e; border-color: #268a4e; }
.export-btn:hover:not(:disabled) { background: #d33c30; border-color: #d33c30; }
.export-status { min-height: 1.3em; margin-top: -4px; font-size: 12px; color: var(--accent-2); }
.export-status:empty { display: none; }
.export-btn[aria-expanded=true] { background: var(--text); border-color: var(--text); color: #171614; }
.export-pop {
  position: absolute; right: 18px; bottom: 64px; z-index: 5; width: 300px; cursor: default;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.5);
}

/* Favourites */
.fav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fav-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; padding: 18px 10px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.fav {
  position: relative; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line);
  background: #e9e5dc; display: grid; place-items: center; cursor: grab; overflow: hidden;
}
.fav img { max-width: 78%; max-height: 72%; pointer-events: none; filter: drop-shadow(1px 2px 2px rgba(0,0,0,.3)); }
/* Drawn inside the card so the scrolling favourites area can't clip it. */
.fav.armed { outline: 3px solid var(--accent-2); outline-offset: -3px; }
.fav.flash { animation: fav-flash .9s ease-out; }
@keyframes fav-flash { 0%, 40% { box-shadow: inset 0 0 0 3px var(--accent); } 100% { box-shadow: inset 0 0 0 3px transparent; } }
.fav .menu, .fav .remove {
  position: absolute; right: 6px; width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center; border-radius: 6px;
  background: rgba(23,22,20,.75); border-color: transparent; color: #fff;
}
.fav .menu { top: 6px; }
.fav .remove { top: 36px; font-size: 15px; line-height: 1; }
.fav .remove:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.fav .count {
  position: absolute; left: 6px; bottom: 5px; font-size: 10.5px; font-weight: 600; color: #3a352e;
}
.fav-detail {
  grid-column: 1 / -1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.feat-row { display: grid; grid-template-columns: 86px 1fr 24px; gap: 6px; align-items: center; font-size: 12px; }
.feat-row > span:first-child { color: var(--muted); }
.feat-row > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat-row button { width: 22px; height: 22px; padding: 0; font-size: 12px; line-height: 1; }
.feat-row.gone { opacity: .45; }
i.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(255,255,255,.3); vertical-align: -1px; margin-right: 5px; }

/* History */
.hist-head { display: flex; align-items: center; gap: 8px; }
.hist-head h2 { flex: 1; }
.hist-head button { padding: 5px 10px; font-size: 12.5px; }
.history { display: flex; flex-direction: column; gap: 3px; }
.hist-item {
  display: grid; grid-template-columns: 58px 1fr; gap: 9px; align-items: center; text-align: left;
  padding: 4px; border-radius: 7px; font-size: 12px; font-weight: 500; background: none; border: 1px solid transparent;
}
.hist-item img, .hist-item .ph { width: 58px; height: 40px; object-fit: cover; border-radius: 4px; background: #333; display: block; }
.hist-item.current { border-color: var(--accent); background: var(--panel-2); }
.hist-item.future { opacity: .45; }

/* Settings and Shortcuts (bottom right) */
.settings-section, .shortcuts { flex: none; margin-top: -6px; border-top: 1px solid var(--line); padding-top: 12px; }
.settings-section[open] > summary, .shortcuts[open] > summary { margin-bottom: 8px; }
.setting-item .hint { margin: 6px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.wipe-confirm { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 12.5px; }
button.danger { border-color: var(--accent); color: #ff8f80; }
button.danger:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.sc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sc {
  position: relative; display: grid; grid-template-columns: 108px 1fr; align-items: center; gap: 8px;
  padding: 3px 6px; border-radius: 6px; font-size: 12px; color: var(--muted);
}
.sc[tabindex] { cursor: help; }
.sc[tabindex] .does { text-decoration: underline dotted rgba(255,255,255,.3); text-underline-offset: 3px; }
.sc:hover, .sc:focus-visible { background: var(--panel-2); color: var(--text); outline: none; }
.sc .combo { display: inline-flex; align-items: center; gap: 3px; color: var(--text); white-space: nowrap; }
.sc kbd {
  font: 600 10.5px/1 ui-monospace, Consolas, monospace; padding: 3px 5px; border-radius: 4px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--panel-2); color: var(--text);
}
.sc .plus { color: var(--muted); font-size: 10px; }
.sc svg { display: block; }
.sc .tip {
  display: none; position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; width: 250px;
  background: #2f2c28; color: var(--text); border: 1px solid #4a463f; border-radius: 8px;
  padding: 9px 11px; font-size: 12px; line-height: 1.45; box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
.sc:hover .tip, .sc:focus-visible .tip { display: block; }

/* Workspace: the note sits on a pannable, zoomable view */
main {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255,240,215,.06), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 2px, transparent 2px 7px),
    #26231f;
}
main.panning, main.panning #note { cursor: grabbing !important; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; line-height: 0; }
.stage.transparent {
  background: repeating-conic-gradient(#3a3733 0% 25%, #2f2c29 0% 50%) 0 0 / 20px 20px;
}
#note {
  display: block; height: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.35);
}
#note.pasting { cursor: copy !important; }
.stage.transparent #note { box-shadow: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; line-height: 1.4;
}
.zoombar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 3px; border-radius: 10px; cursor: default;
  background: rgba(32,31,28,.92); border: 1px solid var(--line); box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.zoombar button { border: 0; background: none; padding: 6px 10px; font-size: 13px; border-radius: 7px; min-width: 34px; }
.zoombar button:hover:not(:disabled) { background: var(--panel-2); border: 0; }
.zoombar #zoomLabel { min-width: 58px; font-variant-numeric: tabular-nums; color: var(--muted); }
/* Pin on a hovered clipping whose position was set by hand; turns into a red × to free it. */
.pin-btn {
  position: absolute; z-index: 3; width: 24px; height: 24px; padding: 0; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%;
  background: #2f6fdc; border: 2px solid #fff; color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.info-btn {
  position: absolute; z-index: 3; width: 24px; height: 24px; padding: 0; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%; cursor: help;
  background: #1f8a7a; border: 2px solid #fff; color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  font: italic 700 14px/1 Georgia, serif;
}
.info-btn:hover:not(:disabled), .info-btn:focus-visible { background: var(--accent-2); border-color: #fff; color: #171614; }
/* Asterisk: this clipping has settings locked (padlocks, a pasted favourite or a Shift-lock). */
.info-btn.has-locks::after {
  content: "*"; position: absolute; top: -7px; right: -8px; width: 15px; height: 15px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); border: 1.5px solid #fff; color: #fff;
  font: 700 13px/1 system-ui, sans-serif; padding-top: 3px; box-sizing: border-box;
}
.pin-btn .x { display: none; }
.pin-btn:hover:not(:disabled), .pin-btn:focus-visible { background: var(--accent); border-color: #fff; }
.pin-btn:hover .pin, .pin-btn:focus-visible .pin { display: none; }
.pin-btn:hover .x, .pin-btn:focus-visible .x { display: block; }

/* Explanations live in tooltips: titles with one get a dotted underline and show it after a second. */
.name[data-help], .check span[data-help], .field > span[data-help], aside h2[data-help] {
  cursor: help; text-decoration: underline dotted rgba(255,255,255,.28); text-underline-offset: 3px;
}
#helpTip {
  position: fixed; z-index: 30; max-width: 290px; pointer-events: none;
  background: #2f2c28; color: var(--text); border: 1px solid #4a463f; border-radius: 8px;
  padding: 9px 11px; font-size: 12px; line-height: 1.45; box-shadow: 0 10px 24px rgba(0,0,0,.45);
}

/* Hover info card */
#info {
  position: fixed; z-index: 20; pointer-events: none; width: 264px;
  background: rgba(24,23,21,.97); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px 11px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
#info .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#info .sample { flex: 1; font-size: 30px; line-height: 1.15; color: #f4f1ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#info .close { width: 26px; height: 26px; padding: 0; font-size: 15px; line-height: 1; flex: none; }
#info dl { display: grid; grid-template-columns: 86px 1fr 22px; gap: 3px 6px; margin: 0; align-items: center; }
/* Clicking the "i" pins the card: it becomes interactive and each row's padlock locks that setting. */
#info.pinned { pointer-events: auto; border-color: var(--accent-2); width: 290px; }
#info .lk {
  width: 22px; height: 20px; padding: 0; border: 0; background: none; border-radius: 5px;
  display: grid; place-items: center; color: var(--muted);
}
#info .lk:hover:not(:disabled) { background: var(--panel-2); color: var(--text); border: 0; }
#info .lk.on { color: var(--accent); }
#info:not(.pinned) .lk:not(.on) { visibility: hidden; }
#info.pinned .go { cursor: pointer; }
#info.pinned dt.go:hover, #info.pinned dt.go:hover + dd { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }
#info.pinned dd.go:hover { color: var(--accent-2); }

/* A setting reached from a clipping's details card glows briefly. */
@keyframes setting-flash {
  0%, 30% { background: rgba(242,201,76,.07); box-shadow: 0 0 0 5px rgba(242,201,76,.07); }
  100% { background: transparent; box-shadow: 0 0 0 5px transparent; }
}
.flash-setting { animation: setting-flash 1.8s ease-out; border-radius: 6px; }
#info dt { color: var(--muted); }
#info dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#info .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
#info .tags span { padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent-2); font-size: 11px; }

@media (max-width: 1240px) {
  body { grid-template-columns: 330px 1fr; }
  aside.right { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  .fav-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px; }
  main { position: relative; height: 72vh; }
}
