/* handbreaker — minimal white / black / purple, Obsidian-ish. */

:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #8a8a8a;
  --faint: #e6e6e6;
  --field: #f2f2f2;
  --purple: #7c5cff;
  --purple-soft: #efeaff;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* dark theme (Obsidian-ish) */
html[data-theme="dark"] {
  --bg: #1a1a1b;
  --ink: #e8e8ea;
  --muted: #8e8e96;
  --faint: #34343a;
  --field: #26262b;
  --purple: #a78bfa;
  --purple-soft: #2b2440;
}

/* light/dark toggle */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--faint);
  background: var(--bg);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.theme-toggle:hover { color: var(--purple); border-color: var(--purple); }

/* Scratchpad toggle — sits just left of the theme toggle */
.scratch-toggle {
  position: fixed;
  top: 12px;
  right: 54px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--faint);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.scratch-toggle:hover { color: var(--purple); border-color: var(--purple); }
.scratch-toggle svg { width: 18px; height: 18px; display: block; }

/* Scratchpad panel — slides in from the right, fills that side of the screen */
.scratchpad {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(42vw, 560px);
  background: var(--bg);
  border-left: 1px solid var(--faint);
  box-shadow: -10px 0 36px rgba(0, 0, 0, 0.10);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 70;
  display: flex;
  flex-direction: column;
}
.scratchpad.open { transform: translateX(0); }
.scratch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--faint);
  font-size: 14px;
  color: var(--muted);
}
.scratch-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.scratch-close:hover { color: var(--purple); }
.scratch-text {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  padding: 16px 18px;
}
.scratch-text::placeholder { color: var(--muted); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
/* when the scratchpad is open, make room for it so it never covers content */
body { transition: padding-right 0.2s ease; }
body.scratch-open { padding-right: min(42vw, 560px); }

a { color: var(--purple); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

/* Breadcrumb */
.breadcrumb {
  position: fixed;
  top: 14px;
  left: 16px;
  font-size: 15px;
  color: var(--muted);
  max-width: 72vw;
  line-height: 1.8;
}
.breadcrumb a { color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.breadcrumb a:hover { color: var(--purple); background: var(--purple-soft); text-decoration: none; }
.breadcrumb .sep { color: var(--faint); margin: 0 1px; }
.breadcrumb .here { color: var(--ink); padding: 4px 6px; font-weight: 600; }

/* Page */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 96px 24px 120px;
}

/* "Return to <parent>" link above the title */
.return-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.return-link:hover { color: var(--purple); text-decoration: none; }

.title {
  text-align: center;
  font-weight: 600;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  word-break: break-word;
}

/* edit / move / delete for the current note — small grey icons under the title */
.note-actions {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin: 0 0 18px;
}
.note-actions .icon-action svg { width: 17px; height: 17px; }

/* Idea input */
.add-form { position: relative; margin: 0 auto 18px; max-width: 560px; }
.add-input {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
/* tap-to-submit button inside the input — shown on touch devices only */
.add-submit {
  display: none;
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: var(--purple);
  color: #fff;
  cursor: pointer;
}
.add-submit svg { width: 20px; height: 20px; display: block; }
.add-input::placeholder { color: var(--muted); }
.add-input:focus { background: var(--bg); border-color: var(--purple); }

/* intro hint (root page only) — sits under the title, above the input */
.intro {
  max-width: 520px;
  margin: 0 auto 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* how-to hint just above the feed */
.expand-hint {
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--muted);
}
.hint-mobile { display: none; }

/* Quicklinks */
.quicklinks {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  justify-content: center;
  margin: 0 auto 40px;
  max-width: 560px;
  font-size: 14px;
}
.quicklinks .ql-sep { color: var(--faint); }

/* Sort bar */
.sortbar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--faint);
  padding-bottom: 10px;
  margin-bottom: 8px;
}
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.view-ico { width: 14px; height: 14px; display: block; }
.sort-btn:hover { color: var(--ink); }
.sort-btn.active { color: var(--purple); background: var(--purple-soft); }
/* Recent/Popular picker for the Feed view, pushed to the right */
.feed-sort {
  margin-left: auto;
  font-family: var(--font);
  font-size: 13px;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--faint);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

/* Feed */
.feed { font-size: 14px; }

/* each note is one visual block; a faint rule separates top-level ideas */
.node { margin-bottom: 8px; }
.feed > .node { border-bottom: 1px solid var(--faint); padding-bottom: 8px; }
.feed > .node:last-child { border-bottom: none; }
.node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
}

/* nesting guide line — clickable to collapse the parent (reddit-style) */
.children {
  position: relative;
  margin-left: 9px;
  padding-left: 14px;
}
.thread-line {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: pointer;
}
.thread-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--faint);
}
.thread-line:hover::before {
  background: var(--purple);
  width: 2px;
}

.toggle {
  flex: none;
  min-width: 22px;
  text-align: center;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1.4;
}
.toggle:hover { color: var(--purple); }
.toggle.empty { visibility: hidden; }

.upvote-wrap { flex: none; position: relative; display: inline-flex; }
.upvote {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  padding: 0 2px;
  line-height: 1.4;
}
.upvote:hover { color: var(--purple); }
.upvote.voted { color: #eab308; } /* gold once upvoted */

/* custom tooltip on the upvote button */
.tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}
.upvote-wrap:hover .tip { opacity: 1; }
.tip.flash { opacity: 1; } /* force-shown right after a click */

.karma {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  min-width: 16px;
  text-align: center;
}

.text { flex: 1; line-height: 1.45; word-break: break-word; cursor: pointer; }
.text:hover { color: var(--purple); }
.text.dim { color: var(--muted); }
/* bucket labels (Unsorted/Hidden) — a container, not an idea */
.text.bucket { color: var(--muted); font-style: italic; }

.edit-input {
  flex: 1;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--purple);
  border-radius: 6px;
  padding: 3px 8px;
  outline: none;
}
/* editing the page title — bigger, centered, like the title it replaces */
.title-edit {
  display: block;
  width: min(560px, 90%);
  margin: 0 auto 14px;
  text-align: center;
  font-size: clamp(22px, 4vw, 40px);
  font-weight: 600;
  padding: 6px 12px;
}

/* action icons on the right of the row, hidden until you hover (desktop only) */
.node-tools {
  flex: none;
  margin-left: 10px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.icon-action { display: inline-flex; align-items: center; color: var(--muted); }
.icon-action:hover { color: var(--purple); }
.icon-action svg { width: 16px; height: 16px; display: block; }
.icon-action.danger:hover { color: #e5484d; }
/* right-aligned meta column: note-count + timestamp, lined up across all rows */
.meta-right {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-left: 12px;
  white-space: nowrap;
}
.node-time {
  min-width: 64px;
  text-align: right;
  color: var(--muted);
  font-size: 11px;
}
.child-count { color: var(--muted); font-size: 12px; cursor: pointer; text-align: right; }
.child-count:hover { color: var(--purple); }
/* the icon group fades in on hover; it reserves its space so nothing reflows */
.secondary { opacity: 0; transition: opacity 0.12s; }
.node-head:hover .secondary { opacity: 1; }

/* inline reply box — indented under the note text, like reddit */
.inline-add { margin: 4px 0 8px 64px; }
.inline-add input {
  width: 100%;
  max-width: 520px;
  font-family: var(--font);
  font-size: 14px;
  background: var(--field);
  border: 1px solid var(--purple);
  border-radius: 8px;
  padding: 9px 13px;
  outline: none;
}

/* ---- "Recent" notification feed (flat, reddit-notification style) ---- */
.notif {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  border-bottom: 1px solid var(--faint);
}
.notif:last-child { border-bottom: none; }
.notif:hover { background: var(--field); }
.notif-body { flex: 1; min-width: 0; cursor: pointer; }
/* small, muted location path on top — where the note lives */
.notif-path {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
/* the note itself — the focus of the row */
.notif-text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  word-break: break-word;
}
.notif-body:hover .notif-text { color: var(--purple); }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
/* compact upvote on the right */
.notif-vote { flex: none; align-items: center; gap: 2px; }
.notif-vote .karma { min-width: 12px; }

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

/* Move modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }
.modal {
  background: var(--bg);
  width: min(440px, 92vw);
  max-height: 80vh;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--faint);
  font-size: 14px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.move-bc {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--faint);
}
.move-bc a { color: var(--muted); }
.move-list { overflow-y: auto; padding: 6px 8px; }
.move-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.move-row:hover { background: var(--field); }
.move-row .arrow { color: var(--muted); font-size: 12px; }
.move-row.disabled { color: var(--faint); cursor: not-allowed; }
.move-row.disabled:hover { background: none; }
.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--faint);
  text-align: right;
}
.move-confirm {
  font-family: var(--font);
  font-size: 14px;
  color: #fff;
  background: var(--purple);
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
}
.move-confirm:disabled { background: var(--faint); cursor: not-allowed; }

/* toast (command feedback) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 8px;
  max-width: 80vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- mobile / touch ---- */
/* touch devices: drop the per-row action icons entirely (edit/move/delete live
   under the title there), swap the hint wording, show the tap-to-submit button */
@media (hover: none) {
  .node-tools { display: none; }
  .hint-desktop { display: none; }
  .hint-mobile { display: inline; }
  .add-submit { display: inline-flex; }
  .add-input { padding-right: 56px; } /* room for the tap-to-submit button */
}

@media (max-width: 600px) {
  /* breadcrumb in normal flow (no overlap with title), bigger tap targets */
  .breadcrumb {
    position: static;
    max-width: none;
    font-size: 14px;
    padding: 14px 14px 0;
  }
  /* not sticky on mobile — let it scroll away with the page */
  .theme-toggle { position: absolute; top: 10px; right: 10px; }
  .scratch-toggle, .scratchpad { display: none; } /* scratchpad is desktop-only */
  .page { padding: 8px 14px 100px; }
  .title { font-size: clamp(26px, 9vw, 40px); margin-bottom: 18px; }
  .add-input { font-size: 16px; } /* 16px stops iOS from auto-zooming */
  .feed { font-size: 13px; }      /* smaller text reads cleaner on a phone */
  .quicklinks { font-size: 12px; gap: 7px; margin-bottom: 28px; }
  .meta-right.deep { display: none; } /* >2 layers deep: drop the count/time */
  .node-time { min-width: 52px; }
  .toggle, .upvote { padding: 4px; } /* easier to tap */
}
