/* notey-g design system — adapted from LandOfWikiandHoney/design.md.
   Semantic CSS variables; compact, bordered, calm utility UI. */

:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-alt: #fbfbf8;
  --control: #ffffff;
  --ink: #1b2424;
  --muted: #687170;
  --line: #dfe2dc;
  --accent: #256f6c;
  --accent-hover: #1f5e5b;
  --accent-2: #9a5b22;
  --soft: #edf4f1;
  --danger: #a64040;
  --on-accent: #ffffff;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(20, 30, 28, 0.12);

  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f1715;
  --panel: #15201d;
  --panel-alt: #121b19;
  --control: #18241f;
  --ink: #e7efea;
  --muted: #8fa39c;
  --line: #25332e;
  --accent: #45b3ad;
  --accent-hover: #5bc4be;
  --accent-2: #c98a4f;
  --soft: #16302b;
  --danger: #d77a7a;
  --on-accent: #06110f;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; }

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}

/* --- auth --- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 26px 24px;
}

.auth-title {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.auth-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 18px;
}

.field { margin-bottom: 12px; }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--control);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--soft);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.checkbox input { width: auto; height: auto; }

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--control);
  color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn:disabled { opacity: 0.55; cursor: default; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 0.82rem;
}
.link-btn:hover { text-decoration: underline; }

.auth-foot {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.msg {
  font-size: 0.82rem;
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
}
.msg-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.msg-ok { color: var(--accent); background: var(--soft); }

/* --- app shell --- */

.shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel-alt);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  padding: 9px 11px;
  font-size: 0.92rem;
}
.nav-item:hover { background: var(--soft); }
.nav-item.active { border-color: var(--accent); background: var(--soft); color: var(--accent); }

.sidebar-foot { margin-top: auto; font-size: 0.78rem; color: var(--muted); }
.sidebar-foot .email { color: var(--ink); overflow-wrap: anywhere; }

.main { height: 100vh; overflow: hidden; }
.content { height: 100%; }
.settings { padding: 20px 24px; overflow: auto; height: 100%; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-head h1 { font-size: 1.1rem; margin: 0; }
.section-head p { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
}

.muted { color: var(--muted); font-size: 0.86rem; }

.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
}

/* --- notes workspace --- */

.notes {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

.tree-pane {
  border-right: 1px solid var(--line);
  background: var(--panel-alt);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tree-header {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tree-actions { display: flex; gap: 6px; }

.btn.mini {
  height: 30px;
  padding: 0 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn.mini.on { border-color: var(--accent); color: var(--accent); background: var(--soft); }

.tree-body { overflow: auto; padding: 8px; flex: 1; min-height: 0; }

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 0.88rem;
}
.row:hover { background: var(--soft); }
.row.active { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.row .caret { width: 14px; text-align: center; color: var(--muted); flex: none; }
.row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.row.folder { font-weight: 500; }
.row.note { color: var(--ink); }

.row-action {
  border: none;
  background: none;
  color: var(--muted);
  opacity: 0;
  padding: 0 4px;
  font-size: 0.8rem;
}
.row:hover .row-action { opacity: 1; }
.row-action:hover { color: var(--accent); }
.row-action.danger:hover { color: var(--danger); }

.children { margin-left: 14px; }

/* search */
.search-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--control);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
}
.search-results { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.search-hit {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
}
.search-hit:hover { border-color: var(--accent); }
.hit-title { font-size: 0.84rem; }
.hit-snippet { font-size: 0.76rem; margin-top: 2px; }
.pad { padding: 6px; }

/* editor */
.editor-pane { display: flex; flex-direction: column; min-height: 0; height: 100%; }

.editor-empty { display: grid; place-items: center; height: 100%; }

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.note-title {
  flex: 1;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0 8px;
  border-radius: var(--radius-sm);
}
.note-title:hover { border-color: var(--line); }
.note-title:focus { outline: none; border-color: var(--accent); background: var(--control); }

.editor-toolbar { display: flex; align-items: center; gap: 6px; }
.save-status { font-size: 0.76rem; min-width: 64px; text-align: right; }

.editor-surface { flex: 1; min-height: 0; overflow: auto; }
.note-body {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--panel);
}
.note-body:focus { outline: none; }

.note-preview {
  padding: 16px 20px;
  line-height: 1.6;
  max-width: 760px;
}
.note-preview h1, .note-preview h2, .note-preview h3 { line-height: 1.25; margin: 1em 0 0.4em; }
.note-preview pre {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow: auto;
}
.note-preview code { font-family: var(--mono); font-size: 0.86em; }
.note-preview blockquote {
  border-left: 3px solid var(--line);
  margin: 0.6em 0;
  padding: 2px 0 2px 12px;
  color: var(--muted);
}
.note-preview img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.note-preview a.wikilink { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }

.backlinks {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.backlinks-title { width: 100%; font-size: 0.76rem; }
.backlink {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.backlink:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 760px) {
  .notes { grid-template-columns: 1fr; }
  .tree-pane { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
}
