/* neapolt.com — folders behind one code.
   Pastel stationery: graph-paper background, white cards, soft ink, and one
   emoji per row where it earns its place. */

@import url('/fonts.css');

:root {
  --paper: #fcfbf7;
  --grid-minor: #e4e7f2;
  --grid-major: #d2d9ea;

  --card: #ffffff;
  --ink: #34344e;
  --ink-soft: #5f5f7c;
  --ink-faint: #6f6f8a;
  --line: #d7d3e6;

  --lilac: #e3dafa;
  --lilac-deep: #b7a4e6;
  --mint: #d5f0e3;
  --mint-deep: #85c9aa;
  --peach: #fde2d6;
  --peach-deep: #f0b39a;
  --butter: #fbeec4;
  --sky: #dcebfb;
  --rose: #f7d9e2;

  --display: "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  /* terms and notices read as a document, not as UI */
  --legal: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

/* graph paper: fine lines every 24px, heavier every 120px */
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px 120px),
    repeating-linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px 120px),
    repeating-linear-gradient(to right, var(--grid-minor) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(to bottom, var(--grid-minor) 0 1px, transparent 1px 24px);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- doodles */

.doodle {
  position: fixed;
  pointer-events: none;
  z-index: 0;
}
.doodle--sun { top: -26px; right: -26px; width: 138px; }
.doodle--cloud-a { top: 88px; left: -30px; width: 120px; }
.doodle--cloud-b { bottom: 70px; right: 54px; width: 96px; }
.doodle--moon { display: none; top: -30px; right: -30px; width: 132px; }

/* ---------------------------------------------------------------- the gate */

.gate {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 22px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 28px 26px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(70, 60, 110, 0.09);
  text-align: center;
}

.mascot { width: 92px; display: block; margin: -2px auto 10px; }

.gate h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 33px;
  line-height: 1.12;
  margin: 0 0 8px;
}

.gate-sub {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0 0 22px;
}

.gate-label {
  display: inline-block;
  padding: 4px 11px 3px;
  margin-bottom: 10px;
  font-family: var(--display);
  font-size: 14.5px;
  background: var(--butter);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  transform: rotate(-1.2deg);
}

.gate-input {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  padding: 14px 14px 13px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 120ms linear, background 120ms linear;
}
.gate-input::placeholder { color: #83819a; font-weight: 400; letter-spacing: 0.02em; }
.gate-input:focus { border-color: var(--lilac-deep); background: #fbf8ff; }

.gate-button {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px 13px;
  font-family: var(--display);
  font-size: 18px;
  color: var(--ink);
  background: var(--lilac);
  border: 2px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 4px 0 var(--lilac-deep);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 90ms linear, box-shadow 90ms linear, background 90ms linear;
}
.gate-button:hover { background: #ece5ff; }
.gate-button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lilac-deep); }
.gate-button:disabled { opacity: 0.65; cursor: progress; transform: translateY(3px); box-shadow: 0 1px 0 var(--lilac-deep); }

.gate-status {
  /* in normal flow: an absolutely positioned line was landing off-screen */
  margin: 14px 0 0;
  min-height: 22px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.45;
  color: #a3455f;
}
.gate-status.is-note { color: var(--ink-soft); }

/* a wrong code: the field nudges, the border says no, the mascot frowns */
.gate-input[aria-invalid="true"] {
  border-color: #c2536b;
  background: #fff4f6;
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
  88% { transform: translateX(2px); }
}

.gate-input.nudge { animation: nudge 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ---------------------------------------------------------------- vault */

.split {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.side {
  position: relative;
  padding: 20px 18px 30px;
  background: rgba(245, 242, 253, 0.82);
  border-right: 1.5px solid var(--line);
  backdrop-filter: blur(1px);
}

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  row-gap: 8px;
}

.side-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 20px;
  line-height: 1;
  white-space: nowrap;
  flex: none;
}
.side-title .ico { font-family: var(--emoji); font-size: 17px; }

.side-out {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 11px 5px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 90ms linear, color 90ms linear;
}
.side-out:hover { border-color: var(--ink); color: var(--ink); }

.side-empty {
  font-size: 15.5px;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

.side-search { margin: 0 0 12px; }

.search-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 8px 11px 7px;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 90ms linear, background 90ms linear;
}
.search-input::placeholder { color: var(--ink-faint); font-weight: 400; }
.search-input:focus { border-color: var(--lilac-deep); background: #fbf8ff; }

.tree,
.tree ul { list-style: none; margin: 0; padding: 0; }

.tree ul {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1.5px dotted #cfc9e4;
}

.tree details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-family: var(--display);
  font-size: 17px;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
}
.tree details > summary::-webkit-details-marker { display: none; }

/* one emoji per folder row, closed and open */
.tree details > summary::before {
  content: attr(data-icon);
  font-family: var(--emoji);
  font-size: 17px;
  line-height: 1;
  flex: none;
}
.tree details > summary:hover { color: #6a4fb0; }
.tree details > summary[data-tone="warn"] { color: #8c3f56; }
.tree details > summary[data-tone="warn"]:hover { color: #a3455f; }

.tree .count {
  margin-left: auto;
  padding: 1px 8px 0;
  font-family: var(--body);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 8px;
}

.file {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px 6px;
  margin: 2px 0;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.4;
  text-align: left;
  word-break: break-word;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 90ms linear, border-color 90ms linear;
}
.file::before {
  font-family: var(--emoji);
  font-size: 14px;
  line-height: 1;
  flex: none;
  content: "📦";
}
.file.k-pdf::before { content: "📄"; }
.file.k-img::before { content: "🖼️"; }
.file.k-txt::before { content: "📝"; }
.file:hover { background: var(--card); border-color: var(--line); }
.file[aria-current="true"] {
  background: var(--mint);
  border-color: var(--mint-deep);
}

/* ---------------------------------------------------------------- pane */

.pane {
  min-width: 0;
  padding: 28px 32px 50px;
}

/* how this code differs from a normal one — kept in the sidebar so it is still
   visible on a phone, where the reading pane is hidden until a file is opened */
.mode-note,
.offline-note {
  margin: 0 0 10px;
  padding: 8px 11px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 10px;
  border: 1.5px solid;
}
.mode-note {
  color: #6b4fa8;
  background: rgba(227, 218, 250, 0.55);
  border-color: var(--lilac-deep);
}
.offline-note {
  color: #8a6a1f;
  background: rgba(251, 238, 196, 0.7);
  border-color: #e0c46a;
}

.blank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 55vh;
  text-align: center;
}

.blank-mascot { width: 84px; }

.blank-text {
  font-family: var(--display);
  font-size: 21px;
  color: var(--ink-faint);
  margin: 0;
}

.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 15px 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(70, 60, 110, 0.06);
}

.doc-ident { min-width: 0; }

.doc-name {
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-all;
}

.doc-meta {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-faint);
}

.doc-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.doc-open,
.doc-download {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  padding: 7px 13px 6px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 90ms linear, border-color 90ms linear;
}
.doc-open:hover,
.doc-download:hover { background: var(--sky); border-color: var(--line); }
.doc-download { background: var(--lilac); border-color: var(--lilac-deep); }
.doc-download:hover { background: #ece5ff; }

/* An explicit way out to the raw document, for anyone who prefers the
   browser's own full-screen viewer or wants to save the file. */
.doc-open { display: inline-block; }

.doc-back { display: none; }

/* ---------------------------------------------- document viewer
   The server rasterises each page with poppler and this is a plain <img>:
   no plugin, no canvas, no worker, nothing a browser can refuse. */

.reader {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.reader-bar {
  display: flex;
  align-items: center;
  gap: 7px;
}

.reader-btn {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-family: var(--body);
  font-size: 19px;
  line-height: 1;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 90ms linear, border-color 90ms linear;
}
.reader-btn:hover:not(:disabled) { background: var(--sky); border-color: var(--line); }
.reader-btn:disabled { opacity: 0.4; cursor: default; }
.reader-btn--wide {
  width: auto;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.reader-count {
  padding: 0 4px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
}
.reader-slash { opacity: 0.45; margin: 0 4px; }
.reader-gap { flex: 1; }
.reader-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* a definite height, so the page can be fitted to it without a circular
     dependency between image size and stage size */
  height: calc(100dvh - 280px);
  min-height: 340px;
  padding: 10px;
  overflow: auto;
  background: #f7f5fc;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}

.reader-canvas {
  display: block;
  max-width: 100%;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 3px 14px rgba(60, 50, 90, 0.12);
  cursor: pointer;
}

.reader-shot {
  display: block;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 3px 14px rgba(60, 50, 90, 0.12);
  cursor: pointer;
}

.reader-status {
  margin: 0;
  padding: 30px 16px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink-faint);
  text-align: center;
}

/* filmstrip of pages */
.reader-strip {
  display: flex;
  flex: none;
  gap: 6px;
  padding: 2px 2px 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.thumb {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 58px;
  padding: 3px;
  line-height: 0;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 90ms linear, box-shadow 90ms linear;
}
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #ffffff;
}
.thumb:hover { border-color: var(--ink); }
.thumb[aria-current="true"] {
  border-color: var(--lilac-deep);
  box-shadow: 0 0 0 2px var(--lilac);
}

.doc-image {
  display: block;
  max-width: 100%;
  margin-top: 16px;
  background: #ffffff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}

.doc-body {
  margin: 16px 0 0;
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.75;
  color: #3b3b57;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}

/* the terms file reads as a document, not as code */
.doc-body--legal {
  font-family: var(--legal);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 62ch;
}

.doc-note {
  margin: 16px 0 0;
  padding: 14px 16px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--rose);
  border: 1.5px dashed var(--peach-deep);
  border-radius: 12px;
}

/* ---------------------------------------------------------------- phone */

@media (max-width: 900px) {
  .doodle--sun { width: 104px; top: -22px; right: -22px; }
  .doodle--cloud-a { width: 88px; top: 66px; }
  .doodle--cloud-b { display: none; }

  .gate { padding: 26px 16px; }
  .gate-card { padding: 22px 18px 26px; border-radius: 18px; }
  .gate h1 { font-size: 29px; }
  .mascot { width: 76px; }

  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 100dvh;
  }

  .side {
    border-right: 0;
    max-height: none;
    overflow: visible;
    padding: calc(16px + env(safe-area-inset-top)) 15px calc(24px + env(safe-area-inset-bottom));
  }

  .page-files:not(.has-doc) .pane { display: none; }

  .page-files.has-doc { overflow: hidden; }

  .page-files.has-doc .pane {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--paper);
    background-image:
      repeating-linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px 120px),
      repeating-linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px 120px),
      repeating-linear-gradient(to right, var(--grid-minor) 0 1px, transparent 1px 24px),
      repeating-linear-gradient(to bottom, var(--grid-minor) 0 1px, transparent 1px 24px);
    padding: calc(12px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  }

  .page-files.has-doc .doc {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
  }

  /* thumb-sized targets */
  .tree details > summary { padding: 10px 0; }
  .file { padding: 10px; font-size: 16px; }

  /* on a phone the header goes flat, so the screen is one sheet, not three */
  .doc-head {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 0 2px 8px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .doc-actions { width: 100%; }
  .doc-download { flex: 1; text-align: center; padding: 10px 14px 9px; }
  .doc-open { display: none; }

  .doc-back {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 11px 5px;
    font-family: var(--body);
    font-weight: 700;
    font-size: 12.5px;
    color: var(--ink-soft);
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    touch-action: manipulation;
  }
  .doc-back::before { content: "‹"; font-size: 16px; line-height: 0.9; }

  .doc-name { font-size: 17.5px; }

  .side-search { margin-bottom: 10px; }
  .reader-strip { gap: 5px; }
  .thumb { width: 48px; }

  /* let the page fill the phone screen; the stage scrolls inside */
  .page-files.has-doc .reader { flex: 1; min-height: 0; margin-top: 6px; }
  .page-files.has-doc .reader-stage { flex: 1; height: auto; min-height: 200px; padding: 6px; }
  .reader-btn { width: 38px; height: 38px; }

  .doc-image,
  .doc-body,
  .doc-note { margin-top: 12px; }
  .doc-body { padding: 14px 15px; }
}

/* ---------------------------------------------------------------- the notice */

.notice {
  width: min(92vw, 470px);
  max-width: 470px;
  padding: 26px 26px 22px;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(40, 30, 70, 0.28);
}
.notice::backdrop { background: rgba(30, 26, 45, 0.45); }

.notice-kicker {
  margin: 0 0 8px;
  font-family: var(--emoji);
  font-size: 30px;
  line-height: 1;
}

.notice-title {
  margin: 0 0 12px;
  font-family: var(--legal);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.notice-body {
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
  font-family: var(--legal);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  scrollbar-width: thin;
}

/* emphasis inside the terms: a highlighter, not a colour */
.notice-body mark,
.doc-body mark {
  padding: 0 3px 1px;
  color: var(--ink);
  background: #ffe9a8;
  border-radius: 3px;
}
.notice-body strong,
.doc-body strong { color: var(--ink); font-weight: 700; }

.notice-ok {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 20px;
  padding: 13px 16px 12px;
  font-family: var(--display);
  font-size: 17px;
  color: var(--ink);
  background: var(--lilac);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--lilac-deep);
  cursor: pointer;
  touch-action: manipulation;
}
.notice-ok:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lilac-deep); }

html.dark .notice { background: #221f33; border-color: #4a4468; }
html.dark .notice-ok { background: #5b4f95; border-color: #2b2547; color: #f6f3ff; box-shadow: 0 4px 0 #3b3364; }
html.dark .notice-body mark,
html.dark .doc-body mark { background: #4a3f1e; color: #ffe9a8; }

/* ---------------------------------------------------------------- the toggle */

.side-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 8px 12px 7px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 90ms linear, background 90ms linear;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-icon { font-family: var(--emoji); font-size: 15px; line-height: 1; }

/* on the gate it sits in the corner, always reachable */
.page-gate .theme-toggle {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  z-index: 6;
}

/* ---------------------------------------------------------------- dark theme */
/* Whole site, not just the reader: paper, cards, folder list and viewer. */

html.dark {
  --paper: #14121f;
  --grid-minor: #211f33;
  --grid-major: #2b2842;
  --card: #221f33;
  --ink: #ece9f8;
  --ink-soft: #c2bcd9;
  --ink-faint: #8f88aa;
  --line: #3a3552;
  --lilac: #5b4f95;
  --lilac-deep: #3f3769;
  --mint: #2b453a;
  --mint-deep: #46856b;
  --butter: #3a3220;
  --sky: #24304a;
  --rose: #3a2430;
  --coral: #a3455f;
  --coral-deep: #f0a7b6;
  --peach-deep: #6b4a5c;
  --edge: 2px solid var(--line);
}

html.dark body { color-scheme: dark; }

html.dark .gate-card {
  background: #1f1c2e;
  border-color: #3b3556;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

html.dark .gate-input {
  background: #191728;
  border-color: #3b3556;
  color: var(--ink);
}
html.dark .gate-input[aria-invalid="true"] {
  border-color: #e08aa0;
  background: #2a1f2c;
}
html.dark .gate-status { color: var(--coral-deep); }
html.dark .gate-input::placeholder { color: #7a7495; }
html.dark .gate-input:focus { background: #1d1a2e; border-color: #6b5fb0; }

html.dark .gate-button {
  background: #6b5fb0;
  border-color: #2b2547;
  color: #f6f3ff;
  box-shadow: 0 4px 0 #3b3364;
}
html.dark .gate-button:hover { background: #7a6cc4; }

html.dark .side {
  background: rgba(27, 25, 42, 0.92);
  border-color: var(--line);
}

html.dark .side-out,
html.dark .count {
  background: #262336;
  border-color: #4a4468;
  color: #d9d4ee;
}
html.dark .side-out:hover { border-color: #8f88aa; color: #f4f1ff; }

html.dark .search-input {
  background: #191728;
  border-color: #3b3556;
  color: var(--ink);
}
html.dark .search-input::placeholder { color: #7a7495; }
html.dark .search-input:focus { background: #1d1a2e; border-color: #6b5fb0; }

html.dark .tree ul { border-left-color: #3a3455; }
html.dark .tree details > summary { color: #e4e0f5; }
html.dark .tree details > summary:hover { color: #bba7ff; }
html.dark .tree details > summary[data-tone="warn"] { color: #f0a7b6; }

html.dark .file { color: #d9d4ee; }
html.dark .file:hover { background: #262336; border-color: #4a4468; }
html.dark .file[aria-current="true"] {
  background: var(--mint);
  border-color: var(--mint-deep);
  color: #f4f1ff;
}

html.dark .blank-text { color: #7d7799; }

html.dark .doc-head,
html.dark .doc-body,
html.dark .doc-note {
  background: #221f33;
  border-color: #3a3552;
  color: var(--ink);
}
html.dark .doc-name { color: #f4f1ff; }
html.dark .doc-meta { color: #a9a3c4; }

html.dark .reader-stage {
  background: #151322;
  border-color: #3a3552;
}

html.dark .reader-btn,
html.dark .doc-open,
html.dark .doc-download,
html.dark .doc-back,
html.dark .thumb {
  background: #262336;
  border-color: #4a4468;
  color: var(--ink);
}
html.dark .doc-download { background: #3a3263; border-color: #5b4f95; }
html.dark .reader-btn:hover:not(:disabled),
html.dark .doc-open:hover { background: #322d4a; }
html.dark .reader-count { color: #bdb6d8; }
html.dark .reader-status { color: #a9a3c4; }
html.dark .thumb[aria-current="true"] { border-color: #8f7fd6; box-shadow: 0 0 0 2px #4b3f7d; }
html.dark .doc-note { background: #33243a; border-color: #6b4a5c; }

html.dark .mode-note { background: #241f3a; border-color: #5b4f95; color: #cfc6ef; }
html.dark .offline-note { background: #3a3220; border-color: #6b5a2a; color: #e8d9a8; }

html.dark .theme-toggle { background: #262336; border-color: #4a4468; color: var(--ink); }
html.dark .theme-toggle:hover { border-color: #8f88aa; }

html.dark .doodle--cloud-a path,
html.dark .doodle--cloud-b path { fill: #221f33; stroke: #4a4468; }

html.dark .doodle--sun { display: none; }
html.dark .doodle--moon { display: block; }

/* the folder header carries three things now, so keep the toggle compact there */
.side .theme-toggle { padding: 7px 10px 6px; font-size: 13px; }

@media (max-width: 900px) {
  .page-files.has-doc .pane { background: var(--paper); }
  .side-actions { gap: 6px; }
}

/* very narrow: icon only, so the header still fits */
@media (max-width: 400px) {
  .theme-label { display: none; }
  .theme-toggle { padding: 8px 10px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .gate-input.nudge { animation: none; }
}

/* Fingers rather than a mouse: a tablet at 1024px is still a touch device, so
   the rows grow regardless of window width. */
@media (pointer: coarse) {
  .file { padding: 10px 10px 9px; }
  .tree details > summary { padding: 11px 0; }
  .side-out { padding: 8px 12px 7px; }
  .reader-btn { width: 38px; height: 38px; }
  .doc-download,
  .doc-open { padding: 10px 14px 9px; }
}

/* Short screens: a phone on its side, or a small laptop window. The header goes
   back to one line and the page stage gives up its height so the filmstrip and
   the page counter stay on screen. */
@media (max-height: 520px) {
  .page-files.has-doc .pane { padding-top: 8px; }
  .doc-head {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding-bottom: 6px;
  }
  .doc-ident { flex: 1; min-width: 0; }
  .doc-back { margin-bottom: 4px; }
  .doc-actions { width: auto; }
  .doc-download { flex: none; }
  .doc-name { font-size: 15.5px; }
  .doc-meta { font-size: 13px; }
  .page-files.has-doc .reader-stage { min-height: 96px; }
  .reader-stage { height: calc(100dvh - 200px); min-height: 120px; }
  .thumb { width: 40px; }
  .reader { gap: 7px; margin-top: 6px; }
}
