/* linkDeck: slate folder, brass hardware, user colors carry the content. */

:root {
  --ink: #1A1E26;
  --folder: #222733;
  --pill: #2A303C;
  --pill-hover: #313846;
  --line: #3A4151;
  --line-soft: #303746;
  --paper: #E8E4DA;
  --muted: #A0A6B3;
  --faint: #737A8A;
  --brass: #D2B074;
  --brass-hover: #DFC08A;
  --up: #86CDA5;
  --down: #EC9A9A;

  --tab-hover: #1F242D;
  --danger-hover: #F2B0B0;
  --chip: #E8E4DA14;
  --body: #D3CFC5;
  --shadow: 6 8 12;
  --backdrop: 12 14 19;

  /* Flair icon colors */
  --f-free: #86CDA5;
  --f-subscription: #9C8CF0;
  --f-onetime: #7FB6F2;
  --f-signup: #5FC6C9;
  --f-ads: #E9B460;
  --f-redirects: #EE8A7A;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --gutter: 32px;
  color-scheme: dark;
}

/* ---------- themes ----------
   Slate (above) is the default. Each theme swaps the same tokens.
   Category and tab colors are darkened in JS for the light themes. */

:root[data-theme="manila"] {
  --ink: #E4E2DC;
  --folder: #F2E8C9;
  --pill: #FBF7EA;
  --pill-hover: #FFFDF6;
  --line: #D2C6A1;
  --line-soft: #E3D8B6;
  --paper: #2B2722;
  --muted: #5E574B;
  --faint: #7D7464;
  --brass: #2F4F87;
  --brass-hover: #26426F;
  --up: #2E7D4F;
  --down: #B23B3B;
  --tab-hover: #ECE9E2;
  --danger-hover: #C85050;
  --chip: rgba(43, 39, 34, .07);
  --body: #3D372F;
  --shadow: 80 70 40;
  --backdrop: 60 55 45;
  --f-free: #2E7D4F;
  --f-subscription: #6A4FC2;
  --f-onetime: #2F6FB0;
  --f-signup: #1E7F86;
  --f-ads: #A86A12;
  --f-redirects: #B8452F;
  color-scheme: light;
}

:root[data-theme="archive"] {
  --ink: #EEF1F5;
  --folder: #FFFFFF;
  --pill: #F5F7FA;
  --pill-hover: #EDF1F6;
  --line: #D5DBE5;
  --line-soft: #E4E8EF;
  --paper: #18202E;
  --muted: #4B5567;
  --faint: #6E7889;
  --brass: #3D4FD1;
  --brass-hover: #3141B4;
  --up: #1F8A5B;
  --down: #C93C4B;
  --tab-hover: #E6EAF0;
  --danger-hover: #D9505E;
  --chip: rgba(24, 32, 46, .06);
  --body: #2B3445;
  --shadow: 30 40 70;
  --backdrop: 20 28 45;
  --f-free: #1F8A5B;
  --f-subscription: #6B4FD8;
  --f-onetime: #2A6FD1;
  --f-signup: #0E8A93;
  --f-ads: #B7791F;
  --f-redirects: #C6462E;
  color-scheme: light;
}

:root[data-theme="rosewater"] {
  --ink: #F1E6E8;
  --folder: #FCF6F7;
  --pill: #FFFFFF;
  --pill-hover: #FBF1F3;
  --line: #E2CDD2;
  --line-soft: #EEDDE1;
  --paper: #33242A;
  --muted: #6A5359;
  --faint: #8A7077;
  --brass: #A23D62;
  --brass-hover: #8A3254;
  --up: #2F7D57;
  --down: #B83A3A;
  --tab-hover: #EADCDF;
  --danger-hover: #C95252;
  --chip: rgba(51, 36, 42, .06);
  --body: #46343A;
  --shadow: 90 50 60;
  --backdrop: 60 35 45;
  --f-free: #2F7D57;
  --f-subscription: #6E4FC8;
  --f-onetime: #2D6CB8;
  --f-signup: #17808A;
  --f-ads: #A96A14;
  --f-redirects: #BC4430;
  color-scheme: light;
}

:root[data-theme="blueprint"] {
  --ink: #0E1E36;
  --folder: #14294A;
  --pill: #1A3359;
  --pill-hover: #203D69;
  --line: #2D4D7C;
  --line-soft: #23406B;
  --paper: #E7EFFA;
  --muted: #A4B6D0;
  --faint: #7D94B5;
  --brass: #7CC8FF;
  --brass-hover: #A0D7FF;
  --up: #7FD8A6;
  --down: #FF9C9C;
  --tab-hover: #122644;
  --danger-hover: #FFB8B8;
  --chip: rgba(231, 239, 250, .08);
  --body: #CBD7E8;
  --shadow: 2 8 20;
  --backdrop: 4 12 26;
}

:root[data-theme="moss"] {
  --ink: #151C18;
  --folder: #1C2620;
  --pill: #243129;
  --pill-hover: #2B3A31;
  --line: #3A4B40;
  --line-soft: #2E3D34;
  --paper: #E6EEE7;
  --muted: #A3B2A7;
  --faint: #7C8D81;
  --brass: #C8DC7A;
  --brass-hover: #D6E795;
  --up: #8FD6A6;
  --down: #F0A0A0;
  --tab-hover: #19221D;
  --danger-hover: #F5B5B5;
  --chip: rgba(230, 238, 231, .07);
  --body: #CFD9D1;
  --shadow: 4 8 6;
  --backdrop: 8 12 10;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

::selection { background: color-mix(in srgb, var(--brass) 38%, transparent); color: var(--paper); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- masthead ---------- */

.masthead {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px var(--gutter) 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  text-decoration: none;
  font: 500 21px/1 var(--mono);
  letter-spacing: -0.03em;
  border-radius: 6px;
}

.logo-mark {
  width: 26px;
  height: 20px;
  fill: none;
  stroke: var(--brass);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

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

/* Adding links, categories and tabs is only shown once editing is unlocked. */
body:not(.is-admin) .admin-only { display: none; }
.is-admin .visitor-only { display: none; }

/* Inbox button with its unread count. */
.inbox-btn { position: relative; }
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brass);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--ink);
  animation: badge-in .3s cubic-bezier(.3, 1.6, .5, 1);
}
.badge[hidden] { display: none; }
@keyframes badge-in { from { transform: scale(0); } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: none;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}

.btn:disabled { opacity: .5; cursor: default; }

.btn-primary { background: var(--brass); color: var(--ink); }
.btn-primary:not(:disabled):hover { background: var(--brass-hover); }

.btn-ghost { border-color: var(--line); color: var(--paper); }
.btn-ghost:not(:disabled):hover { background: var(--pill); }

.btn-danger { background: var(--down); color: var(--ink); }
.btn-danger:not(:disabled):hover { background: var(--danger-hover); }

.btn-icon {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  color: var(--faint);
}
.btn-icon:hover { color: var(--paper); background: var(--pill); }
.btn-icon.is-unlocked { color: var(--brass); border-color: color-mix(in srgb, var(--brass) 50%, var(--line)); }

.btn-small {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-quiet-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 35%, transparent); }
.btn-quiet-danger:hover { background: color-mix(in srgb, var(--down) 12%, transparent); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--faint);
}
.icon-btn:hover { color: var(--paper); background: var(--line-soft); }

.btn-round {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--brass);
  color: var(--ink);
}
.btn-round:hover { background: var(--brass-hover); }
.btn-round .i { width: 18px; height: 18px; stroke-width: 2.2; }

/* ---------- the folder ---------- */

.deck {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px var(--gutter) 72px;
}

.tabbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-bottom: -2px;
  padding: 6px 0 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.tab {
  --c: var(--line);
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 2px;
  padding: 10px 26px 9px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  border-radius: 10px 10px 0 0;
}

/* The tab shape: a trapezoid drawn behind the label. */
.tab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1.5px solid color-mix(in srgb, var(--c) 50%, transparent);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: var(--ink);
  transform: perspective(40px) rotateX(7deg);
  transform-origin: bottom;
  transition: background-color .15s;
}

.tab:hover { color: var(--paper); }
.tab:hover::before { background: var(--tab-hover); }

.tab-count {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.tab[aria-selected="true"] {
  margin-bottom: 0;
  padding-bottom: 11px;
  color: var(--paper);
}
.tab[aria-selected="true"]::before {
  background: var(--folder);
  border: 2px solid var(--c);
  border-bottom: 0;
}

.tab:focus-visible { outline-offset: -4px; }

.tab-add {
  padding: 10px 16px 9px;
  color: var(--faint);
}
.tab-add::before { border-style: dashed; border-color: var(--line); }

.folder {
  --c: var(--brass);
  position: relative;
  min-height: 55vh;
  padding: 34px 32px 40px;
  background: var(--folder);
  border: 1.5px solid color-mix(in srgb, var(--c) 30%, var(--line-soft));
  border-top: 2px solid var(--c);
  border-radius: 14px;
  box-shadow: 0 30px 60px -30px rgb(var(--shadow) / .55);
}
.folder:focus { outline: none; }

.folder-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: -14px 0 18px;
}
.folder-hint { font-size: 13px; color: var(--faint); }
.folder-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }
a.btn { text-decoration: none; }
.folder-actions .i { width: 14px; height: 14px; }

/* Reordering tabs while editing is unlocked. */
.is-admin .tabs .tab,
.is-admin .category-head,
.is-admin .pill {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tabs .tab.dragging {
  z-index: 3;
  cursor: grabbing;
  color: var(--paper);
  transform: translateY(-4px);
}
.tabs .tab.dragging::before {
  background: var(--pill-hover);
  border-color: var(--c);
  box-shadow: 0 12px 24px -10px rgb(var(--shadow) / .8);
}
.is-admin .pill-link { cursor: pointer; }

.pill.dragging {
  position: relative;
  z-index: 3;
  background: var(--pill-hover);
  border-color: var(--cat);
  box-shadow: 0 16px 32px -12px rgb(var(--shadow) / .85);
  transform: scale(1.02);
}

.category.dragging .category-head,
.category.dragging .category-links,
.category.dragging .category-empty {
  opacity: .55;
}
.category.dragging .category-head h2 { color: var(--cat); }

.is-sorting, .is-sorting * { cursor: grabbing !important; user-select: none; }

.columns {
  columns: 250px auto;
  column-gap: 36px;
}

.swap { animation: swap .22s ease-out; }
@keyframes swap { from { opacity: 0; transform: translateY(4px); } }

/* ---------- categories ---------- */

.category {
  --cat: var(--muted);
  break-inside: avoid;
  padding-bottom: 30px;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  margin-bottom: 10px;
}

.category-head .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--cat);
  flex: none;
}

.category-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-head .count {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.category-head .icon-btn { margin-left: auto; width: 28px; height: 28px; }
.category-head .cat-cog .i { width: 15px; height: 15px; }
.category-head .cat-cog:hover, .category-head .cat-cog[aria-expanded="true"] { color: var(--brass); }

.category-links {
  list-style: none;
  margin: 0 0 0 4px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid color-mix(in srgb, var(--cat) 55%, transparent);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.category-empty {
  margin-left: 4px;
  padding-left: 14px;
  border-left: 2px dashed color-mix(in srgb, var(--cat) 40%, transparent);
  color: var(--faint);
  font-size: 13px;
}

/* ---------- link pills ---------- */

/* Two rows: favicon + full link text, then the site and its actions. */
.pill {
  padding: 8px 6px 4px 8px;
  background: var(--pill);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  transition: background-color .15s, border-color .15s;
}
.pill:hover { background: var(--pill-hover); border-color: var(--line); }

.pill-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 4px 2px 0;
  color: var(--paper);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  border-radius: 8px;
}
.pill-link:hover .label { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--paper) 40%, transparent); text-underline-offset: 3px; }

.pill-link .label {
  min-width: 0;
  padding-top: 3px;
  overflow-wrap: anywhere;
}

.pill-meta {
  display: flex;
  align-items: center;
  gap: 1px;
  padding-left: 36px;
}

.flairs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}
.flair { display: grid; place-items: center; width: 22px; height: 22px; }
.flair .i { width: 14px; height: 14px; }

.flair-free { --f: var(--f-free); }
.flair-subscription { --f: var(--f-subscription); }
.flair-onetime { --f: var(--f-onetime); }
.flair-signup { --f: var(--f-signup); }
.flair-ads { --f: var(--f-ads); }
.flair-redirects { --f: var(--f-redirects); }
.flair, .legend-item .i, .card-flairs .i, .flair-opt .i { color: var(--f); }

/* Long-pressing a link shows its details card, not the browser's menu. */
.pill { -webkit-touch-callout: none; }
@media (hover: none) {
  .pill { user-select: none; -webkit-user-select: none; }
}

.fav {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--chip);
  overflow: hidden;
}
.fav img { width: 16px; height: 16px; display: block; }
.fav-letter {
  background: color-mix(in srgb, var(--cat) 28%, transparent);
  color: var(--paper);
  font-size: 11.5px;
  font-weight: 600;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 28px;
  height: 28px;
  padding: 0 5px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--faint);
  flex: none;
}
.pill-btn:hover { color: var(--paper); background: var(--line-soft); }
.pill-btn .i { width: 15px; height: 15px; }
.pill-btn .n { font-size: 11.5px; font-weight: 500; font-variant-numeric: tabular-nums; }

.vote.up[aria-pressed="true"] { color: var(--up); }
.vote.down[aria-pressed="true"] { color: var(--down); }
.vote[aria-pressed="true"] .i { fill: color-mix(in srgb, currentColor 22%, transparent); }

.pill-btn.cog[aria-expanded="true"], .pill-btn.cog:hover { color: var(--brass); }

/* ---------- link options menu ---------- */

.menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--folder);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--paper);
  box-shadow: 0 20px 50px -12px rgb(var(--shadow) / .7);
}
/* Separate rules: a browser that doesn't know :popover-open drops the whole rule. */
.menu:popover-open { display: grid; animation: rise .14s ease-out; }
.menu.is-open { display: grid; z-index: 30; animation: rise .14s ease-out; }
@supports not selector(:popover-open) {
  .menu:not(.is-open) { display: none; }
}
.menu-title { display: none; }
.menu button {
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  font-size: 14px;
}
.menu button:hover, .menu button:focus-visible { background: var(--pill); outline: none; }
.menu .menu-danger { color: var(--down); margin-top: 5px; position: relative; }
.menu .menu-danger::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: -3px;
  border-top: 1px solid var(--line-soft);
}

/* Phones: the menu becomes a sheet along the bottom with large targets. */
@media (max-width: 640px) {
  .menu {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: auto;
    max-height: 70dvh;
    overflow-y: auto;
    padding: 8px;
    border-radius: 16px;
  }
  .menu::backdrop { background: rgb(var(--backdrop) / .55); }
  .menu-title {
    display: block;
    padding: 8px 12px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .menu button { height: 48px; font-size: 15px; }
}

/* ---------- theme picker ---------- */

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

.theme-menu { min-width: 220px; }
.theme-menu button {
  display: flex;
  align-items: center;
  gap: 11px;
}
.theme-dots { display: inline-flex; flex: none; }
.theme-dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--folder);
}
.theme-dots span + span { margin-left: -4px; }
.theme-name { flex: 1; }
.theme-menu .check { width: 15px; height: 15px; color: var(--brass); visibility: hidden; }
.theme-menu button[aria-checked="true"] .check { visibility: visible; }
.theme-menu button[aria-checked="true"] { font-weight: 600; }

/* ---------- link details card ---------- */

.link-card {
  --cat: var(--line);
  position: fixed;
  z-index: 20;
  width: min(320px, calc(100vw - 16px));
  padding: 12px 14px 13px;
  background: var(--folder);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cat);
  border-radius: 12px;
  box-shadow: 0 20px 50px -12px rgb(var(--shadow) / .75);
  pointer-events: none;
  animation: rise .14s ease-out;
}
.link-card[hidden] { display: none; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head strong { font-size: 14.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.card-url {
  margin-top: 6px;
  font: 12px/1.45 var(--mono);
  color: var(--faint);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc { margin-top: 8px; font-size: 13.5px; color: var(--body); white-space: pre-line; overflow-wrap: anywhere; }
.card-flairs {
  list-style: none;
  margin: 10px 0 0;
  padding: 9px 0 0;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.card-flairs li { display: inline-flex; align-items: center; gap: 5px; }
.card-flairs .i { width: 14px; height: 14px; }

/* ---------- legend ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--muted);
}
.legend-title { font-weight: 500; color: var(--faint); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item .i { width: 14px; height: 14px; }

.rating {
  min-width: 30px;
  padding: 0 6px 0 2px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  flex: none;
}
.rating.pos { color: var(--up); }
.rating.neg { color: var(--down); }

.pill.fresh { animation: fresh 1.8s ease-out; }
@keyframes fresh {
  0%, 30% { box-shadow: 0 0 0 2px var(--cat); }
  100% { box-shadow: 0 0 0 2px transparent; }
}

/* ---------- empty and error states ---------- */

.empty {
  max-width: 420px;
  padding: 48px 4px 24px;
}
.empty h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 8px; }
.empty p { color: var(--muted); margin-bottom: 20px; }

.empty + .columns { margin-top: 24px; }

/* ---------- dialogs ---------- */

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--folder);
  color: var(--paper);
  box-shadow: 0 40px 90px -20px rgb(var(--shadow) / .7);
}
dialog.dlg-wide { width: min(520px, calc(100vw - 32px)); }
dialog[open] { animation: rise .2s ease-out; }
dialog::backdrop { background: rgb(var(--backdrop) / .66); backdrop-filter: blur(3px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 18px 4px 24px;
}
.dlg-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; padding-top: 3px; }

.dlg-body {
  display: grid;
  gap: 18px;
  padding: 16px 24px 4px;
}

.dlg-note { color: var(--muted); font-size: 14px; }

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 22px 24px 24px;
}

.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field label,
.field legend {
  display: block;
  padding: 0;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.counter.near { color: var(--brass); }
.optional { font-weight: 400; color: var(--faint); margin-left: 4px; }

.flair-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.flair-opt { position: relative; display: block; margin: 0 !important; cursor: pointer; }
.flair-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.flair-opt span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color .12s, border-color .12s, color .12s;
}
.flair-opt .i { width: 15px; height: 15px; }
.flair-opt:hover span { background: var(--pill); }
.flair-opt input:checked + span {
  color: var(--paper);
  border-color: color-mix(in srgb, var(--f) 70%, transparent);
  background: color-mix(in srgb, var(--f) 14%, transparent);
}
.flair-opt input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
textarea[name="description"] { min-height: 76px; }

input, select, textarea {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 112px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 22%, transparent);
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A0A6B3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.row { display: flex; gap: 8px; }
.row select { flex: 1; min-width: 0; }
.row .btn { height: 42px; }

.form-error { color: var(--down); font-size: 13.5px; }
.field-warning { margin-top: 7px; color: var(--down); font-size: 13px; }
.field-warning[hidden] { display: none; }
input.is-duplicate { border-color: var(--down); }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch-opt { position: relative; display: block; margin: 0 !important; cursor: pointer; }
.swatch-opt input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch-opt span {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--s);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  transition: box-shadow .12s;
}
.swatch-opt input:checked + span { box-shadow: 0 0 0 2px var(--folder), 0 0 0 4px var(--s); }
.swatch-opt input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 5px; }

.swatch-custom {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px dashed var(--faint);
  border-radius: 9px;
  background: conic-gradient(#7FB6F2, #9C8CF0, #E58FC4, #EE8A7A, #E9B460, #73CBA0, #7FB6F2);
  cursor: pointer;
  transition: none;
}
.swatch-custom::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-custom::-webkit-color-swatch { border: 0; border-radius: 8px; opacity: 0; }
.swatch-custom::-moz-color-swatch { border: 0; opacity: 0; }
.swatch-custom.selected { border: 0; box-shadow: 0 0 0 2px var(--folder), 0 0 0 4px var(--paper); }
.swatch-custom.selected::-webkit-color-swatch { opacity: 1; }
.swatch-custom.selected::-moz-color-swatch { opacity: 1; }

/* ---------- category list (in the Add category window) ---------- */

.cat-manage {
  padding: 18px 24px 20px;
  border-top: 1px solid var(--line-soft);
}
.cat-manage h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.cat-list {
  list-style: none;
  margin: 0 -8px;
  padding: 0;
  max-height: min(320px, 40vh);
  overflow-y: auto;
}
.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 4px 0 10px;
  border-radius: 10px;
}
.cat-row:hover { background: var(--pill); }
.cat-row.is-editing { background: var(--pill); box-shadow: inset 2px 0 0 var(--cat); }
.cat-row .swatch {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 3px;
  background: var(--cat);
}
.cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}
.cat-count { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.cat-row .icon-btn { width: 30px; height: 30px; }
.cat-row .icon-btn .i { width: 15px; height: 15px; }
.cat-row .del:hover { color: var(--down); }

@media (max-width: 640px) {
  .cat-manage { padding-left: 20px; padding-right: 20px; }
}

/* ---------- suggest a link ---------- */

.dlg-suggest { transition: border-color .4s, background-color .4s; }
.sealed { display: none; }

.dlg-suggest.is-sealed {
  border-color: color-mix(in srgb, var(--up) 70%, transparent);
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--up) 16%, transparent), transparent 65%),
    var(--folder);
  animation: sealed-pulse 1.1s ease-out .25s 2;
}
.dlg-suggest.is-sealed form { display: none; }
.dlg-suggest.is-sealed .sealed {
  display: grid;
  justify-items: center;
  padding: 46px 24px 44px;
  text-align: center;
}
@keyframes sealed-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 45%, transparent), 0 40px 90px -20px rgb(var(--shadow) / .7); }
  100% { box-shadow: 0 0 0 26px transparent, 0 40px 90px -20px rgb(var(--shadow) / .7); }
}

/* The lock: the body pops in, the shackle drops shut, the check draws on. */
.seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--up) 14%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--up) 55%, transparent);
  animation: seal-pop .45s cubic-bezier(.3, 1.5, .5, 1) both;
}
.seal::before, .seal::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--up);
  opacity: 0;
  animation: seal-ring 1.2s ease-out .55s 2;
}
.seal::after { animation-delay: .85s; }
.seal svg {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: var(--up);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.seal-body { fill: color-mix(in srgb, var(--up) 18%, transparent); }
.seal-shackle {
  transform-box: view-box;
  transform-origin: 32px 22px;
  animation: shackle-shut .38s cubic-bezier(.5, 0, .4, 1.6) .3s both;
}
.seal-check { stroke-dasharray: 20; stroke-dashoffset: 20; animation: check-draw .3s ease-out .7s forwards; }

@keyframes seal-pop { from { transform: scale(.4); opacity: 0; } }
@keyframes seal-ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.7); opacity: 0; } }
@keyframes shackle-shut { from { transform: translateY(-7px) rotate(-14deg); } }
@keyframes check-draw { to { stroke-dashoffset: 0; } }

.sealed-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  animation: rise .35s ease-out .55s both;
}
.sealed-text { margin-top: 4px; color: var(--muted); font-size: 14px; animation: rise .35s ease-out .7s both; }

/* With reduced motion the window still shows the end state: no animation,
   but the check must be drawn. */
@media (prefers-reduced-motion: reduce) {
  .seal-check { stroke-dashoffset: 0; }
}

/* ---------- suggestions inbox ---------- */

.inbox-sub { color: var(--faint); font-size: 13px; margin-top: 2px; }
.inbox-list {
  max-height: min(62vh, 560px);
  overflow-y: auto;
  margin-top: 14px;
  padding: 0 24px 6px;
  border-top: 1px solid var(--line-soft);
}
.suggestion { padding: 16px 0; transition: opacity .2s; }
.suggestion + .suggestion { border-top: 1px solid var(--line-soft); }
.suggestion.is-leaving { opacity: .35; pointer-events: none; }
.suggestion header { display: flex; align-items: flex-start; gap: 11px; }
.suggestion .fav { --cat: var(--brass); margin-top: 1px; }
.s-where { flex: 1; min-width: 0; }
.s-host {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--paper);
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
  border-radius: 4px;
}
.s-host:hover { text-decoration: underline; text-underline-offset: 3px; }
.s-host .i { width: 13px; height: 13px; color: var(--faint); }
.s-url { font: 12px/1.45 var(--mono); color: var(--faint); overflow-wrap: anywhere; margin-top: 2px; }
.suggestion .c-time { padding-top: 2px; }
.s-note {
  margin: 10px 0 0 37px;
  padding: 9px 12px;
  background: var(--ink);
  border-radius: 10px;
  font-size: 14px;
}
.s-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.s-actions .i { width: 14px; height: 14px; }

@media (max-width: 640px) {
  .inbox-list { padding: 0 20px 6px; }
  .s-note { margin-left: 0; }
}

/* ---------- comments ---------- */

.comments-heading { min-width: 0; }
.comments-heading h2 { overflow-wrap: anywhere; }
#comments-host { color: var(--faint); font-size: 13px; margin-top: 2px; }

.comments-list {
  max-height: min(52vh, 460px);
  overflow-y: auto;
  margin-top: 14px;
  padding: 0 24px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.comment { padding: 16px 0; }
.comment + .comment { border-top: 1px solid var(--line-soft); }
.comment header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.c-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.c-time { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.comment header .icon-btn { margin-left: auto; width: 26px; height: 26px; align-self: center; }
.c-body { color: var(--body); font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

.comments-empty { padding: 30px 0; color: var(--muted); }
.comments-empty strong { display: block; color: var(--paper); font-weight: 600; margin-bottom: 2px; }

.comments-foot { justify-content: space-between; align-items: center; padding-top: 16px; padding-bottom: 18px; }
#comments-count { color: var(--faint); font-size: 13px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 16px 40px -12px rgb(var(--shadow) / .7);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--down); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .masthead { padding-top: 20px; }
  .is-admin .actions { width: 100%; }
  .actions .btn-ghost, .actions .btn-primary { flex: 1; }
  .deck { padding-top: 28px; }
  .tabbar { padding-left: 8px; }
  .tab { padding-left: 20px; padding-right: 20px; }
  .folder { padding: 26px 16px 28px; border-radius: 12px; }
  .row { flex-direction: column; }
  .row select { flex: none; }
  .dlg-head { padding-left: 20px; }
  .dlg-body { padding-left: 20px; padding-right: 20px; }
  .dlg-foot { padding-left: 20px; padding-right: 20px; }
  .comments-list { padding: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
