/* Nothing OS in a browser: black, hairlines, one red, no shadows. */

:root {
  --bg: #000000;
  --surface: #0e0e0e;
  --raised: #1c1c1c;
  --hairline: rgba(255, 255, 255, 0.12);
  --fg: #ffffff;
  --fg2: #b1b3b3;
  --fg3: #595a5a;
  --accent: #c6102e;
  --accent-pressed: #ed1d3f;

  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px;
  --sp5: 24px; --sp6: 32px;
  --r-inner: 16px; --r-chip: 12px;

  --ui: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
}

@media (prefers-contrast: more) {
  :root { --accent: #f04061; --hairline: rgba(255, 255, 255, 0.28); }
}

* { box-sizing: border-box; }

/* `hidden` has to beat the layout rules below.
 *
 * The attribute works through a UA rule of `[hidden] { display: none }`, which
 * a class selector like `.app { display: grid }` ties on specificity and then
 * wins on order. Without this, hiding a pane does nothing and both render on
 * top of each other. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }

.muted { color: var(--fg3); }
.small { font-size: 13px; }
.status { min-height: 1.2em; margin: var(--sp2) 0 0; font-size: 13px; color: var(--fg2); }
.status.error { color: var(--accent); }

button {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-chip);
  padding: var(--sp2) var(--sp3);
  cursor: pointer;
}
button:focus-visible, input:focus-visible, .editor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-inner);
  padding: var(--sp3) var(--sp4);
  width: 100%;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}
.primary:hover { background: var(--accent-pressed); }
.primary:disabled { background: var(--raised); color: var(--fg3); cursor: default; }

.ghost { border-color: var(--hairline); color: var(--fg2); letter-spacing: 0.06em; font-size: 12px; }
.ghost:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.3); }
.danger { color: var(--accent); }

/* ---- pairing ---- */

.pair { display: grid; place-items: center; min-height: 100dvh; padding: var(--sp5); }
.pair-card { width: min(420px, 100%); }
.pair-card h1 {
  font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--fg3); margin: 0 0 var(--sp4);
}

/* A white quiet zone regardless of theme: a QR on black is unreadable to most
 * scanners, which expect dark modules on light. */
.pair-qr {
  width: min(260px, 70vw);
  aspect-ratio: 1;
  margin: var(--sp5) auto var(--sp4);
  padding: var(--sp3);
  background: #ffffff;
  border-radius: var(--r-inner);
  display: grid;
  place-items: center;
}
.pair-qr:empty { background: var(--surface); }
.pair-qr.expired { opacity: 0.2; }
.pair-qr svg { display: block; width: 100%; height: 100%; }

.field { display: block; margin: var(--sp4) 0; }
.field span {
  display: block; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--fg3); margin-bottom: var(--sp2);
}
.field input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--r-inner);
  padding: var(--sp3) var(--sp4);
}
#pair-code {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.advanced summary { color: var(--fg3); font-size: 13px; cursor: pointer; }
.advanced input { font-family: var(--mono); font-size: 13px; }

/* ---- app shell ---- */

.app {
  display: grid;
  grid-template-columns: 232px 320px 1fr;
  height: 100dvh;
}
.sidebar, .list { border-right: 1px solid var(--hairline); min-width: 0; }
.sidebar { display: flex; flex-direction: column; padding: var(--sp4); gap: var(--sp3); }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.wordmark { font-size: 12px; letter-spacing: 0.24em; color: var(--fg3); }

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-inner);
  padding: var(--sp2) var(--sp3);
}

.folders { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.folder {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp2); width: 100%; text-align: left;
  border-radius: var(--r-chip); padding: var(--sp2) var(--sp3); color: var(--fg2);
}
.folder:hover { background: var(--surface); color: var(--fg); }
.folder[aria-current="true"] { background: var(--raised); color: var(--fg); }
.folder .count { color: var(--fg3); font-size: 12px; font-family: var(--mono); }
.folder-group {
  margin-top: var(--sp3); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--fg3); padding: 0 var(--sp3);
}

.sidebar-foot { display: flex; flex-direction: column; gap: var(--sp2); }

/* ---- note list ---- */

.pane-head {
  display: flex; align-items: center; gap: var(--sp3);
  padding: var(--sp4); border-bottom: 1px solid var(--hairline);
  min-height: 57px;
}
.pane-head h2 { font-size: 15px; margin: 0; font-weight: 500; }

.notes { overflow-y: auto; height: calc(100dvh - 57px); }
.note-row {
  display: block; width: 100%; text-align: left;
  padding: var(--sp3) var(--sp4);
  border: 0; border-bottom: 1px solid var(--hairline); border-radius: 0;
}
.note-row:hover { background: var(--surface); }
.note-row[aria-current="true"] { background: var(--raised); }
.note-row .title {
  display: flex; align-items: center; gap: var(--sp2);
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.note-row .snippet {
  color: var(--fg3); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.note-row .pin { color: var(--accent); font-size: 11px; }
.note-row .badge { color: var(--fg3); font-size: 11px; font-family: var(--mono); }

/* ---- editor ---- */

.detail { display: flex; flex-direction: column; min-width: 0; }
.editor-head { gap: var(--sp2); flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.toolbar button {
  min-width: 32px; color: var(--fg2); font-size: 13px;
  border-radius: var(--r-chip); padding: var(--sp1) var(--sp2);
}
.toolbar button:hover { background: var(--raised); color: var(--fg); }
.toolbar button[aria-pressed="true"] { background: var(--fg); color: #000; }
.toolbar .sep { width: 1px; height: 18px; background: var(--hairline); margin: 0 var(--sp2); }

.empty { padding: var(--sp6); color: var(--fg2); max-width: 52ch; }

.editor {
  flex: 1; overflow-y: auto;
  padding: var(--sp5) var(--sp5) 40vh;
  outline: none;
  max-width: 76ch;
  caret-color: var(--accent);
}
.editor[contenteditable="false"] { caret-color: transparent; }

.editor .line { margin: 0 0 2px; min-height: 1.5em; }
.editor h1.line { font-size: 26px; margin: var(--sp4) 0 var(--sp2); }
.editor h2.line { font-size: 21px; margin: var(--sp4) 0 var(--sp2); }
.editor h3.line { font-size: 17px; margin: var(--sp3) 0 var(--sp1); }

.editor blockquote.line {
  border-left: 2px solid var(--accent);
  padding-left: var(--sp3); color: var(--fg2);
}
.editor pre.line {
  font-family: var(--mono); font-size: 13px;
  background: var(--surface); padding: var(--sp2) var(--sp3);
  white-space: pre-wrap; margin: 0;
}

.editor .block-ul, .editor .block-ol, .editor .block-cl {
  display: flex; gap: var(--sp2); padding-left: var(--sp2);
}
.editor .block-ul::before { content: "•"; color: var(--fg3); }
.editor .block-ol { counter-increment: ol; }
.editor .block-ol::before { content: counter(ol) "."; color: var(--fg3); font-family: var(--mono); font-size: 13px; }
.editor { counter-reset: ol; }

.editor .tick {
  flex: 0 0 auto; width: 17px; height: 17px; margin-top: 3px;
  border: 1px solid var(--fg3); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--accent); cursor: pointer; user-select: none;
}
.editor .ticked .tick { border-color: var(--accent); }
.editor .ticked .line-body { color: var(--fg3); text-decoration: line-through; }
.editor .line-body { flex: 1; min-width: 0; }

.editor a { color: var(--accent); }
.editor code { font-family: var(--mono); font-size: 0.92em; background: var(--surface); padding: 0 3px; }

.embed { margin: var(--sp3) 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--r-chip); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table-wrap td { border: 1px solid var(--hairline); padding: var(--sp2) var(--sp3); }

.attachment-image { margin: var(--sp3) 0; }
.attachment-image img {
  display: block;
  max-width: 100%;
  border-radius: var(--r-chip);
  border: 1px solid var(--hairline);
}
.attachment-loading {
  padding: var(--sp4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-chip);
  color: var(--fg3);
  font-size: 13px;
}

.attachment {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left;
  border: 1px solid var(--hairline); border-radius: var(--r-inner);
  padding: var(--sp3) var(--sp4);
}
.attachment:hover { background: var(--surface); }
.attachment-name { font-weight: 500; }
.attachment-detail { color: var(--fg3); font-size: 12px; font-family: var(--mono); }

.attachment-view {
  border-top: 1px solid var(--hairline); padding: var(--sp4);
  max-height: 45dvh; overflow: auto;
}
.attachment-view img { max-width: 100%; border-radius: var(--r-chip); display: block; }
.attachment-view audio, .attachment-view video { width: 100%; }

.only-narrow { display: none; }

/* ---- narrow ---- */

@media (max-width: 900px) {
  .app { grid-template-columns: 200px 1fr; }
  .detail { display: none; }
  .app.showing-note .list { display: none; }
  .app.showing-note .detail { display: flex; }
  .only-narrow { display: inline-block; }
}

@media (max-width: 620px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.showing-sidebar .sidebar { display: flex; }
}

/* ---- shared link view ---- */

.shared {
  max-width: 76ch;
  margin: 0 auto;
  padding: var(--sp6) var(--sp5) var(--sp8);
}
.shared-head { border-bottom: 1px solid var(--hairline); padding-bottom: var(--sp4); }
.shared-head h1 { font-size: 24px; margin: 0 0 var(--sp1); font-weight: 500; }
.shared-note {
  padding: var(--sp5) 0;
  border-bottom: 1px solid var(--hairline);
}
.shared-note h2 { font-size: 18px; margin: 0 0 var(--sp2); font-weight: 500; }
.shared-editor {
  padding: 0;
  max-width: none;
  overflow: visible;
  flex: none;
}
.shared-foot { padding-top: var(--sp5); }
