/* okboomer notes — Obsidian-like theme */
:root {
  --accent: #7c6cf2;
  --accent-hover: #8b7cf6;
  --accent-ink: #ffffff;
  --danger: #e5484d;
  --ok: #4ac97e;

  /* dark (Obsidian default) */
  --bg: #1e1e1e;             /* editor / primary */
  --bg-sidebar: #181818;     /* file explorer */
  --bg-elev: #262626;        /* cards / modals */
  --bg-input: #1a1a1a;
  --bg-hover: rgba(255, 255, 255, .055);
  --bg-active: rgba(124, 108, 242, .22);
  --border: #2d2d2d;
  --border-faint: rgba(255, 255, 255, .07);
  --text: #dcddde;
  --text-muted: #9c9c9f;
  --text-faint: #6a6a6e;
  --code-bg: #2a2a2a;

  --radius: 6px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --bg-sidebar: #f6f6f7;
    --bg-elev: #ffffff;
    --bg-input: #f1f1f3;
    --bg-hover: rgba(0, 0, 0, .045);
    --bg-active: rgba(124, 108, 242, .14);
    --border: #e4e4e7;
    --border-faint: rgba(0, 0, 0, .08);
    --text: #2e3338;
    --text-muted: #6b7078;
    --text-faint: #9aa0a6;
    --code-bg: #f0f0f3;
    --accent-hover: #6a5cf0;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--text);
  background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.hidden { display: none !important; }
.spacer { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* thin Obsidian-style scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(150,150,150,.35) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(150,150,150,.3); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(150,150,150,.5); background-clip: content-box; }

/* ---- Centered cards (login / totp / notice / setup) ---- */
.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; background: var(--bg-sidebar); }
.card {
  width: 100%; max-width: 380px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 10px; padding: 28px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.card.wide { max-width: 440px; }
.card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.card input {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: var(--radius); font-size: 15px; width: 100%;
}
.card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,108,242,.35); }
.code-input { letter-spacing: 6px; text-align: center; font-size: 22px; font-family: var(--mono); }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text); padding: 10px 14px; border-radius: var(--radius);
  transition: background .12s ease, border-color .12s ease;
}
button:hover { background: var(--bg-hover); border-color: var(--accent); }
.card button[type=submit]:not(.linkbtn) {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600;
}
.card button[type=submit]:not(.linkbtn):hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.alert { background: rgba(229,72,77,.12); border: 1px solid var(--danger); color: #ff9ea0; padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; }
.ok-box { background: rgba(74,201,126,.12); border: 1px solid var(--ok); color: #9fe9bd; padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; }
.inline-form { display: inline; margin: 0; }
.linkbtn { background: none; border: none; color: var(--text-muted); padding: 6px 0; }
.linkbtn:hover { background: none; color: var(--text); text-decoration: underline; }

/* setup helpers */
.steps { padding-left: 18px; margin: 14px 0; }
.qr { display: flex; justify-content: center; margin: 10px 0; }
.qr img, .qr canvas { background: #fff; padding: 8px; border-radius: 8px; }
.breakall { word-break: break-all; }
.mt { margin-top: 16px; }
details summary { cursor: pointer; }

/* ---- App shell ---- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  background: var(--bg-sidebar); border-bottom: 1px solid var(--border); flex: none;
}
.brand { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.searchwrap { flex: 1; max-width: 420px; }
#search {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: var(--radius); font-size: 13.5px;
}
#search:focus { outline: none; border-color: var(--accent); }
.user { color: var(--text-muted); }
.iconbtn { background: none; border: none; font-size: 18px; padding: 4px 8px; display: none; color: var(--text-muted); }
.iconbtn:hover { background: none; color: var(--text); }

.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 290px; flex: none; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  overflow: auto; padding: 8px 6px;
}
.sidebar-actions { margin: 2px 6px 8px; }
.smallbtn { padding: 6px 11px; font-size: 13px; border-radius: var(--radius); }
.smallbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.smallbtn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.smallbtn.danger:hover { border-color: var(--danger); color: #ff9ea0; }
#newNote { width: 100%; color: var(--text-muted); }
#newNote:hover { color: var(--text); }

/* ---- File explorer tree ---- */
.tree ul { list-style: none; margin: 0; padding-left: 13px; }
.tree > ul { padding-left: 0; }
/* indentation guides like Obsidian */
.tree ul ul { border-left: 1px solid var(--border-faint); margin-left: 7px; padding-left: 7px; }
.tree li { margin: 0; }
.tree .row {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 5px;
  cursor: pointer; color: var(--text-muted); white-space: nowrap; font-size: 13.5px; line-height: 1.5;
}
.tree .row:hover { background: var(--bg-hover); color: var(--text); }
.tree .row.active { background: var(--bg-active); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.tree .dir > .row { color: var(--text); font-weight: 500; }
.tree .twisty { width: 12px; font-size: 10px; display: inline-block; color: var(--text-faint); text-align: center; }
.tree .file .twisty { visibility: hidden; }
.tree .collapsed > ul { display: none; }
.tree .name { overflow: hidden; text-overflow: ellipsis; }
.tree .file.other .name { color: var(--text-faint); }

.search-results { padding: 4px; }
.search-results .sr-item { padding: 8px; border-radius: var(--radius); cursor: pointer; }
.search-results .sr-item:hover { background: var(--bg-hover); }
.search-results .sr-name { font-weight: 600; font-size: 13.5px; }
.search-results .sr-snip { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---- Content ---- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  border-bottom: 1px solid var(--border); flex: none;
}
.current-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; font-size: 12.5px; color: var(--text-faint); }
.status { min-width: 60px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.viewer, .editor { flex: 1; overflow: auto; }
.viewer { padding: 10px 26px 80px; }
.markdown { max-width: 720px; margin: 0 auto; }
.editor {
  font-family: var(--mono); font-size: 14px; line-height: 1.7; border: none;
  background: var(--bg); color: var(--text); resize: none; width: 100%;
  max-width: 760px; margin: 0 auto; padding: 18px 26px 80px; display: block;
}
.editor:focus { outline: none; }

/* ---- Markdown reading view (Obsidian-like) ---- */
.markdown { font-size: 16px; line-height: 1.7; }
.markdown > :first-child { margin-top: .4em; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { line-height: 1.3; margin: 1.5em 0 .5em; font-weight: 700; }
.markdown h1 { font-size: 1.9em; }
.markdown h2 { font-size: 1.5em; }
.markdown h3 { font-size: 1.25em; }
.markdown h4 { font-size: 1.1em; }
.markdown p, .markdown ul, .markdown ol, .markdown table, .markdown blockquote { margin: .6em 0; }
.markdown ul, .markdown ol { padding-left: 1.6em; }
.markdown li { margin: .2em 0; }
.markdown code {
  font-family: var(--mono); font-size: .88em; background: var(--code-bg);
  padding: .15em .4em; border-radius: 4px;
}
.markdown pre {
  background: var(--code-bg); border: 1px solid var(--border); padding: 14px 16px;
  border-radius: 8px; overflow: auto; line-height: 1.5;
}
.markdown pre code { background: none; padding: 0; font-size: .85em; }
.markdown blockquote {
  padding: .1em 1em; border-left: 3px solid var(--accent);
  color: var(--text-muted); background: var(--bg-hover); border-radius: 0 6px 6px 0;
}
.markdown img { max-width: 100%; height: auto; border-radius: 6px; margin: .4em 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.markdown table { border-collapse: collapse; width: 100%; display: block; overflow: auto; font-size: .95em; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.markdown th { background: var(--bg-hover); font-weight: 600; }
.markdown a { word-break: break-word; }
.viewer > .muted.center { color: var(--text-faint); margin-top: 40px; }

/* ---- Mobile ---- */
@media (max-width: 760px) {
  .iconbtn { display: inline-block; }
  .sidebar {
    position: fixed; z-index: 30; top: 48px; bottom: 0; left: 0; width: 82%; max-width: 310px;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .user { display: none; }
  .viewer { padding: 10px 16px 80px; }
  .current-path { max-width: 40%; }
}
