:root {
  color-scheme: light dark;
  --bg: #f3f0e7; --paper: #fffdf7; --ink: #26352c; --muted: #626b60;
  --green: #263e32; --line: #d8dacf; --soft: #e5ebdf; --alert: #884216;
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
a { color: var(--green); text-underline-offset: .2em; }
button, input, .button { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .65rem 1rem; border: 1px solid var(--green);
  border-radius: 9px; background: var(--green); color: #fffdf7; text-decoration: none;
  font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .55; cursor: wait; }
.quiet { background: transparent; color: var(--green); border-color: var(--line); }
button:hover, .button:hover { filter: brightness(1.1); }
:focus-visible { outline: 3px solid #be802c; outline-offset: 3px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 1.25rem; background: var(--paper); }
.has-files .app-header { display: none; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 700; text-decoration: none; }
.brand img { border-radius: 9px; }
.network-hint { font-size: .8rem; color: var(--muted); text-align: right; }
.tabs { display: flex; align-items: center; gap: .25rem; padding: 0 .75rem; border-bottom: 1px solid var(--line); background: var(--paper); }
.tabs a { display: flex; flex-shrink: 0; align-items: center; gap: .4rem; min-height: 46px; padding: .4rem .8rem; text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a[aria-current="page"] { border-bottom-color: var(--green); font-weight: 700; }
.tabs .expand-view { margin-left: auto; padding: .25rem .65rem; border: 0; font-size: .8rem; flex-shrink: 0; }
.expand-view > [aria-hidden] { font-size: 1.4rem; line-height: 1; }
.count { font-size: .75rem; border-radius: 20px; background: var(--soft); padding: .05rem .45rem; }
h1, h2, p { margin-top: 0; }
h1 { font: 600 clamp(1.7rem, 4vw, 2.7rem)/1.2 ui-serif, Georgia, serif; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin-bottom: .6rem; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; margin-bottom: .65rem; }
.small { font-size: .88rem; color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--paper); padding: 1.5rem; margin-bottom: 1rem; }
.welcome { max-width: 680px; margin: clamp(1.5rem, 7vh, 5rem) auto; padding: clamp(1.5rem, 5vw, 3rem); }
.welcome > button { margin: .5rem 0 1.5rem; }
.content { max-width: 1000px; margin: 0 auto; padding: 2rem 1.25rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.section-heading > p { max-width: 290px; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin: .8rem 0; }
input[type="text"], input[type="search"] { display: block; width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; color: var(--ink); background: var(--bg); }
label:not(.button), .search-label { display: block; font-weight: 600; margin-bottom: .4rem; }
.import-panel input { max-width: 460px; }
.search-label { margin-top: 1.5rem; }
#document-search { margin-bottom: 1.5rem; }
.folder-heading { margin: 1.8rem 0 .65rem; overflow-wrap: anywhere; }
.document-row { display: flex; align-items: stretch; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; }
.document-main { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; gap: .15rem; padding: .85rem 1rem; text-align: left; background: transparent; border: 0; border-radius: 9px 0 0 9px; color: var(--green); }
.document-name { overflow-wrap: anywhere; width: 100%; }
.document-main .small { display: block; margin: 0; font-weight: 400; }
.document-main:hover, .document-main:active { background: var(--soft); filter: none; }
.document-main:focus-visible { outline-offset: -3px; }
.document-actions { display: flex; align-items: center; gap: .4rem; padding: .85rem 1rem .85rem 0; }
.document-actions button { font-size: .8rem; padding: .4rem .65rem; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.status-grid .panel { margin: 0; }
.status-grid + p { margin: 1rem 0; }
.notice { padding: 1rem; border-radius: 9px; background: var(--soft); }
.message, .update-banner { padding: .4rem 1rem; background: var(--soft); overflow-wrap: anywhere; font-size: .85rem; }
.message { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.message > button { padding: 0; width: 44px; flex-shrink: 0; border: 0; font-size: 1.4rem; }
.message[data-kind="error"] { color: var(--alert); background: #fff0dd; }
.update-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); }
.viewer-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; min-height: 58px; padding: .5rem 1rem; }
.file-label { font: inherit; font-size: .85rem; color: var(--muted); flex: 1; overflow-wrap: anywhere; margin: 0; }
.viewer-toolbar .button, .viewer-toolbar button { font-size: .8rem; }
#itinerary-view iframe { display: block; width: 100%; height: calc(100vh - 166px); height: calc(100dvh - 166px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 400px; border: 0; background: var(--bg); }
#pdf-view iframe { display: block; width: 100%; height: 75vh; height: 75dvh; min-height: 400px; border: 0; background: var(--paper); }
.pdf-help { padding: 0 1rem; }
/* Fit the reader to the available visual viewport, including changing browser bars. */
body.reading { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.reading > .tabs, .reading > .message, .reading > .update-banner { flex-shrink: 0; }
.reading main { display: flex; flex: 1; min-height: 0; }
.reading #panel-itinerary { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
.reading #itinerary-view { flex: 1; min-height: 0; }
.reading #itinerary-view iframe { height: 100%; min-height: 0; }
.expanded .app-header, .expanded .tabs, .expanded .message, .expanded .update-banner { display: none !important; }
.reading-menu { position: fixed; top: calc(env(safe-area-inset-top) + .5rem); right: calc(env(safe-area-inset-right) + .6rem); z-index: 10; min-height: 44px; padding: .35rem .85rem; border-radius: 999px; background: var(--paper); color: var(--ink); font-size: .85rem; box-shadow: 0 2px 12px #0002; opacity: .92; }
.file-inputs { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
body.busy { cursor: progress; }
body.busy .button { pointer-events: none; opacity: .6; }
ol { padding-left: 1.4rem; }
li { margin-bottom: .5rem; }
@media (max-width: 600px) {
  .app-header { padding: .65rem .8rem; }
  .brand { font-size: .9rem; }
  .tabs { padding: 0 .25rem; }
  .tabs a { padding: .5rem .65rem; font-size: .9rem; }
  .tabs .expand-view { width: 44px; padding: 0; }
  .expand-label { display: none; }
  .welcome { margin: 1rem; }
  .section-heading { display: block; }
  .status-grid { grid-template-columns: 1fr; }
  .document-row { flex-wrap: wrap; }
  .document-main { flex-basis: 100%; border-radius: 9px 9px 0 0; }
  .document-actions { width: 100%; padding: .2rem 1rem .85rem; }
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141d17; --paper: #1b271f; --ink: #edf0e7; --muted: #b2bdad; --green: #a4c9a8; --line: #3b4c3e; --soft: #2b3b2d; --alert: #ffcf9e; }
  button, .button { color: #14271b; }
  .quiet { color: var(--green); }
  .message[data-kind="error"] { background: #442c1b; }
}
