/* ============================ theme tokens ============================ */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --topbar: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --border: #e0e0e0;
  --hover: #f1f3f4;
  --search-bg: #f1f3f4;
  --nav-active: #feefc3;
  --chip: rgba(0, 0, 0, .06);
  --shadow: 0 1px 2px rgba(60, 64, 67, .1), 0 2px 6px rgba(60, 64, 67, .12);
  --shadow-hover: 0 1px 3px rgba(60, 64, 67, .2), 0 4px 14px rgba(60, 64, 67, .22);
  --radius: 8px;
  --code-bg: #f1f3f4;
  --note-border: rgba(0, 0, 0, .08);
  /* note color palette (light) */
  --note-coral: #faafa8; --note-peach: #f39f76; --note-sand: #fff8b8;
  --note-mint: #e2f6d3; --note-sage: #b4ddd3; --note-fog: #d4e4ed;
  --note-storm: #aeccdc; --note-dusk: #d3bfdb; --note-blossom: #f6e2dd;
  --note-clay: #e9e3d4; --note-chalk: #efeff1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #202124; --surface: #202124; --topbar: #202124;
    --text: #e8eaed; --muted: #9aa0a6; --border: #5f6368;
    --hover: #303134; --search-bg: #303134; --nav-active: #41331c;
    --chip: rgba(255, 255, 255, .1);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-hover: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 16px rgba(0, 0, 0, .4);
    --code-bg: #3c3f43; --note-border: rgba(255, 255, 255, .12);
    --note-coral: #5c2b29; --note-peach: #614a19; --note-sand: #635d19;
    --note-mint: #345920; --note-sage: #16504b; --note-fog: #2d555e;
    --note-storm: #1e3a5f; --note-dusk: #42275e; --note-blossom: #5b2245;
    --note-clay: #442f19; --note-chalk: #3c3f43;
  }
}

:root[data-theme="dark"] {
  --bg: #202124; --surface: #202124; --topbar: #202124;
  --text: #e8eaed; --muted: #9aa0a6; --border: #5f6368;
  --hover: #303134; --search-bg: #303134; --nav-active: #41331c;
  --chip: rgba(255, 255, 255, .1);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-hover: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 16px rgba(0, 0, 0, .4);
  --code-bg: #3c3f43; --note-border: rgba(255, 255, 255, .12);
  --note-coral: #5c2b29; --note-peach: #614a19; --note-sand: #635d19;
  --note-mint: #345920; --note-sage: #16504b; --note-fog: #2d555e;
  --note-storm: #1e3a5f; --note-dusk: #42275e; --note-blossom: #5b2245;
  --note-clay: #442f19; --note-chalk: #3c3f43;
}

/* ============================ base ============================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .icon { display: block; }
.icon { vertical-align: middle; }

.text-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
}
.text-btn:hover { background: var(--hover); color: var(--text); }

.ghost {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
}
.ghost:hover { background: var(--hover); color: var(--text); }

.muted { color: var(--muted); }

/* ============================ top bar ============================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.brand .logo { display: inline-flex; align-items: center; color: var(--muted); }
#nav-toggle { display: inline-flex; }

.search { flex: 1; display: flex; justify-content: center; }
.search input {
  width: 100%;
  max-width: 720px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 15px;
  padding: 10px 16px;
  outline: none;
}
.search input:focus { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.topbar-actions { display: flex; gap: 2px; }

/* ============================ layout ============================ */
.app { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: 57px;
  flex: 0 0 256px;
  width: 256px;
  height: calc(100vh - 57px);
}
.sidebar-inner {
  height: 100%;
  overflow-y: auto;
  padding: 10px 12px 10px 0;
}

/* Collapsed rail (desktop): show only the icons; hovering expands the full
   sidebar as an overlay so the board never reflows (Google Keep style). */
@media (min-width: 721px) {
  body.sidebar-collapsed .sidebar { flex-basis: 68px; width: 68px; overflow: visible; }
  body.sidebar-collapsed .sidebar-inner { width: 68px; transition: width .18s ease; }
  body.sidebar-collapsed .sidebar:hover .sidebar-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 256px;
    max-height: calc(100vh - 57px);
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-hover);
    z-index: 29;
  }
  body.sidebar-collapsed .sidebar:not(:hover) .nav-section,
  body.sidebar-collapsed .sidebar:not(:hover) .nav-empty,
  body.sidebar-collapsed .sidebar:not(:hover) .nav-text,
  body.sidebar-collapsed .sidebar:not(:hover) .nav-count { display: none; }
  body.sidebar-collapsed .sidebar:not(:hover) .nav-item {
    width: 48px;
    margin: 2px auto;
    padding: 12px 0;
    gap: 0;
    justify-content: center;
    border-radius: 24px;
  }
}
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 14px 24px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  padding: 11px 24px;
  border-radius: 0 26px 26px 0;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--nav-active); }
.nav-item.active .nav-ico { color: var(--text); }
.nav-ico { display: inline-flex; align-items: center; color: var(--muted); }
.nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { color: var(--muted); font-size: 12px; }
.nav-empty { color: var(--muted); font-size: 13px; padding: 6px 24px; }

.main { flex: 1; min-width: 0; padding: 28px 24px 90px; }

/* ============================ composer ============================ */
.composer {
  max-width: 600px;
  margin: 0 auto 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.composer.collapsed .composer-expanded { display: none; }
.composer:not(.collapsed) .composer-collapsed-bar { display: none; }

.composer-collapsed-bar { display: flex; align-items: center; }
.composer-collapsed {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  padding: 14px 18px;
  outline: none;
  cursor: text;
}
#composer-newlist, #composer-newnumlist { flex: 0 0 auto; }
#composer-newnumlist { margin-right: 8px; }

.composer-expanded { padding: 12px 18px 10px; }
.composer-title {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 4px 0 6px;
}
.composer-title::placeholder { color: var(--muted); }
.composer-expanded textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  min-height: 60px;
  overflow: hidden;
}
.composer-toolbar { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.composer-toolbar .spacer { flex: 1; }
.composer-toolbar .color-dots { margin-right: 4px; }
.color-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .preview { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* label chips inside the composer */
.composer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.composer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip);
  color: var(--text);
  font-size: 12px;
  border-radius: 12px;
  padding: 2px 6px 2px 8px;
}
.composer-chip > .icon { color: var(--muted); }
.composer-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0;
  border-radius: 50%;
}
.composer-chip-x:hover { color: var(--text); background: rgba(0, 0, 0, .08); }

/* ============================ sections + masonry ============================ */
.grid-section { margin-bottom: 22px; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 12px 4px;
}
.masonry { display: flex; gap: 14px; align-items: flex-start; }
.masonry-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* ============================ note cards ============================ */
.note {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 6px;
  transition: box-shadow .12s, border-color .12s;
}
.note:hover { box-shadow: var(--shadow-hover); }
.note:hover .note-actions, .note:hover .note-pin { opacity: 1; }

.note-pin {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity .12s;
}
.note-pin.is-pinned { opacity: 1; }
.note-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 26px; /* leave room for the pin */
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.note-body { font-size: 14px; }
.note-body.markdown { padding-right: 26px; } /* leave room for the pin */
.note-title + .note-body.markdown { padding-right: 0; }

.note-labels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.note-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  border-radius: 12px;
  padding: 2px 9px;
}
.note-label:hover { color: var(--text); }

.note-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  min-height: 34px;
  opacity: 0;
  transition: opacity .12s;
}
.note-actions .icon-btn { width: 30px; height: 30px; }
.note-actions .icon-btn .icon { width: 18px; height: 18px; }
.note-time { margin-left: auto; font-size: 11px; color: var(--muted); padding-right: 4px; }

/* ============================ checklist component ============================ */
/* Shared by the card preview, the modal editor and the composer. */
.note-checklist { font-size: 14px; padding-right: 26px; }
.note-title + .note-checklist { padding-right: 0; }
.cl-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 2px 0;
  border-radius: 4px;
}
.cl-check {
  margin: 3px 0 0;
  flex: 0 0 auto;
  accent-color: var(--text);
  cursor: pointer;
}
.cl-check:disabled { cursor: default; }
.cl-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cl-item.is-checked .cl-text { text-decoration: line-through; color: var(--muted); }
.cl-remove {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .12s, background .12s;
}
.cl-item:hover .cl-remove { opacity: 1; }
.cl-remove:hover { background: var(--hover); color: var(--text); }

.cl-completed-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  user-select: none;
}
.cl-completed-head.is-clickable { cursor: pointer; }
.cl-chevron { display: inline-flex; align-items: center; transition: transform .15s; }
.cl-chevron:not(.is-open) { transform: rotate(-90deg); }
.cl-completed-group { padding-top: 2px; }

.cl-add { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cl-add-ico { display: inline-flex; align-items: center; color: var(--muted); flex: 0 0 auto; }
.cl-add-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 2px 0;
}
.cl-add-input::placeholder { color: var(--muted); }

/* ============================ modal editor ============================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 32px;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
}
.modal[data-color] { border-color: var(--note-border); }
.modal-title {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  padding: 16px 18px 6px;
}
.modal-title::placeholder { color: var(--muted); }
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 18px 8px;
}
.modal-body .note-checklist { padding-right: 0; font-size: 15px; }
.modal-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  min-height: 120px;
  overflow: hidden;
}
.modal-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; }
.modal-chips:not([hidden]) { margin-bottom: 6px; }
.modal-chips .note-label { background: var(--chip); }
.modal-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px 8px;
}
.modal-actions .spacer { flex: 1; }
.modal[data-color] .note-label { background: rgba(0, 0, 0, .07); }
body.modal-open { overflow: hidden; }

/* modal background colors mirror the card palette */
.modal[data-color="coral"] { background: var(--note-coral); }
.modal[data-color="peach"] { background: var(--note-peach); }
.modal[data-color="sand"] { background: var(--note-sand); }
.modal[data-color="mint"] { background: var(--note-mint); }
.modal[data-color="sage"] { background: var(--note-sage); }
.modal[data-color="fog"] { background: var(--note-fog); }
.modal[data-color="storm"] { background: var(--note-storm); }
.modal[data-color="dusk"] { background: var(--note-dusk); }
.modal[data-color="blossom"] { background: var(--note-blossom); }
.modal[data-color="clay"] { background: var(--note-clay); }
.modal[data-color="chalk"] { background: var(--note-chalk); }

/* ============================ drag & drop ============================ */
.note[draggable="true"] { cursor: grab; }
.note[draggable="true"]:active { cursor: grabbing; }
.note.dragging { opacity: .4; cursor: grabbing; }
/* Insertion indicator: a line on the side the card will drop. */
.note.drop-before { box-shadow: 0 -3px 0 -1px #1a73e8, var(--shadow-hover); }
.note.drop-after { box-shadow: 0 3px 0 -1px #1a73e8, var(--shadow-hover); }
/* Keep text/inputs/links selectable & clickable inside a draggable card. */
.note[draggable="true"] input,
.note[draggable="true"] textarea,
.note[draggable="true"] a { cursor: auto; }
.note[draggable="true"] .icon-btn,
.note[draggable="true"] .note-label,
.note[draggable="true"] .cl-check,
.note[draggable="true"] .cl-remove { cursor: pointer; }

/* note colors (applies to cards, the composer and swatches) */
.note[data-color="coral"], .composer[data-color="coral"], .swatch[data-color="coral"] { background: var(--note-coral); }
.note[data-color="peach"], .composer[data-color="peach"], .swatch[data-color="peach"] { background: var(--note-peach); }
.note[data-color="sand"], .composer[data-color="sand"], .swatch[data-color="sand"] { background: var(--note-sand); }
.note[data-color="mint"], .composer[data-color="mint"], .swatch[data-color="mint"] { background: var(--note-mint); }
.note[data-color="sage"], .composer[data-color="sage"], .swatch[data-color="sage"] { background: var(--note-sage); }
.note[data-color="fog"], .composer[data-color="fog"], .swatch[data-color="fog"] { background: var(--note-fog); }
.note[data-color="storm"], .composer[data-color="storm"], .swatch[data-color="storm"] { background: var(--note-storm); }
.note[data-color="dusk"], .composer[data-color="dusk"], .swatch[data-color="dusk"] { background: var(--note-dusk); }
.note[data-color="blossom"], .composer[data-color="blossom"], .swatch[data-color="blossom"] { background: var(--note-blossom); }
.note[data-color="clay"], .composer[data-color="clay"], .swatch[data-color="clay"] { background: var(--note-clay); }
.note[data-color="chalk"], .composer[data-color="chalk"], .swatch[data-color="chalk"] { background: var(--note-chalk); }
.note[data-color] { border-color: var(--note-border); }
.note[data-color] .note-label { background: rgba(0, 0, 0, .07); }

/* ============================ color swatches + popover ============================ */
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .25);
  background: var(--surface);
  padding: 0;
}
.swatch.is-default {
  background:
    linear-gradient(135deg, transparent 44%, #d93025 44%, #d93025 56%, transparent 56%),
    var(--surface);
}
.swatch.is-selected { outline: 2px solid var(--text); outline-offset: 1px; border-color: transparent; }

/* shared popover shell (color picker, label editor, ⋮ menu). Anchored to the
   document body in page coordinates by placePopover(). */
.popover {
  position: absolute;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

.color-popover {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 232px;
  padding: 10px 12px;
  border-radius: 24px;
}

.label-popover {
  width: 248px;
  border-radius: 10px;
  padding: 10px 12px 12px;
}
.label-pop-head { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.label-pop-list { max-height: 220px; overflow-y: auto; }
.label-pop-empty { color: var(--muted); font-size: 13px; padding: 4px 2px; }
.label-pop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 2px;
  cursor: pointer;
  border-radius: 6px;
}
.label-pop-row:hover { background: var(--hover); }
.label-pop-row input { accent-color: var(--text); }
.label-pop-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-pop-create {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.label-pop-create input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--search-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
}
.label-pop-create input:focus { border-color: var(--text); }

.menu-popover {
  min-width: 180px;
  border-radius: 8px;
  padding: 6px 0;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  padding: 9px 16px;
}
.menu-item:hover { background: var(--hover); }
.menu-ico { display: inline-flex; align-items: center; color: var(--muted); }

/* ============================ board actions (trash bar) ============================ */
.board-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto 18px;
  padding: 0 4px;
}
.board-note { flex: 1; color: var(--muted); font-size: 13px; }
.text-btn.danger { color: #d93025; }
.text-btn.danger:hover { background: rgba(217, 48, 37, .1); color: #d93025; }

/* ============================ empty state ============================ */
.empty { text-align: center; color: var(--muted); padding: 80px 0; font-size: 15px; }

/* ============================ markdown ============================ */
.markdown { word-wrap: break-word; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3,
.markdown h4, .markdown h5, .markdown h6 { margin: .7em 0 .35em; line-height: 1.3; }
.markdown h1 { font-size: 1.4em; }
.markdown h2 { font-size: 1.25em; }
.markdown h3 { font-size: 1.1em; }
.markdown p { margin: .45em 0; }
.markdown ul, .markdown ol { margin: .45em 0; padding-left: 1.4em; }
.markdown li.task { list-style: none; margin-left: -1.2em; }
.markdown li.task input { margin-right: 6px; accent-color: var(--text); cursor: pointer; vertical-align: -1px; }
.markdown li.task input:disabled { cursor: default; }
.markdown blockquote {
  margin: .5em 0;
  padding: 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.markdown code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown img { max-width: 100%; border-radius: 6px; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: .9em 0; }
.markdown a { text-decoration: none; color: #1a73e8; }
.markdown a:hover { text-decoration: underline; }
:root[data-theme="dark"] .markdown a,
.hashtag { color: #8ab4f8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .markdown a { color: #8ab4f8; } }
.hashtag { font-weight: 500; }

/* GFM tables */
.markdown .table-wrap { overflow-x: auto; margin: .6em 0; }
.markdown table { border-collapse: collapse; width: auto; max-width: 100%; font-size: .92em; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--chip); font-weight: 600; }

/* ============================ scrim (mobile drawer) ============================ */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 25;
}

/* ============================ login ============================ */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-card .brand { justify-content: center; font-size: 24px; color: var(--text); }
.login-sub { color: var(--muted); margin: 0; font-size: 14px; }
.login-card input {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.login-card input:focus { border-color: #1a73e8; }
.login-card button {
  background: #1a73e8;
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
}
.login-error { color: #d93025; font-size: 13px; margin: 0; }

/* ============================ account menu ============================ */
.account { position: relative; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-hover);
  padding: 6px 0;
  z-index: 45;
}
.account-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  padding: 10px 16px;
}
.account-item:hover { background: var(--hover); }
.account-ico { display: inline-flex; align-items: center; color: var(--muted); }
.account-card {
  display: flex;
  flex-direction: column;
  padding: 9px 16px 11px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.account-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.account-card-sub { font-size: 12px; color: var(--muted); }

/* ============================ dialog (settings / account) ============================ */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 72px 16px 32px;
  overflow-y: auto;
}
.dialog {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.dialog-body { padding: 16px 18px 20px; }
.dialog-section + .dialog-section { margin-top: 22px; }
.dialog-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}
.setting-label { font-size: 14px; }

/* segmented switch (theme / language) */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--hover); color: var(--text); }
.seg-btn.active { background: var(--nav-active); color: var(--text); }

/* form fields */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
}
.field input:focus { border-color: #1a73e8; background: var(--surface); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn-primary {
  background: #1a73e8;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover { background: #1666cf; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.dialog-msg { font-size: 13px; margin: 0 0 12px; }
.dialog-msg.err { color: #d93025; }
.dialog-msg.ok { color: #188038; }
.field-hint { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* user management (admin settings) */
.user-list { margin: 6px 0 10px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-row-name {
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.user-row-sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 10px;
}
.badge-admin { background: var(--nav-active); color: var(--text); }
.badge-you { background: var(--chip); color: var(--muted); }
.icon-btn.danger { color: #d93025; }
.icon-btn.danger:hover { background: rgba(217, 48, 37, .1); color: #d93025; }

/* ============================ note images ============================ */
.note:has(.note-images) { overflow: hidden; }
.note-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  margin: -14px -16px 10px; /* bleed to the card edges */
}
.note-images.single { grid-template-columns: 1fr; }
.note-image { position: relative; margin: 0; min-width: 0; }
.note-image img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}
.note-image-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: rgba(32, 33, 36, .6);
  color: #fff;
  opacity: 0;
}
.note-image:hover .note-image-remove,
.note-image:focus-within .note-image-remove { opacity: 1; }
.note-image-remove:hover { background: rgba(32, 33, 36, .85); color: #fff; }

/* editor image strip (composer + modal add area) */
.note-images-edit {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 6px;
  margin: 4px 0 10px;
}
.note-images-edit .note-image img { border-radius: 8px; max-height: 150px; }
.note-images-edit .note-image-remove { opacity: 1; width: 24px; height: 24px; }

/* modal: full-width image grid above the title */
.modal-images:empty { display: none; }
.modal-images .note-images { margin: 0 0 4px; }
.modal-images .note-image img { max-height: 440px; }
.modal[data-color] .note-images { mix-blend-mode: normal; }

/* ============================ responsive ============================ */
@media (max-width: 720px) {
  #nav-toggle { display: inline-flex; }
  .dialog-backdrop { padding: 28px 10px; }
  .sidebar {
    position: fixed;
    top: 57px;
    left: 0;
    z-index: 28;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .2s ease;
    padding-right: 12px;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .scrim { display: block; }
  .main { padding: 20px 14px 80px; }
  .note-actions, .note-pin { opacity: 1; }
  .cl-remove { opacity: 1; }
  .brand-name { display: none; }
  .modal-backdrop { padding: 24px 10px; }
  .modal { max-height: 90vh; }
}
