:root {
  --bg: #0b0b0d;
  --ink: #e8e6e1;
  --dim: #6f6c66;
  --line: #26262a;
  --warm: #c9a227;
  --burn: #a8432a;
  font-size: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Something carrying `hidden` is not on the page. Said here once and loudly,
   because several rules below hand an element a display of their own, and a
   rule in this file quietly outranks the browser's own `[hidden]`. Where that
   happened to an <img> with no photo to show, WebKit kept drawing the frame of
   the last photo seen, so a page of plain writing opened under an empty box. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, "Songti TC", "Times New Roman", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem 2rem;
}

main { width: 100%; max-width: 40rem; }

.meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-transform: uppercase;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.meta .burned { color: var(--burn); }
.meta .out { color: var(--dim); text-decoration: none; margin-left: 1rem; }
.meta .out:hover { color: var(--ink); }

/* --------------------------------------- reading: one page of a book, on
   a phone. The page fills the screen and never scrolls; the type shrinks
   to fit rather than the writer being cut short. */

body.reading {
  padding: 0;
  height: 100dvh;
  overflow: hidden;
}

body.reading main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 30rem;
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem max(1.1rem, env(safe-area-inset-bottom));
}

body.reading .sheet {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 1.25rem 0;
  border: none;
  border-radius: 0;
  background: transparent;
  display: grid;
  align-content: center;
}

body.reading .content {
  font-size: 1.16rem;
  line-height: 2.15;
  letter-spacing: 0.015em;
}

body.reading footer { flex: none; }

.stamp {
  flex: none;
  margin: 1.1rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--dim);
}

/* ------------------------------------------------------------ the sheet */

.sheet {
  position: relative;
  margin: 1.75rem 0;
  min-height: 14rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0f0f12;
  overflow: hidden;

  /* A page is read, not handled: no callout menu, no dragging a selection
     across it. Not a security measure. */
  -webkit-touch-callout: none;
  user-select: none;
}

.pagebody { position: relative; z-index: 1; }

.photo {
  display: block;
  width: 100%;
  max-height: 58dvh;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 2px;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* With a photo the text is a caption, so it sits under the image and small. */
.sheet.has-photo .content {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.94rem !important;
  line-height: 1.8;
}

.content {
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.85;
  font-size: 1.06rem;
}

/* ------------------------------------------------------------- controls */

.hold {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  overflow: hidden;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: none;
}

.hold::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--progress, 0%);
  background: var(--burn);
  opacity: 0.35;
  transition: width 60ms linear;
}

.hold span { position: relative; z-index: 1; }
.hold:disabled { color: var(--dim); cursor: default; }

.warn {
  margin: 0.8rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  line-height: 1.7;
  color: var(--dim);
  text-align: center;
}

.warn strong { color: var(--burn); font-weight: normal; }
.warn.big { font-size: 0.78rem; line-height: 1.9; margin: 0 0 0.9rem; }

/* Walking back through the pages that were kept. Deliberately quiet: it is a
   way back, not the point of the page. */
.nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.nav button { font-size: 0.75rem; padding: 0.45rem 0.85rem; }

/* ---------------------------------------------------------------- login */

.gate { margin: 22vh 0 0; text-align: center; }

.gate h1 {
  margin: 0 0 2rem;
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--dim);
}

.datefield {
  width: 100%;
  padding: 1.1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0f0f12;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  text-align: center;
}

.datefield::placeholder { color: #34343a; letter-spacing: 0.18em; }

input[type="password"], textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0f0f12;
  color: var(--ink);
  font: inherit;
  text-align: center;
}

textarea { text-align: left; line-height: 1.8; resize: vertical; min-height: 9rem; }

input:focus, textarea:focus { outline: none; border-color: var(--dim); }

button.plain {
  margin-top: 0.9rem;
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

button.plain:hover { border-color: var(--dim); }
button.plain.wide { display: block; width: 100%; margin-top: 0.6rem; }
button.plain:disabled { color: var(--dim); cursor: default; }

.err { min-height: 1.4rem; margin-top: 0.9rem; font-size: 0.8rem; color: var(--burn); }

/* --------------------------------------------------------------- author */

.attach {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.attach .file { margin: 0; cursor: pointer; font-size: 0.8rem; padding: 0.5rem 0.9rem; }

.preview, .thumb {
  border: 1px solid var(--line);
  border-radius: 2px;
  object-fit: cover;
}

.preview { width: 3.4rem; height: 3.4rem; }
.thumb { width: 100%; max-width: 14rem; height: auto; max-height: 11rem; object-fit: contain; }

/* The one decision made per page: whether it burns behind her. */
.tick {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  font-size: 0.82rem;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}

.tick:hover { color: var(--ink); }
.tick input { width: 1rem; height: 1rem; accent-color: var(--burn); cursor: pointer; }

.count {
  margin: 0.5rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-align: right;
}

.count.over { color: var(--burn); }

.pages { list-style: none; margin: 1.5rem 0 0; padding: 0; }

.pages li {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
}

.tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.tag.now { color: var(--warm); }
.tag.gone { color: var(--burn); }

.pages .text { white-space: pre-wrap; line-height: 1.75; overflow-wrap: anywhere; }
.pages .text.gone { color: var(--burn); opacity: 0.55; font-style: italic; }

.rowbtns { display: flex; gap: 0.5rem; }
.rowbtns button { font-size: 0.75rem; padding: 0.35rem 0.7rem; }

.status {
  margin: 1.2rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.9;
  color: var(--dim);
}
