:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #222b22;
  background: #f7f5ed;
  --green: #254e36;
  --muted: #556153;
  --border: #dfdfd2;
  --paper: #fffef9;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; }
@font-face {
  font-family: Rajdhani;
  src: url("./fonts/Rajdhani-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Rajdhani;
  src: url("./fonts/Rajdhani-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Everything3D;
  src: url("./fonts/Everything3d-Regular.otf") format("opentype");
  font-display: swap;
}
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font: .8rem Rajdhani, system-ui, sans-serif; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding-block: 7px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
.site-footer a { color: inherit; text-underline-offset: 2px; }
#footer-donate { display: none; }
@media (display-mode: browser) {
  .site-footer .wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px 8px; }
  .site-footer .wrap > :last-child { text-align: end; }
  #footer-donate { display: inline; }
}
@media (display-mode: browser) and (max-width: 480px) {
  .site-footer .wrap { grid-template-columns: 1fr 1fr; gap: 5px 12px; }
  .site-footer .wrap > :first-child { justify-self: end; }
  #footer-donate { justify-self: start; }
  .site-footer .wrap > :last-child { grid-column: 1 / -1; text-align: center; }
}
.board, .board-row { scrollbar-width: none; }
.board::-webkit-scrollbar, .board-row::-webkit-scrollbar { display: none; }
#board-scroll-wrap { display: none; }
@media (min-width: 651px) and (pointer: fine) {
  .board .board-row { scroll-snap-type: none; }
  .bottom-bar:has(#board-scroll-wrap:not([hidden])) {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--paper);
  }
  #board-scroll-wrap:not([hidden]) { display: flex; align-items: center; height: 22px; }
  #board-scroll-wrap #board-scroll {
    appearance: none;
    cursor: ew-resize;
    width: 100%;
    min-height: 0;
    height: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: var(--header);
  }
  #board-scroll::-webkit-slider-thumb {
    appearance: none;
    width: max(24px, var(--scroll-thumb, 25%));
    height: 12px;
    border-radius: 6px;
    background: var(--muted);
  }
  #board-scroll::-moz-range-thumb {
    width: max(24px, var(--scroll-thumb, 25%));
    height: 12px;
    border: 0;
    border-radius: 6px;
    background: var(--muted);
  }
}
.footer-powered-label { font-size: .65rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.footer-brand { font: 1.1rem/1 Everything3D, Rajdhani, sans-serif; letter-spacing: .02em; }
.wrap { width: calc(100% - 40px); margin-inline: auto; }
.top { border-bottom: 1px solid var(--border); }
.top-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "brand title actions settings" "groups groups groups groups";
  align-items: center;
  gap: 8px 12px;
  padding-block: 10px;
}
.brand { grid-area: brand; display: flex; align-items: center; font-family: Georgia, serif; font-size: 26px; font-weight: bold; }
.brand-logo { margin-right: 10px; }
.local { font-size: .78rem; color: var(--muted); font-weight: 650; display: flex; gap: 7px; align-items: center; }
.local span { width: 8px; height: 8px; border-radius: 50%; background: #508457; }
h1, h2, p { margin: 0; }
dialog p { color: var(--muted); line-height: 1.55; }
.toolbar { display: contents; }
.toolbar-title { grid-area: title; }
.toolbar .actions { grid-area: actions; }
.settings { grid-area: settings; position: relative; justify-self: end; }
.settings summary { display: grid; place-items: center; list-style: none; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.settings summary::-webkit-details-marker { display: none; }
.toolbar .actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.toolbar h1, dialog h2 { font: 700 1.55rem Georgia, serif; }
#summary, #summary-compact, .count { color: var(--muted); font-size: .82rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button, input { font: inherit; }
button { cursor: pointer; min-height: 44px; padding: 8px 14px; border: 1px solid transparent; border-radius: 10px; font-size: .88rem; font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--green); color: white; }
.secondary { color: var(--green); background: var(--paper); border-color: var(--border); }
button:hover:enabled { filter: brightness(.94); }
:focus-visible { outline: 3px solid #8c682b; outline-offset: 3px; }
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 18px; padding-bottom: 12px; }
.board.grouped-board {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
}
.board-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(320px, 85%);
  align-items: start;
  justify-content: start;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.board-group { min-width: 0; }
.grouped-board > .board-group { flex: none; width: 44px; }
.grouped-board > .board-group[open] { width: max-content; min-width: min(320px, 82vw); }
.grouped-board > .card { flex: 0 0 min(320px, 82vw); margin-top: 42px; }
.grouped-board.organizing { gap: 6px; }
.standalone-drop-slot {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  align-self: stretch;
  min-height: 110px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
}
.standalone-drop-slot[data-drop-preview] { background: var(--header); color: var(--green); }
.board-group > .board-row { margin-top: 8px; }
.grouped-board .board-row { grid-auto-columns: min(320px, 82vw); overflow: visible; }
.group-heading { cursor: pointer; border: 1px solid var(--border); border-radius: 8px; height: 34px; padding: 0 8px; line-height: 32px; background: var(--header); font-size: .88rem; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-heading .move-list { float: right; min-width: 34px; min-height: 32px; padding: 0; }
.group-heading .count { margin-inline-start: .55em; }
.board-group:not([open]) > .group-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: auto;
  padding: 8px 4px;
  line-height: 1.2;
}
.board-group:not([open]) > .group-heading::after { content: '›'; }
.board-group:not([open]) > .group-heading > .group-name {
  writing-mode: vertical-rl;
  max-height: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-group:not([open]) > .group-heading .count { margin-inline-start: 0; }
.move-list { cursor: grab; touch-action: none; user-select: none; -webkit-touch-callout: none; }
.board:not(.organizing) .move-list { display: none; }
.board:not(.organizing) .remove-group { display: none; }
.group-heading .remove-group { float: right; min-width: 32px; min-height: 32px; padding: 0; }
#organize-toggle { white-space: nowrap; }
.move-list:active { cursor: grabbing; }
[data-drop-preview="before"]:not(.board-group) { box-shadow: inset 4px 0 var(--accent); }
[data-drop-preview="after"]:not(.board-group) { box-shadow: inset -4px 0 var(--accent); }
[data-drop-preview="inside"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.board-group[data-drop-preview="before"] > .group-heading { box-shadow: inset 4px 0 var(--accent); }
.board-group[data-drop-preview="after"] > .group-heading { box-shadow: inset -4px 0 var(--accent); }
.touch-dragging .board-row { scroll-snap-type: none; }
.touch-drag-source { opacity: .5; }
.touch-drag-label {
  position: fixed; inset: 0 auto auto 0; z-index: 10; pointer-events: none;
  translate: -50% calc(-100% - 14px); max-width: 70vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--accent);
  border-radius: 8px; padding: 6px 10px; background: var(--paper); font-size: .85rem;
}
.card { scroll-snap-align: start; }
.card { min-width: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--paper); overflow: hidden; box-shadow: 0 3px 9px #252e1c08; }
.card-head { padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 6px; background: #e9efdf; }
.card h2 { font: 700 1.3rem Georgia, serif; overflow-wrap: anywhere; }
.card-title { background: transparent; color: inherit; font: inherit; min-height: 0; padding: 3px 0; text-align: start; overflow-wrap: anywhere; }
button.card-title, button.group-name { text-decoration: underline dotted; text-underline-offset: 4px; }
button.group-name { background: transparent; color: inherit; min-height: 0; padding: 0; font: inherit; }
.card-tools svg { vertical-align: middle; }
.card-tools { display: flex; flex-shrink: 0; }
.icon { background: transparent; color: var(--green); font-size: 1.15rem; min-width: 44px; padding: 4px; }
.items { padding: 0; list-style: none; margin: 0 14px; }
.items li { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--border); }
.items .move-list { min-width: 28px; }
.items li[data-drop-preview="above"] { box-shadow: inset 0 3px var(--accent); }
.items li[data-drop-preview="below"] { box-shadow: inset 0 -3px var(--accent); }
.items label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 46px; cursor: pointer; overflow-wrap: anywhere; }
.items input { accent-color: var(--green); width: 19px; height: 19px; flex: none; }
.items input:checked + span { text-decoration: line-through; color: var(--muted); }
.item-form { display: flex; gap: 8px; padding: 14px; }
input:not([type=checkbox]) { width: 100%; min-width: 0; min-height: 44px; background: white; color: inherit; border: 1px solid var(--border); padding: 8px 11px; border-radius: 8px; }
.empty { color: var(--muted); padding: 16px 16px 0; font-size: .9rem; }
#status:not(:empty) { margin-top: 14px; }
dialog { width: min(430px, calc(100% - 32px)); max-height: 85vh; color: inherit; padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--paper); }
#help-dialog { width: min(560px, calc(100% - 32px)); }
#help-dialog h3 { margin: 18px 0 0; font-size: 1rem; }
#help-dialog p { margin-top: 8px; }
dialog::backdrop { background: #18291ca0; }
dialog p, dialog label, dialog .actions { margin-top: 14px; }
dialog label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 700; }
dialog .actions { justify-content: end; }
#import-preview { overflow-wrap: anywhere; padding-left: 20px; }
:root {
  --header: #e9efdf;
  --field: #fff;
  --accent: #356947;
}
.card-head { background: var(--header); }
input:not([type=checkbox]) { background: var(--field); }
.chrome-stack, .lang-switcher, .theme-switcher { display: flex; align-items: center; gap: 4px; }
.chrome-stack {
  position: absolute; z-index: 2; inset-inline-end: 0; top: calc(100% + 8px);
  flex-direction: column; gap: 8px; padding: 10px; background: var(--paper);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 20px #0002;
}
.lang-switcher, .theme-switcher { border: 1px solid var(--border); background: var(--paper); padding: 3px; border-radius: 12px; }
.lang-btn, .theme-btn { display: grid; place-items: center; width: 40px; min-height: 40px; padding: 4px; background: transparent; color: var(--green); border-radius: 8px; }
.lang-btn[aria-pressed=true], .theme-btn[aria-pressed=true] { border-color: var(--accent); background: var(--header); }
.lang-flag svg { display: block; width: 24px; height: auto; }
.theme-btn svg { display: block; width: 19px; height: 19px; }

:root[data-theme=dark] {
  color-scheme: dark;
  color: #f5f5f5;
  background: #141414;
  --green: #b1edc1;
  --muted: #c6c6c6;
  --border: #858585;
  --paper: #242424;
  --header: #383838;
  --field: #1a1a1a;
  --accent: #b1edc1;
}
:root[data-theme=dark] .primary { color: #102417; }
:root[data-theme=dark] :is(.secondary, .icon, .lang-btn, .theme-btn) { color: inherit; }
:root[data-theme=dark] dialog::backdrop { background: #000b; }
:root[data-theme=dark] input::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme=dark] :focus-visible { outline-color: #ffe093; }
:root[data-theme=dark] button:disabled { opacity: 1; color: var(--muted); }
:root[data-theme=dark] .primary:disabled { background: var(--header); }

@media (max-width: 480px) {
  .toolbar .actions { flex: none; flex-wrap: nowrap; }
  .toolbar .actions button { width: 44px; padding: 0; font-size: 1.2rem; }
  .toolbar .toolbar-label { display: none; }
  .card-tools .icon { min-width: 36px; }
  .top-inner { width: calc(100% - 24px); gap: 8px; }
  .brand img { width: 38px; height: 38px; }
  .brand-logo { margin-right: 0; }
  .lang-switcher, .theme-switcher { gap: 2px; padding: 2px; }
  .lang-btn, .theme-btn { width: clamp(28px, 11vw, 36px); min-height: 40px; }
}

#help { min-width: 36px; }
#sync-dialog textarea, #sync-list, #list-color, #group-color, #list-group, #group-view, #move-form select {
  width: 100%; padding: 8px; color: inherit; background: var(--field);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
#sync-dialog canvas, #sync-camera { max-width: 100%; height: auto !important; margin: 12px auto 0; }
#sync-dialog canvas:not([hidden]), #sync-camera:not([hidden]) { display: block; }
@media (max-width: 480px) {
  #help { min-width: 28px; }
  .lang-btn, .theme-btn { width: clamp(26px, 10vw, 34px); }
  .toolbar .actions { gap: 5px; }
  .toolbar h1 { font-size: 1.3rem; }
}

:is(.card[data-color=blue], .board-group[data-color=blue] > .group-heading) { --header: #dcebf8; }
:is(.card[data-color=purple], .board-group[data-color=purple] > .group-heading) { --header: #ebe2f6; }
:is(.card[data-color=rose], .board-group[data-color=rose] > .group-heading) { --header: #f7e1e6; }
:is(.card[data-color=amber], .board-group[data-color=amber] > .group-heading) { --header: #f5e9ce; }
:root[data-theme=dark] :is(.card[data-color=blue], .board-group[data-color=blue] > .group-heading) { --header: #194b83; --color-edge: #69b3ff; }
:root[data-theme=dark] :is(.card[data-color=purple], .board-group[data-color=purple] > .group-heading) { --header: #563579; --color-edge: #c39aff; }
:root[data-theme=dark] :is(.card[data-color=rose], .board-group[data-color=rose] > .group-heading) { --header: #792c50; --color-edge: #ff8fb7; }
:root[data-theme=dark] :is(.card[data-color=amber], .board-group[data-color=amber] > .group-heading) { --header: #654510; --color-edge: #ffc361; }

#sync.sync-connected { border-color: var(--accent); background: var(--header); }
#sync-status { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: inherit; }
#sync-status[data-kind="progress"], #sync-status[data-kind="success"] { border-color: var(--accent); background: var(--header); }
#sync-status[data-kind="error"], #sync-status[data-kind="warning"] { border-color: currentColor; font-weight: 650; }
#sync-start h3, #sync-form h3 { margin: 18px 0 0; font-size: .95rem; }
#sync-start:not([hidden]) + #sync-output[hidden] + #sync-form:not([hidden]) { border-top: 1px solid var(--border); margin-top: 16px; }
#sync-dialog [hidden] { display: none; }

#code-form { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--border); }
#code-status:empty { display: none; }

.group-bar { grid-area: groups; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.group-bar label { font-size: .88rem; font-weight: 700; }
#group-view { width: auto; max-width: 100%; min-width: 0; min-height: 44px; }
#group-status:empty { display: none; }

#summary-compact, .group-icon { display: none; }

@media (min-width: 651px) {
  .top-inner {
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "brand title groups actions settings";
  }
  .toolbar .actions { justify-self: end; }
  .group-bar { flex-wrap: nowrap; }
  #group-view { max-width: 160px; }
}

@media (max-width: 1150px) {
  .group-bar { flex-wrap: nowrap; min-width: 0; }
  .group-bar button, .toolbar .actions button { flex: none; width: 44px; padding: 0; }
  .group-icon { display: inline-block; vertical-align: middle; }
  .group-button-label, .toolbar .toolbar-label { display: none; }
  .toolbar .actions { flex-wrap: nowrap; }
  #group-view { flex: 1; }
}

@media (max-width: 850px) {
  .top-inner { width: calc(100% - 24px); gap: 4px 8px; }
  .brand img { width: 38px; height: 38px; }
  .brand-logo { margin-right: 0; }
  .toolbar h1 { font-size: 1rem; line-height: 1.1; }
  #summary, .group-bar label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  #summary-compact { display: inline; font-size: .75rem; }
  .group-bar { gap: 5px; }
  .group-bar button { width: 36px; }
  #group-view { max-width: 120px; padding: 4px 6px; font-size: .82rem; }
}

@media (max-width: 650px) {
  .top-inner {
    grid-template-columns: minmax(84px, auto) minmax(0, 1fr) auto;
    grid-template-areas: "brand actions settings" "title groups groups";
    padding-block: 4px;
  }
  .toolbar .actions { justify-self: end; gap: 4px; }
  .group-bar { justify-content: flex-end; }
  #group-view { max-width: 160px; }
  .board { margin-top: 8px; }
  .board-row { gap: 10px; }
  .card-head { padding: 6px 10px; }
  .card h2 { font-size: 1.12rem; }
  .count { font-size: .75rem; }
}

#sync-pairings h3 { margin: 16px 0 6px; font-size: .9rem; }
#sync-pairings-summary { margin: 0 0 8px; font-size: .85rem; }
#sync-pairing-rows, .sync-session-list { padding: 0; margin: 0; list-style: none; }
#sync-pairing-rows > li { border-top: 1px solid var(--border); padding: 10px 0; }
#sync-pairing-rows h4 { margin: 0 0 4px; font-size: .9rem; overflow-wrap: anywhere; }
.sync-session-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 4px 0; }
.sync-session-list li > div { flex: 1 1 145px; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; }
.sync-session-list span { display: block; color: var(--muted); }

.card[data-color=custom], .board-group[data-color=custom] > .group-heading {
  --header: color-mix(in srgb, var(--custom-color) 32%, var(--paper));
}
:root[data-theme=dark] :is(.card[data-color=custom], .board-group[data-color=custom] > .group-heading) {
  --header: color-mix(in srgb, var(--custom-color) 34%, #181818);
  --color-edge: var(--custom-color);
}
:root[data-theme=dark] :is(.card[data-color]:not([data-color=default]) > .card-head,
  .board-group[data-color]:not([data-color=default]) > .group-heading) {
  --muted: #eeeeee;
  border-inline-start: 3px solid var(--color-edge);
}
.color-picker { display: grid; gap: 10px; margin: 10px 0; }
.color-picker[hidden] { display: none; }
.color-plane {
  position: relative;
  height: 132px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(transparent, black), linear-gradient(to right, white, transparent),
    hsl(var(--picker-hue) 100% 50%);
  cursor: crosshair;
  touch-action: none;
}
.color-plane span {
  position: absolute;
  top: var(--picker-y);
  left: var(--picker-x);
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #111;
  pointer-events: none;
}
.color-picker input.color-hue {
  appearance: none;
  min-height: 24px;
  margin: 0;
  padding: 0;
  background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red);
  border-radius: 999px;
  cursor: pointer;
}
.color-hue::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: white; border: 2px solid #222; }
.color-hue::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: white; border: 2px solid #222; }
.color-hex-row { display: flex; align-items: end; gap: 10px; }
.color-hex-row label { flex: 1; }
.color-preview { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 8px; }

#sync-copy-feedback { margin: 0; }
#sync-copy-feedback:not(:empty) { margin-top: 8px; }

.brand-logo { position: relative; display: inline-grid; }
.brand-logo.nerdcircle::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  padding: 3px;
  pointer-events: none;
  background: conic-gradient(
    var(--nerdcircle-direct, #888b8b) 0 25%,
    var(--nerdcircle-server, #888b8b) 25% 50%,
    var(--nerdcircle-download, #888b8b) 50% 100%
  );
  mask: linear-gradient(#fff 0 0) content-box exclude, linear-gradient(#fff 0 0);
}
.brand-logo.upload-direct { --nerdcircle-direct: #ff7200; }
.brand-logo.upload-server { --nerdcircle-server: #ffdf00; }
.brand-logo.download { --nerdcircle-download: #31e943; }
.nerdcircle-setting { display: flex; gap: 8px; align-items: center; }
