:root {
  --paper: #f4efe3;
  --surface: #fbf8f0;
  --ink: #1c211e;
  --muted: #6b6a5f;
  --line: #d6cdb8;
  --line-soft: #e7e0cf;
  --brand: #1f3d33;
  --brand-ink: #f6f1e7;
  --brass: #b08a34;
  --err: #9b2c2c;
  --ok: #2f6b3f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121613;
    --surface: #181d19;
    --ink: #ece6d4;
    --muted: #9a9888;
    --line: #2f372f;
    --line-soft: #252c26;
    --brand: #d6b36a;
    --brand-ink: #17170f;
    --brass: #d6b36a;
    --err: #e08a7a;
    --ok: #86c08f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.005em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 19px; margin-bottom: 4px; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 3px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { color: var(--err); font-size: 13.5px; }
.center { text-align: center; }

/* sections: ruled, not boxed */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 22px 24px;
}
.card > h2:first-child { padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line-soft); }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  min-height: 56px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.wordmark { font: 600 20px/1 var(--serif); letter-spacing: -.01em; }
.wordmark em { font-style: normal; font-weight: 400; color: var(--muted); }
.tabs { display: flex; gap: 22px; flex: 1; align-self: stretch; }
.tab {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: -1px;
}
.tab:hover { background: transparent; color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.topbar > button:last-child { border: 0; padding: 4px 0; color: var(--muted); }
.topbar > button:last-child:hover { background: transparent; color: var(--ink); text-decoration: underline; }

main { max-width: 1000px; margin: 0 auto; padding: 32px 24px 96px; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* form controls */
label.field { display: block; margin-top: 16px; }
label.field:first-child { margin-top: 0; }
label.field > span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; letter-spacing: .01em; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

button, .btn {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: 3px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--line-soft); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(1.12); background: var(--brand); }
button.primary.warn { background: var(--err); border-color: var(--err); color: #fff; }
button.danger:hover { color: var(--err); border-color: var(--err); background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; }
.setting + .setting { border-top: 1px solid var(--line-soft); }
.card > .setting:first-child { padding-top: 0; }

/* switch: a button with role=switch, square-cornered */
.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--line);
  cursor: pointer;
  transition: background .15s;
}
.switch:hover { background: var(--line); filter: brightness(.95); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform .15s;
}
.switch[aria-checked="true"], .switch[aria-checked="true"]:hover { background: var(--brand); filter: none; }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* tags */
.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--muted);
}
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--err); }

/* sign-in page */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-hero {
  background: #1f3d33;
  color: #f6f1e7;
  padding: 56px clamp(32px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
}
.auth .logo svg { width: 64px; height: 64px; }
.auth .logo { display: flex; align-items: center; gap: 16px; }
.auth .logo .wordmark { font-size: 30px; }
.auth .logo .wordmark em { color: #d6b36a; }
.auth-hero blockquote { margin: 0; max-width: 28ch; font: 400 clamp(26px, 3.4vw, 38px)/1.25 var(--serif); letter-spacing: -.01em; }
.auth-hero small { color: #b9c4bb; font-size: 13px; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 20px; }
.auth-card h2 { font-size: 24px; margin: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 4px; }
.auth-card button.primary { margin-top: 18px; padding: 10px 15px; }
.switch-mode { font-size: 13.5px; color: var(--muted); }
.switch-mode button { border: 0; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.switch-mode button:hover { background: transparent; }
@media (max-width: 800px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px; gap: 20px; }
  .auth-hero blockquote, .auth-hero small { display: none; }
  .auth .logo svg { width: 44px; height: 44px; }
  .auth .logo .wordmark { font-size: 24px; }
}

/* notes */
.notes-layout { display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .notes-layout { grid-template-columns: 1fr; gap: 20px; } }
.sidebar { display: flex; flex-direction: column; gap: 12px; }
.sidebar .actions { display: flex; gap: 8px; }
.sidebar .actions button { flex: 1; }
.note-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 62vh; overflow: auto; border-top: 1px solid var(--line); }
.note-item { padding: 11px 10px 11px 12px; border-bottom: 1px solid var(--line-soft); border-left: 3px solid transparent; cursor: pointer; }
.note-item:hover { background: var(--line-soft); }
.note-item.active { background: var(--surface); border-left-color: var(--brand); }
.note-item .t { font: 600 16px/1.3 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the sheet of paper you write on */
.editor { display: flex; flex-direction: column; gap: 10px; min-height: 420px; padding: 26px 32px 24px; }
.editor .title { font: 600 28px/1.2 var(--serif); letter-spacing: -.01em; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 0 0 12px; }
.editor .title:focus { outline: none; border-bottom-color: var(--brand); }
.editor .bar { display: flex; align-items: center; gap: 12px; }
.editor .bar .grow { flex: 1; }
.editor textarea {
  flex: 1;
  min-height: 320px;
  border: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 29px, var(--line-soft) 29px, var(--line-soft) 30px);
  background-attachment: local;
  font: 17px/30px var(--serif);
  padding: 0 2px;
  resize: vertical;
}
.editor textarea:focus { outline: none; }
.empty { text-align: center; color: var(--muted); padding: 64px 16px; font-family: var(--serif); font-size: 17px; }
.drop-over { outline: 2px dashed var(--brand); outline-offset: 8px; }

/* extension settings */
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.notes-use { list-style: none; margin: 10px 0 0; padding: 0; }
.notes-use li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.notes-use .t { font-family: var(--serif); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; }
.stat { padding: 4px 20px; border-left: 1px solid var(--line); }
.stat:first-child { padding-left: 0; border-left: 0; }
.stat .n { font: 600 28px/1.2 var(--serif); letter-spacing: -.01em; font-variant-numeric: lining-nums tabular-nums; }

/* admin ledger */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .09em; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input[type=number] { width: 84px; padding: 5px 8px; }
tbody tr:hover { background: var(--line-soft); }
.bar-track { height: 6px; border-radius: 1px; background: var(--line); overflow: hidden; margin-top: 14px; }
.bar-fill { height: 100%; background: var(--brand); }
.bar-fill.hot { background: var(--err); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 16px);
  padding: 8px 16px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* .btn links styled like buttons */
a.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
a.btn.primary:hover { filter: brightness(1.12); background: var(--brand); }
.btn.big { padding: 13px 24px; font-size: 16px; }
td input.limit, input.limit { width: 92px; padding: 5px 8px; }

/* modal (replaces confirm()) */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(12, 16, 13, .55); }
.modal { width: 100%; max-width: 400px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); }
.modal h2 { font-size: 21px; margin-bottom: 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal .field { margin-top: 16px; }
.pin-input { text-align: center; font: 600 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5em; text-indent: .5em; }

/* update banner */
#banner:empty { display: none; }
.banner { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 10px 24px; background: var(--brand); color: var(--brand-ink); font-size: 14px; }
.banner a { color: inherit; font-weight: 600; }

/* install steps */
.steps-list { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.steps-list code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; background: var(--line-soft); border-radius: 2px; }
.release-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dropzone { margin-top: 12px; padding: 22px; text-align: center; border: 1px dashed var(--line); border-radius: 3px; color: var(--muted); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); color: var(--ink); }

/* homepage */
body.home { background: var(--paper); }
.home-wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.home-nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1120px; margin: 0 auto; padding: 22px 24px; }
.home-nav nav { display: flex; align-items: center; gap: 28px; }
.home-nav .link, .home-foot .link { color: var(--muted); text-decoration: none; }
.home-nav .link:hover, .home-foot .link:hover { color: var(--ink); }
@media (max-width: 720px) { .home-nav nav .link:not(#navSignin) { display: none; } .home-nav nav { gap: 16px; } }

.home-hero { max-width: 1120px; margin: 0 auto; padding: 48px 24px 96px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 80px); align-items: center; }
@media (max-width: 900px) { .home-hero { grid-template-columns: 1fr; padding-top: 24px; } }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); margin-bottom: 18px; }
.home-hero h1 { font-size: clamp(42px, 6vw, 72px); line-height: 1.03; letter-spacing: -.025em; font-weight: 600; }
.home-hero h1 em { font-style: italic; font-weight: 500; color: var(--brand); white-space: nowrap; }
.lede { margin-top: 24px; max-width: 46ch; font-size: 19px; line-height: 1.55; color: var(--muted); }
.cta-row { display: flex; align-items: center; gap: 24px; margin-top: 36px; flex-wrap: wrap; }
.link-quiet { color: var(--ink); text-underline-offset: 4px; }

/* product mock */
.mock { position: relative; padding: 0 0 24px 16px; }
.mock-back { position: absolute; inset: 28px 0 0 36px; background: var(--line-soft); border: 1px solid var(--line); border-radius: 3px; transform: rotate(2.2deg); }
.mock-window { position: relative; display: grid; grid-template-columns: 38% 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; box-shadow: 0 30px 60px -30px rgba(31, 61, 51, .35); transform: rotate(-.8deg); overflow: hidden; }
.mock-list { list-style: none; margin: 0; padding: 0; border-right: 1px solid var(--line); }
.mock-list li { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); border-left: 3px solid transparent; display: flex; flex-direction: column; gap: 1px; }
.mock-list li.on { background: var(--paper); border-left-color: var(--brand); }
.mock-list b { font: 600 14.5px/1.3 var(--serif); }
.mock-list span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-sheet { padding: 22px 24px 28px; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 27px, var(--line-soft) 27px, var(--line-soft) 28px); background-position: 0 4px; }
.mock-sheet h3 { font-size: 22px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.mock-sheet p { font: 15px/28px var(--serif); }
.mock-sheet .faded { color: var(--muted); font-style: italic; }
@media (max-width: 520px) { .mock-window { grid-template-columns: 1fr; } .mock-list { display: none; } }

.home-features { border-top: 1px solid var(--line); padding: 88px 0; background: var(--surface); }
.section-title { font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -.015em; max-width: 20ch; margin-bottom: 48px; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; gap: 28px; } }
.features article { border-top: 2px solid var(--ink); padding-top: 18px; }
.features .num { font: 500 15px var(--serif); color: var(--brass); font-style: italic; }
.features h3 { font-size: 24px; margin: 8px 0 10px; }
.features p { color: var(--muted); max-width: 34ch; }

.home-band { background: #1f3d33; color: #f6f1e7; padding: 88px 0; }
.home-band blockquote { margin: 0 0 56px; max-width: 24ch; font: 500 clamp(32px, 4.6vw, 56px)/1.12 var(--serif); letter-spacing: -.02em; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; gap: 20px; } }
.steps li { border-top: 1px solid rgba(246, 241, 231, .3); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.steps b { font: 600 18px var(--serif); color: #d6b36a; }
.steps span { color: #c9d3cb; }

.home-cta { text-align: center; padding: 104px 24px; }
.home-cta h2 { font-size: clamp(32px, 4.4vw, 52px); letter-spacing: -.02em; margin-bottom: 10px; }
.home-cta p { margin-bottom: 30px; font-size: 17px; }
.home-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1120px; margin: 0 auto; padding: 28px 24px 40px; border-top: 1px solid var(--line); }
.home-foot .wordmark { font-size: 16px; }
.home-foot nav { display: flex; gap: 22px; }

/* alert strip */
.alert { padding: 12px 16px; background: var(--surface); border: 1px solid var(--err); border-left-width: 4px; border-radius: 3px; color: var(--ink); }
.alert strong { color: var(--err); }
.credit-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.credit-row input { width: 120px; }
