/* Steep on the web: the Editorial look the Mac has — paper, ink, one dark red
   accent, a serif for what you write and a sans for everything around it. */

:root {
  /* The settled Editorial palette: warm paper, oxblood. */
  --paper: #fbf9f3;
  --chrome: #f3efe6;
  --ink: #1f1b16;
  --muted: #857d72;
  --rule: #e2dbcd;
  --accent: #8c3a2b;
  --code: #f0eadf;
  --hover: rgba(31, 27, 22, 0.05);
  --selected: rgba(140, 58, 43, 0.1);
  --button: #000;
  --button-ink: #fff;
  --serif: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #221f1a;
    --chrome: #2a2621;
    --ink: #ece6dc;
    --muted: #978e82;
    --rule: #3b3630;
    --accent: #ce7a5c;
    --code: #2f2b26;
    --hover: rgba(236, 230, 220, 0.06);
    --selected: rgba(206, 122, 92, 0.16);
    /* Apple's guidance: a white button on a dark page. */
    --button: #fff;
    --button-ink: #000;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.4 var(--sans); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* MARK: Welcome — signing in, first download, missing key.
   One quiet column in the middle of the page: the mark, the name, a line,
   and the one thing to do. */

.welcome {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px 12vh; text-align: center;
  background: radial-gradient(120% 70% at 50% 0%, var(--chrome), var(--paper) 60%);
}
.welcome .mark { width: 76px; height: 76px; margin-bottom: 22px; filter: drop-shadow(0 6px 18px rgba(140, 58, 43, 0.22)); }
.welcome h1 { font: 500 44px/1.05 var(--serif); letter-spacing: -0.01em; margin: 0; }
.welcome .lede { font: 17px/1.45 var(--sans); color: var(--muted); margin: 10px 0 36px; max-width: 22rem; }
.welcome .fine { font: 12.5px/1.5 var(--sans); color: var(--muted); max-width: 19rem; margin: 20px 0 0; opacity: 0.85; }
.welcome code { font: 12px var(--mono); }

/* Sign in with Apple, drawn to Apple's current guidance: the logo and the
   words centered together, system type, a full-width capsule of its own. */
.apple-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 300px; height: 50px; border-radius: 12px;
  background: var(--button); color: var(--button-ink);
  font: 500 17px/1 var(--sans); letter-spacing: -0.01em;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.apple-button svg { width: 15px; height: 18px; margin-top: -3px; }
.apple-button:hover { opacity: 0.86; }
.apple-button:active { transform: scale(0.985); }
.apple-button:focus-visible { outline: 3px solid var(--selected); outline-offset: 3px; }

/* CloudKit's own buttons: present, clickable by code, never seen. */
.ck-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

.progress { width: 180px; height: 3px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.progress span { display: block; width: 40%; height: 100%; border-radius: 2px; background: var(--accent); animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .progress span { animation: none; width: 100%; opacity: 0.5; } }

/* MARK: Three columns */

#app { display: grid; grid-template-columns: 280px 300px 1fr; height: 100vh; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#sidebar, #list { background: var(--chrome); border-right: 1px solid var(--rule); }
.bar { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--rule); }
.bar h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; font-size: 24px; line-height: 1; color: var(--accent); padding: 0 6px 0 0; }

#search { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
#search:focus { outline: 2px solid var(--selected); border-color: var(--accent); }

ul { list-style: none; margin: 0; padding: 0; }
#folders, #notes { flex: 1; overflow-y: auto; padding: 6px 0 24px; }

/* Depth reads from type as on the Mac: caps at the top, smaller and lighter
   further in, with the indent stopping at level four. */
.folder { display: flex; align-items: center; padding-left: calc(var(--depth) * 10px + 4px); }
.folder .twisty { width: 22px; height: 34px; color: var(--muted); }
.folder .chev { display: inline-block; transition: transform 0.12s; font-size: 16px; }
.folder .chev.open { transform: rotate(90deg); }
.folder .twisty[hidden] { display: block !important; visibility: hidden; }
.folder .open { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; height: 34px; padding-right: 16px; border-radius: 6px; text-align: left; }
.folder .open:hover { background: var(--hover); }
.folder.selected .open { background: var(--selected); }
.folder .dot { flex: none; width: 6px; height: 6px; border-radius: 50%; }
.folder .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.folder.d0 .name { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; font-weight: 600; }
.folder.d1 .name { font-weight: 600; font-size: 13.5px; }
.folder.d2 .name { font-weight: 500; font-size: 13px; }
.folder.d4 .name { color: var(--muted); }
.folder .pin { font-size: 10px; }
.folder .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 12px; }
#sign-out { color: var(--muted); font-size: 12px; }
#sign-out:hover { color: var(--accent); }

.note-row button { display: block; width: 100%; padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--rule); }
.note-row button:hover { background: var(--hover); }
.note-row.selected button { background: var(--selected); }
.note-row .title { display: block; font: 16px/1.3 var(--serif); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-row .meta { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#notes .empty { padding: 24px 16px; color: var(--muted); }
#new-note { font-size: 20px; color: var(--accent); padding: 0 4px; }

#page { background: var(--paper); }
#page .bar { justify-content: space-between; }
#save-state { color: var(--muted); font-size: 12px; }
#save-state[data-state="error"] { color: var(--accent); }
#note-tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
#note-tools button { color: var(--accent); font-size: 13px; }
.scroll { flex: 1; overflow-y: auto; }
#editor-empty { margin: 30vh auto; text-align: center; color: var(--muted); }

/* MARK: The note */

#editor { max-width: 44rem; margin: 0 auto; padding: 40px 32px 40vh; font: 18px/1.6 var(--serif); }
.blk { position: relative; padding-left: calc(var(--depth, 0) * 1.6em); }
.txt { outline: none; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.6em; }
.txt code { font: 0.86em var(--mono); background: var(--code); padding: 0.1em 0.3em; border-radius: 4px; }
.txt mark { background: rgba(240, 200, 60, 0.4); color: inherit; }
.txt a { color: var(--accent); }
.txt .tag { color: var(--accent); }

.t-heading { margin-top: 0.8em; }
.t-heading .txt { font-weight: 600; line-height: 1.25; }
.h1 .txt { font-size: 1.75em; }
.h2 .txt { font-size: 1.35em; }
.h3 .txt { font-size: 1.12em; }
.blk:first-child.t-heading { margin-top: 0; }
.blk:first-child.h1 .txt:empty::before { content: "Title"; color: var(--muted); }

.t-bulleted, .t-numbered, .t-todo { padding-left: calc(var(--depth, 0) * 1.6em + 1.6em); }
.t-bulleted::before, .t-numbered::before { position: absolute; left: calc(var(--depth, 0) * 1.6em); width: 1.2em; text-align: right; color: var(--muted); }
.t-bulleted::before { content: "•"; }
.t-numbered::before { content: attr(data-num); font-variant-numeric: tabular-nums; }
/* Centered on the first line, not the whole block: a holder one line tall. */
.t-todo .check-line { position: absolute; left: calc(var(--depth, 0) * 1.6em + 0.1em); top: 0; height: 1.6em; display: flex; align-items: center; }
/* A form control keeps the browser's own 13px type unless told otherwise;
   inheriting makes the box scale with the note's text. */
.t-todo .check { font-size: inherit; width: 0.9em; height: 0.9em; margin: 0; accent-color: var(--accent); cursor: pointer; }
.t-todo.done .txt { color: var(--muted); text-decoration: line-through; }

.t-quote .txt { border-left: 3px solid var(--rule); padding-left: 1em; color: var(--muted); font-style: italic; }

/* A run of code lines reads as one panel. */
.t-code { background: var(--code); padding: 0 1em; }
.t-code .txt { font: 14.5px/1.55 var(--mono); }
:not(.t-code) + .t-code { border-radius: 8px 8px 0 0; padding-top: 0.6em; margin-top: 0.4em; }
.t-code:not(:has(+ .t-code)) { border-radius: 0 0 8px 8px; padding-bottom: 0.6em; margin-bottom: 0.4em; }
:not(.t-code) + .t-code:not(:has(+ .t-code)) { border-radius: 8px; }

.embedded { margin: 0.6em 0; user-select: none; }
.embedded hr { border: 0; border-top: 1px solid var(--rule); margin: 1em 0; }
.embedded img { max-width: 100%; height: auto; border-radius: 6px; display: block; }
.card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--chrome); color: var(--ink); text-decoration: none; font: 14px/1.4 var(--sans); }
.card.file { flex-direction: row; align-items: center; gap: 10px; }
.card small { color: var(--muted); margin-left: 6px; }
.card.link small { margin-left: 0; }
.card.link span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.embedded table { border-collapse: collapse; font: 14px/1.4 var(--sans); }
.embedded td, .embedded th { border: 1px solid var(--rule); padding: 6px 10px; vertical-align: top; text-align: left; }
.embedded th { background: var(--chrome); }

/* MARK: One column at a time on a narrow window */

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .pane { display: none; height: 100vh; }
  body[data-pane="folders"] #sidebar,
  body[data-pane="notes"] #list,
  body[data-pane="editor"] #page { display: flex; }
  .back { display: block; }
  #sidebar, #list { border-right: 0; }
  #editor { padding: 24px 16px 40vh; }
}
