/* ==========================================================================
   OnePage — infinite quick-notes board
   ========================================================================== */

:root {
  --bg:        #0e1116;
  --bg-2:      #141922;
  --panel:     #191f2a;
  --panel-2:   #202836;
  --line:      #2a3242;
  --line-2:    #374154;
  --text:      #e7ebf2;
  --muted:     #97a2b6;
  --accent:    #6ea8fe;
  --accent-2:  #8b5cf6;
  --danger:    #f87171;
  --ok:        #4ade80;
  --warn:      #fbbf24;

  --c-yellow: #ffdf6b;
  --c-pink:   #ff9fb0;
  --c-green:  #a6e3a1;
  --c-blue:   #9ed2f7;
  --c-violet: #c9b0f5;
  --c-orange: #ffc08a;
  --c-grey:   #d9dee6;

  --note-ink: #2c2a1f;

  --radius:   10px;
  --radius-s: 7px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.45);
  --shadow-2: 0 10px 30px rgba(0,0,0,.5);
  --topbar-h: 52px;
  --status-h: 30px;
  --col-w:    280px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg:        #eef1f6;
  --bg-2:      #e4e9f1;
  --panel:     #ffffff;
  --panel-2:   #f5f7fb;
  --line:      #d5dbe6;
  --line-2:    #bfc8d6;
  --text:      #1a2030;
  --muted:     #5d6b80;
  --accent:    #2563eb;
  --accent-2:  #7c3aed;
  --danger:    #dc2626;
  --ok:        #16a34a;
  --shadow-1: 0 1px 2px rgba(20,30,50,.10);
  --shadow-2: 0 10px 30px rgba(20,30,50,.14);
  --note-ink: #2c2a1f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ── scrollbars ─────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 7px; font-weight: 650; letter-spacing: .2px; }
.brand-mark { font-size: 16px; line-height: 1; }
.brand-name { white-space: nowrap; }

.search-wrap {
  position: relative;
  flex: 1 1 240px;
  max-width: 460px;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 10px; font-size: 13px; color: var(--muted); pointer-events: none;
}
#search {
  width: 100%;
  height: 32px;
  padding: 0 60px 0 29px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
#search::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.search-count {
  position: absolute; right: 10px;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.color-filter { display: flex; gap: 4px; }
.color-filter .sw {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; background: var(--sw);
  box-shadow: var(--shadow-1);
  transition: transform .1s, box-shadow .1s;
}
.color-filter .sw:hover { transform: scale(1.18); }
.color-filter .sw[aria-pressed="true"] { border-color: var(--text); transform: scale(1.12); }

.topbar-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, transform .06s;
}
.btn:hover { background: color-mix(in srgb, var(--panel-2) 70%, var(--text) 8%); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #08111f; font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); min-width: 46px; font-variant-numeric: tabular-nums; }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-icon { width: 30px; padding: 0; font-size: 15px; }
.btn-sm { height: 25px; padding: 0 10px; font-size: 12px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0;
  background: transparent; border: 0; border-radius: 5px;
  color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 12%, transparent); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

kbd {
  display: inline-block;
  min-width: 18px; padding: 1px 5px;
  font: 600 11px/1.5 var(--mono);
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
}

.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font-size: 12px; display: inline-flex; gap: 5px; align-items: center;
}
.link-btn:hover { color: var(--text); }

/* ==========================================================================
   Stage / infinite board
   ========================================================================== */
.stage {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background-color: var(--bg);
  cursor: grab;
  outline: none;
  contain: strict;
}
.stage.grabbing { cursor: grabbing; }
.stage.grid-on {
  background-image: radial-gradient(circle at 1px 1px, var(--line-2) 1px, transparent 0);
  background-size: 26px 26px;
}

.world {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.columns { position: absolute; top: 0; left: 0; }
.blocks  { position: absolute; top: 0; left: 0; }

/* ==========================================================================
   Column
   ========================================================================== */
.column {
  position: absolute;
  width: var(--col-w);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - var(--status-h) - 60px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}

.column.dragging { opacity: .55; }
.column.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow-2); }

.column-head {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 8px 7px 6px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
/* one handle shape for everything you drag: columns, notes, blocks */
.grip {
  cursor: grab;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: -1px;
  user-select: none;
  opacity: .55;
  padding: 0 2px;
}
.grip:hover { opacity: 1; }
.grip:active { cursor: grabbing; }

.col-title {
  flex: 1 1 auto; min-width: 0;
  height: 24px; padding: 0 6px;
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  font-weight: 600; font-size: 13px;
  outline: none;
}
.col-title:hover { background: var(--bg-2); }
.col-title:focus { background: var(--bg-2); border-color: var(--accent); }

.col-count {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--bg-2); border-radius: 999px; padding: 1px 7px;
}

.column-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 44px;
}

.column-foot { flex: 0 0 auto; padding: 6px 8px 8px; border-top: 1px solid var(--line); }
.quick-add {
  display: block;
  width: 100%; min-height: 28px; max-height: 140px;
  padding: 5px 9px;
  background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: var(--radius-s);
  outline: none; font-size: 12.5px; font-family: inherit; line-height: 1.4;
  resize: none; overflow-y: auto;
}
.quick-add::placeholder { color: var(--muted); }
.quick-add:focus { border-style: solid; border-color: var(--accent); }

/* ==========================================================================
   Note (sticky)
   ========================================================================== */
.note {
  position: relative;
  background: var(--note-bg, var(--c-yellow));
  color: var(--note-ink);
  border-radius: 5px;
  padding: 7px 9px 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.28), 0 3px 8px rgba(0,0,0,.14);
  cursor: grab;
  transition: transform .1s, box-shadow .12s, opacity .12s;
  border: 1px solid rgba(0,0,0,.10);
}
[data-theme="dark"] .note { box-shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 16px rgba(0,0,0,.4); }
.note:hover { transform: translateY(-1px); box-shadow: 0 3px 6px rgba(0,0,0,.3), 0 10px 22px rgba(0,0,0,.22); }
.note.dragging { opacity: .4; cursor: grabbing; }
.note.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.note.dimmed { opacity: .22; }
.note.tilted { transform: rotate(var(--tilt, 0deg)); }
.note.tilted:hover { transform: rotate(var(--tilt, 0deg)) translateY(-1px); }

.note-tools {
  display: flex; align-items: flex-start; gap: 1px;
  height: 22px;                 /* a blank line of its own above the text */
  margin: -4px -5px 1px 0;
  opacity: 0;
  transition: opacity .12s;
}
.note:hover .note-tools, .note:focus-within .note-tools, .note.selected .note-tools { opacity: 1; }
.note-tools .icon-btn { color: rgba(0,0,0,.5); }
.note-tools .icon-btn:hover { background: rgba(0,0,0,.12); color: rgba(0,0,0,.85); }

/* the empty part of that line is the handle you grab a note with */
.note-grip {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 24px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: flex-end;   /* the dots sit at the top right of the note */
  padding-right: 4px;
  color: rgba(0,0,0,.45);
  font-size: 12px;
  line-height: 1;
  letter-spacing: -1px;
  user-select: none;
}
.note-grip:active { cursor: grabbing; }

.note-text {
  display: block;
  width: 100%;
  border: 0; outline: none; resize: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.42;
  color: inherit;
  font-family: inherit;
  overflow: hidden;
  min-height: 19px;
  word-break: break-word;
}
.note-text::placeholder { color: rgba(0,0,0,.35); }

.note-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.note:hover .note-foot, .note:focus-within .note-foot, .note.selected .note-foot { opacity: 1; }
.note-swatches { display: flex; gap: 3px; }
.note-swatches .sw {
  width: 11px; height: 11px; border-radius: 50%; border: 0; padding: 0;
  background: var(--sw); cursor: pointer; opacity: .55;
  transition: opacity .1s, transform .1s;
}
.note-swatches .sw:hover { opacity: 1; transform: scale(1.25); }
.note-swatches .sw[aria-pressed="true"] { opacity: 1; box-shadow: 0 0 0 1.5px var(--note-ink); }
.note-time { font-size: 10px; color: rgba(0,0,0,.42); margin-left: auto; white-space: nowrap; }

.note.c-yellow { --note-bg: var(--c-yellow); }
.note.c-pink   { --note-bg: var(--c-pink); }
.note.c-green  { --note-bg: var(--c-green); }
.note.c-blue   { --note-bg: var(--c-blue); }
.note.c-violet { --note-bg: var(--c-violet); }
.note.c-orange { --note-bg: var(--c-orange); }
.note.c-grey   { --note-bg: var(--c-grey); }

/* ==========================================================================
   Block (clock, date, stopwatch)
   ========================================================================== */
.block {
  position: absolute;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.block.dragging { opacity: .55; }

.block-head {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 5px 5px 3px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.block-grip { padding: 1px 3px; }
.block-title {
  flex: 1 1 auto;
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.block-body { padding: 10px 14px 12px; min-height: 68px; }
.block-time {
  font: 600 28px/1.15 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.block-lead {
  display: block;
  font-size: 19px;
  line-height: 1.25;
  font-weight: 650;
  color: var(--text);
}
.block-sub {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 2px;
}
.block-timer-row { display: flex; gap: 6px; margin: 8px 0 4px; }
.block-progress {
  height: 4px;
  margin: 7px 0 4px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
}
.block-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .4s linear;
}

/* ==========================================================================
   Empty state / hints
   ========================================================================== */
.empty-hint {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  z-index: 5;
}
.empty-hint[hidden] { display: none; }
.empty-card {
  pointer-events: auto;
  text-align: center;
  max-width: 380px;
  padding: 28px 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
}
.empty-card h1 { margin: 0 0 6px; font-size: 19px; }
.empty-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; }
.empty-hint-foot { margin-top: 16px !important; font-size: 12px !important; }

.stage-hint {
  position: absolute; right: 12px; bottom: 12px;
  font-size: 11px; color: var(--muted);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  pointer-events: none;
  z-index: 6;
  opacity: .75;
}
.stage-hint kbd { font-size: 10px; padding: 0 4px; }

/* ==========================================================================
   Status bar
   ========================================================================== */
.statusbar {
  height: var(--status-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
  z-index: 40;
}
.spacer { flex: 1 1 auto; }
.status-text { white-space: nowrap; }
.status-saved.saving { color: var(--warn); }
.status-saved.error { color: var(--danger); }
.status-saved.ok { color: var(--ok); }
.muted { opacity: .7; }

.pill {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  cursor: pointer;
  color: var(--text);
  font-size: 11px;
}
.pill:hover { border-color: var(--accent); }
.pill-static { cursor: default; }
.pill-static:hover { border-color: var(--line); }

/* ==========================================================================
   Dialogs
   ========================================================================== */
.dlg {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow-2);
}
.dlg::backdrop { background: rgba(4,8,15,.6); backdrop-filter: blur(2px); }
.dlg-body { padding: 0; margin: 0; }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.dlg-head h2 { margin: 0; font-size: 15px; }
.dlg-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dlg-section:last-child { border-bottom: 0; }
.dlg-section h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

.field { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.field > span { flex: 0 0 145px; font-size: 12.5px; color: var(--muted); }
.field input[type="text"], .field select {
  flex: 1 1 auto; height: 30px; padding: 0 8px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-s); outline: none;
}
.field input[type="text"]:focus, .field select:focus { border-color: var(--accent); }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 12.5px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hint { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.hint code {
  font: 11px/1.4 var(--mono);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.hint strong { color: var(--text); font-weight: 600; }

.keys { padding: 14px 16px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.keys > div { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.keys span { color: var(--muted); }

/* ==========================================================================
   Popover menu
   ========================================================================== */
.menu {
  position: fixed;
  z-index: 100;
  min-width: 170px;
  padding: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-2);
}
.menu[hidden] { display: none; }
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 6px 9px; border: 0; border-radius: 5px;
  background: transparent; cursor: pointer; font-size: 12.5px;
}
.menu button:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-host {
  position: fixed; left: 50%; bottom: 46px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  pointer-events: auto;
  animation: toast-in .16s ease-out;
}
.toast.out { animation: toast-out .16s ease-in forwards; }
.toast button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 12.5px;
}
.toast button:hover { text-decoration: underline; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .brand-name, .color-filter { display: none; }
  .topbar { gap: 6px; padding: 0 8px; }
  #btn-new-column, #btn-undo, #btn-redo { display: none; }
}
@media (max-width: 620px) {
  .keys { grid-template-columns: 1fr; }
  #btn-zoom-out, #btn-zoom-reset, #btn-zoom-in, #btn-fit { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
