:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e6e2dc;
  background: #161719;
  --muted: #9c9b98;
  --border: #ffffff12;
  --accent: #c6b18b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background-position: center; background-size: cover; background-attachment: fixed; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--border); border-radius: 7px; background: #ffffff08; color: inherit; padding: .6rem .85rem; }
button:hover { background: #ffffff12; }
button:disabled { opacity: .5; cursor: wait; }
input { width: 100%; border: 1px solid var(--border); background: #ffffff05; color: inherit; padding: .8rem; border-radius: 7px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input::placeholder, textarea::placeholder { color: #777875; }
.muted { color: var(--muted); font-size: .85rem; }
.brand { font-family: Georgia, serif; font-size: 2.6rem; letter-spacing: -.16rem; }
.brand span { color: var(--accent); }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: #161719d9; }
.login-card { position: relative; width: min(100%, 27rem); display: grid; grid-template-rows: 5rem 7rem 3.25rem; justify-items: center; gap: 1.75rem; }
.login-brand { font-family: Georgia, serif; font-size: 4rem; line-height: 1; font-weight: 400; letter-spacing: -.18rem; margin: 0; align-self: center; }
.password-fields { width: 100%; height: 7rem; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(2, 3rem); gap: 1rem clamp(.35rem, 2vw, .75rem); }
.password-fields input { min-width: 0; height: 3rem; padding: 0; border-radius: .65rem; text-align: center; font-size: 1.35rem; caret-color: var(--accent); }
.password-fields input:focus { outline: none; border-color: var(--accent); background: #c6b18b09; }
.password-fields input.is-masked { font-family: ui-monospace, monospace; }
.password-fields[aria-invalid="true"] input { border-color: #ce918980; }
.login-key { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border-radius: 50%; padding: 0; color: var(--accent); }
.login-key svg { width: 1.5rem; height: 1.5rem; }
.login-key:disabled { cursor: wait; }
#login-error { position: absolute; top: 100%; left: 0; width: 100%; margin: 1.25rem 0 0; color: #e6a49c; text-align: center; font-size: .8rem; line-height: 1.5; }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: 275px minmax(0, 1fr); background: #161719eb; }
.sidebar { padding: 1.5rem; border-right: 1px solid var(--border); background: #151618b8; display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.sidebar header { display: flex; align-items: center; justify-content: space-between; }
.sidebar input { font-size: .85rem; }
.chapters-heading { display: flex; align-items: center; justify-content: space-between; }
.chapters-heading h2 { text-transform: uppercase; letter-spacing: .15em; font-size: .7rem; color: var(--muted); }
.chapters-heading button { font-size: 1.2rem; padding: .15rem .55rem; }
#chapter-list { display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.chapter { text-align: left; border-color: transparent; overflow-wrap: anywhere; }
.chapter.active { background: #c6b18b12; color: var(--accent); border-color: #c6b18b24; }
.chapter small { display: block; margin-top: .4rem; color: var(--muted); font-size: .75rem; font-weight: 400; }
.sidebar footer { display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; border-top: 1px solid var(--border); padding-top: 1.2rem; }
.quiet { color: var(--muted); background: none; border: none; padding: .3rem 0; font-size: .8rem; }
.writing-area { min-width: 0; padding: 1.6rem clamp(1.5rem, 5vw, 6rem); }
.toolbar { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.editor { max-width: 780px; margin: 4rem auto 0; }
#chapter-title { font-family: Georgia, serif; font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 400; background: none; border: 0; padding: 0; border-radius: 0; }
#chapter-content { display: block; width: 100%; min-height: 60dvh; margin-top: 2rem; padding: 0; resize: vertical; border: none; background: none; color: #d6d2cd; font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; line-height: 1.9; tab-size: 4; }
.danger { color: #ce9189; margin-top: 2rem; }
.notice { border: 1px solid #ce91894d; background: #362422; padding: 1rem; margin-top: 1rem; font-size: .9rem; line-height: 1.5; }
.notice button { margin: .5rem; }
.empty-state { margin: 20vh auto; max-width: 500px; text-align: center; color: var(--muted); }
.empty-state h1 { font-family: Georgia, serif; font-weight: 400; color: #e6e2dc; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 700px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); gap: 1rem; padding: 1rem; }
  #chapter-list { max-height: 180px; overflow-y: auto; }
  .sidebar footer { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .editor { margin-top: 2rem; }
}
