/* ============================================================================
   nullnote — the page is the note.
   Declassified-dossier maximalism: the whole viewport is one sheet of ruled
   evidence paper with a red margin; the chrome is carbon-copy black; every
   confirmation lands like a rubber stamp. One signature moment: the SAVED
   stamp thunks into the status strip on every save.
   ========================================================================== */

:root {
  --paper:      #f2efe4;
  --paper-deep: #eae6d6;
  --rule:       #d8d2bd;
  --margin-red: #c96a5b;
  --ink:        #211d15;
  --ink-soft:   #6f695a;
  --carbon:     #17140e;
  --carbon-ink: #cfc9b8;
  --stamp:      #a23325;
  --mono: "Courier Prime", "Courier New", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--mono);
  color: var(--ink);
  background: var(--carbon);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font-family: var(--mono); cursor: pointer; }
input, textarea { font-family: var(--mono); color: var(--ink); }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

/* ═══════════════════ carbon topbar ═══════════════════ */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--carbon);
  color: var(--carbon-ink);
  border-bottom: 3px double #3a352a;
}

.wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--carbon-ink);
  user-select: none;
  white-space: nowrap;
}
.wordmark span { color: var(--stamp); }

.linkchip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px;
  border: 1px solid #3a352a;
  background: #100e09;
}
.linkchip-url {
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--carbon-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.linkchip-ghost .linkchip-url { color: #5c5646; font-style: italic; }

.chipbtn {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--carbon-ink);
  background: transparent;
  border: 1px solid #4a4436;
  padding: 4px 9px;
  white-space: nowrap;
}
.chipbtn:hover { border-color: var(--carbon-ink); }
.chipbtn.danger { color: #d98a7c; border-color: #6b4038; }
.chipbtn.danger:hover { border-color: #d98a7c; }

.tools { display: flex; gap: 6px; margin-left: auto; }
.tool {
  position: relative;
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--carbon-ink);
  background: transparent;
  border: 1px solid #4a4436;
  transition: transform 0.08s ease, border-color 0.08s ease, color 0.08s ease;
}
.tool:hover { border-color: var(--stamp); color: #fff; transform: rotate(-2deg) translateY(-1px); }
.tool:active { transform: rotate(-2deg) translateY(1px); }
.tool-tag {
  position: absolute;
  bottom: 1px;
  font-size: 7px;
  letter-spacing: 0.18em;
  color: #6b6452;
}
.tool:hover .tool-tag { color: var(--stamp); }

/* ═══════════════════ the sheet ═══════════════════ */

.sheet-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background:
    linear-gradient(90deg, transparent 0 63px, var(--margin-red) 63px 65px, transparent 65px),
    repeating-linear-gradient(to bottom, var(--paper) 0 27px, var(--rule) 27px 28px),
    var(--paper);
}

.watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(20px, 4.5vw, 44px);
  font-weight: 700;
  letter-spacing: 0.35em;
  color: rgba(162, 51, 37, 0.07);
  transform: rotate(-14deg);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.sheet {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

.punchholes {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  pointer-events: none;
}
.punchholes i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--carbon);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.5);
}

.doc {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  padding: 24px 8vw 32px 96px;
  font-size: 15.5px;
  line-height: 28px; /* matches the ruled lines */
  color: var(--ink);
  caret-color: var(--stamp);
}
.doc::placeholder { color: #a49d87; }
.doc:focus { outline: none; }
.doc-static { overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* ── interstitials ── */

.inter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 20, 14, 0.35);
  padding: 20px;
}
.folder {
  max-width: 480px;
  background: var(--paper-deep);
  border: 1px solid #b9b29a;
  border-top: 14px solid #c9c2a8;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  padding: 26px 28px 24px;
  position: relative;
}
.folder p { font-size: 13.5px; line-height: 1.65; color: var(--ink); margin-bottom: 14px; }
.folder-title {
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.primary {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  padding: 11px 18px;
}
.primary:hover { background: var(--stamp); border-color: var(--stamp); }
.primary:disabled { opacity: 0.5; cursor: wait; }

/* ── stamps ── */

.stamp {
  display: inline-block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--stamp);
  border: 3px double var(--stamp);
  padding: 6px 14px;
  transform: rotate(-6deg);
  user-select: none;
}
.big-stamp { font-size: 15px; margin-bottom: 14px; }
.red-stamp { font-size: 13px; }

.destroyed {
  position: absolute;
  top: 18px;
  right: max(4vw, 24px);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper-deep);
  border: 1px solid var(--stamp);
  padding: 12px 16px;
  max-width: 420px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.destroyed p { font-size: 12px; line-height: 1.5; }

/* ═══════════════════ status strip ═══════════════════ */

.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--carbon);
  color: #8d8672;
  font-size: 11px;
  letter-spacing: 0.1em;
  border-top: 3px double #3a352a;
  min-height: 36px;
}
.s-fill { flex: 1; }
.s-sep { color: #4a4436; }

.s-saved { color: var(--carbon-ink); font-weight: 700; }
.s-saved.thunk { animation: thunk 0.35s cubic-bezier(0.2, 2.2, 0.4, 1); }
@keyframes thunk {
  0%   { transform: scale(1.7) rotate(-5deg); opacity: 0; color: var(--stamp); }
  60%  { transform: scale(0.96) rotate(0.5deg); opacity: 1; color: var(--stamp); }
  100% { transform: scale(1) rotate(0); }
}

/* ═══════════════════ drawers ═══════════════════ */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 14, 0.45);
  z-index: 9;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 94vw);
  z-index: 10;
  background: var(--paper-deep);
  border-left: 4px solid var(--carbon);
  box-shadow: -18px 0 50px rgba(0,0,0,0.5);
  padding: 20px 22px 28px;
  overflow-y: auto;
  animation: slide-in 0.18s ease;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 3px double var(--rule);
}
.drawer-head h2 {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.drawer-head .chipbtn { color: var(--ink-soft); border-color: #b9b29a; }
.drawer-head .chipbtn:hover { color: var(--ink); border-color: var(--ink); }

.drawer .chipbtn { color: var(--ink-soft); border-color: #b9b29a; }
.drawer .chipbtn:hover { color: var(--ink); border-color: var(--ink); }
.drawer .chipbtn.danger { color: var(--stamp); border-color: #cf9a90; }

.prose { font-size: 13px; line-height: 1.65; margin-bottom: 14px; }
.prose.small { font-size: 12px; color: var(--ink-soft); }
.prose code, .outbox code { background: rgba(0,0,0,0.06); padding: 1px 4px; }
.tor-line { word-break: break-all; }

.lbl {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 12px 0 5px;
}

.drawer input[type="text"],
.drawer input[type="password"],
.outbox input[type="text"] {
  width: 100%;
  font-size: 13.5px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid #b9b29a;
}
.drawer input:focus { outline: none; border-color: var(--ink); }

.strength { font-size: 11px; letter-spacing: 0.12em; margin: 8px 0 4px; min-height: 14px; font-weight: 700; }
.strength[data-level="weak"]   { color: var(--stamp); }
.strength[data-level="fair"]   { color: #8a6d1f; }
.strength[data-level="strong"] { color: #3e6b34; }

.drawer .row { margin-top: 12px; }
.status { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.04em; }

.outbox {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.outbox .lbl { grid-column: 1 / -1; margin: 0 0 2px; }

/* notebook list */
.book-toprow { margin-bottom: 12px; }
.nb-list { display: flex; flex-direction: column; }
.nb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--rule);
}
.nb-row:first-child { border-top: 1px solid var(--rule); }
.nb-title {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════ errors ═══════════════════ */

.error {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(560px, 92vw);
  background: var(--paper-deep);
  color: var(--stamp);
  border: 2px solid var(--stamp);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* ═══════════════════ responsive & motion ═══════════════════ */

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .linkchip, .linkchip-ghost { order: 3; width: 100%; }
  .tools { margin-left: 0; }
  .tool { width: 40px; height: 36px; }
  .doc { padding: 18px 16px 28px 52px; font-size: 15px; }
  .sheet-wrap { background:
    linear-gradient(90deg, transparent 0 33px, var(--margin-red) 33px 35px, transparent 35px),
    repeating-linear-gradient(to bottom, var(--paper) 0 27px, var(--rule) 27px 28px),
    var(--paper); }
  .punchholes { left: 6px; }
  .punchholes i { width: 14px; height: 14px; }
  .watermark { font-size: 16px; }
  .destroyed { position: static; margin: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .s-saved.thunk { animation: none; }
  .drawer { animation: none; }
  .tool, .tool:hover, .tool:active { transition: none; transform: none; }
}
