:root {
  color-scheme: light dark;
  font: 16px/1.5 system-ui, sans-serif;
  --background: #f3f5f0;
  --surface: #fff;
  --ink: #1d2922;
  --muted: #53655a;
  --line: #d6dfd7;
  --accent: #244e39;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: grid; grid-template-rows: auto 1fr; min-height: 100dvh; margin: 0; color: var(--ink); background: var(--background); }
header { display: flex; align-items: center; gap: 1rem; min-height: 4rem; padding: .75rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: var(--surface); }
a { color: inherit; }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand span { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .65rem; background: var(--accent); color: white; }
#document-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); border-left: 1px solid var(--line); padding-left: 1rem; }
#sign-out { margin-left: auto; }
main { min-width: 0; }
#library, .sign-in, #status { width: min(100% - 2.5rem, 65rem); margin: clamp(1.75rem, 6vw, 4rem) auto; }
.sign-in { max-width: 32rem; padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
h1 { margin: 0 0 .4rem; font-size: clamp(1.65rem, 5vw, 2.7rem); line-height: 1.12; letter-spacing: -.045em; }
p { color: var(--muted); margin: 0 0 1rem; }
.heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
button, .button { display: inline-block; border: 1px solid transparent; border-radius: .5rem; padding: .6rem 1rem; background: var(--accent); color: white; font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:disabled { opacity: .55; cursor: wait; }
.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
:focus-visible { outline: 2px solid #5f9d7d; outline-offset: 3px; }
.controls { margin: 1rem 0; }
label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: .375rem; }
input[type=search] { width: min(100%, 24rem); background: var(--surface); border: 1px solid var(--line); border-radius: .5rem; padding: .65rem .75rem; color: var(--ink); font: inherit; }
ul { padding: 0; margin: 0; list-style: none; }
li { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--line); }
li + li { border-top: 0; }
li:first-child { border-radius: .6rem .6rem 0 0; }
li:last-child { border-radius: 0 0 .6rem .6rem; }
li:only-child { border-radius: .6rem; }
.document { min-width: 0; overflow-wrap: anywhere; font-weight: 650; text-underline-offset: .18em; }
time { font-size: .875rem; color: var(--muted); white-space: nowrap; }
#viewer { position: absolute; inset: 4rem 0 0; }
iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
#status:empty { display: none; }

@media (prefers-color-scheme: dark) {
  :root { --background: #19201d; --surface: #242e28; --ink: #eaf0e9; --muted: #bac8be; --line: #3c4b42; --accent: #315e46; }
}

@media (max-width: 540px) {
  #document-title { display: none; }
  li { align-items: flex-start; flex-direction: column; gap: .25rem; }
}
