:root {
  --bg: #f7f5f0; --panel: #ffffff; --ink: #1d232b; --quiet: #626b76; --line: #e2ddd2; --accent: #1f5f8b; --accent-soft: #e5eef5;
  --work: #7a5a12; --work-soft: #f6efdc; --write: #2f6b3a; --write-soft: #e6f1e7; --warn: #a33a2a; --paste: #fff3c4;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Naskh Arabic", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15191e; --panel: #1d232a; --ink: #e6e3dc; --quiet: #9aa3ad; --line: #2e3640; --accent: #7fb6dd; --accent-soft: #1e3242;
    --work: #e0bf6a; --work-soft: #2e2716; --write: #8fcf98; --write-soft: #18291b; --warn: #f08a78; --paste: #3d3615; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15191e; --panel: #1d232a; --ink: #e6e3dc; --quiet: #9aa3ad; --line: #2e3640; --accent: #7fb6dd; --accent-soft: #1e3242;
  --work: #e0bf6a; --work-soft: #2e2716; --write: #8fcf98; --write-soft: #18291b; --warn: #f08a78; --paste: #3d3615; color-scheme: dark;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans) }
a { color: var(--accent) }
button, select, input, textarea { font: inherit; color: inherit }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; cursor: pointer }
button:hover { border-color: var(--accent) }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent) }
button.link { border: 0; background: none; padding: 0 4px; color: var(--accent) }
button:disabled { opacity: .5; cursor: not-allowed }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px }
textarea { width: 100%; resize: vertical }
.quiet { color: var(--quiet) } .small { font-size: 13px } .warn { color: var(--warn) } .pad { padding: 24px }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 20px; align-items: center; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap }
.brand { font: 600 17px var(--serif); color: var(--ink); text-decoration: none }
.top nav { display: flex; gap: 4px; flex-wrap: wrap }
.top nav a { text-decoration: none; color: var(--quiet); padding: 4px 10px; border-radius: 6px }
.top nav a.on { color: var(--ink); background: var(--accent-soft) }
#status { margin-left: auto }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 80px }
h1 { font: 600 24px var(--serif); margin: 4px 0 14px } h2 { font: 600 18px var(--serif); margin: 22px 0 10px } h3 { font-size: 15px; margin: 14px 0 6px }
.room { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; margin-left: 8px; vertical-align: middle; font-family: var(--sans); font-weight: 500 }
.room.work { background: var(--work-soft); color: var(--work) } .room.write { background: var(--write-soft); color: var(--write) }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 10px }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 12px; font-size: 13px; background: var(--accent-soft); margin: 2px 4px 2px 0; border: 1px solid transparent }
.chip.must { border-color: var(--accent); font-weight: 600 } .chip.not { background: transparent; border-color: var(--warn); color: var(--warn); text-decoration: line-through }
.chip button { border: 0; background: none; padding: 0 2px; font-size: 12px; color: inherit }
.status { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--quiet) }
.item { padding: 8px 0; border-top: 1px solid var(--line) } .item:first-child { border-top: 0 }
.item .h { font-weight: 600 } .item .t { color: var(--ink) } .item .meta { font-size: 13px; color: var(--quiet) }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer }
.src { font-size: 13px } .src a { margin-right: 6px }
.sugg { position: absolute; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 280px; overflow: auto; min-width: 300px }
.sugg div { padding: 6px 10px; cursor: pointer } .sugg div:hover, .sugg div.on { background: var(--accent-soft) }
.daygroup { font-size: 13px; color: var(--quiet); margin: 14px 0 2px; font-weight: 600 }

/* writing room */
.desk { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start }
@media (max-width: 980px) { .desk { grid-template-columns: 1fr } }
.page { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 26px 34px 40px; min-height: 70vh }
.ptitle { width: 100%; border: 0; background: none; font: 600 28px/1.25 var(--serif); padding: 0; margin: 0 0 6px; outline: none }
.bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; position: sticky; top: 49px; background: var(--panel); z-index: 3 }
.bar .sp { flex: 1 }
.editor { font: 18px/1.7 var(--serif); outline: none; min-height: 50vh; max-width: 680px }
.editor:empty::before { content: "Start writing. Nothing here is ever sent to an AI."; color: var(--quiet) }
.editor h2 { font: 600 22px var(--serif) } .editor blockquote { border-left: 3px solid var(--line); margin: 0 0 0 4px; padding-left: 14px; color: var(--quiet) }
.editor .pasted { background: var(--paste); border-radius: 2px }
.editor.hidepaste .pasted { background: none }
.editor sup.fn { color: var(--accent); cursor: default; font-family: var(--sans); font-size: 12px; padding: 0 1px }
.fns { max-width: 680px; margin-top: 30px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px }
.fns ol { padding-left: 22px; margin: 4px 0 }
.side { position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 10px }
.side .tabs { display: flex; border-bottom: 1px solid var(--line); flex-wrap: wrap }
.side .tabs button { border: 0; border-radius: 0; background: none; padding: 9px 10px; color: var(--quiet); font-size: 14px }
.side .tabs button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent) }
.side .body { overflow: auto; padding: 10px 14px 20px }
.cite { font-size: 12px; padding: 1px 7px; margin-left: 4px }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto }
.modal .box { background: var(--panel); border-radius: 12px; padding: 20px 24px; max-width: 900px; width: 100%; border: 1px solid var(--line) }
.preview { font: 17px/1.65 var(--serif); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; max-height: 55vh; overflow: auto; margin-top: 10px }
.revs { max-height: 22vh; overflow: auto; font-size: 13px; margin-top: 8px }
.revs div { padding: 3px 6px; cursor: pointer; border-radius: 4px } .revs div.on, .revs div:hover { background: var(--accent-soft) }
.banner { background: var(--work-soft); color: var(--work); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px }
.banner.bad { background: #fbe4df; color: var(--warn) }
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh }
.loginbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 30px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 10px }
.ur { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; direction: rtl; unicode-bidi: plaintext }
