/* Library app. Look: a cloth-bound spine with gilt lettering on top, catalogue-drawer labels
   for the sections, and a tight shelf list on paper below. */

@font-face { font-family: Alegreya; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(fonts/alegreya-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: Alegreya; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(fonts/alegreya-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: Alegreya; font-style: italic; font-weight: 400 900; font-display: swap;
  src: url(fonts/alegreya-latin-wght-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: Alegreya; font-style: italic; font-weight: 400 900; font-display: swap;
  src: url(fonts/alegreya-latin-ext-wght-italic.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Alegreya Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/alegreya-sans-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Alegreya Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/alegreya-sans-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Alegreya Sans'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/alegreya-sans-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Alegreya Sans'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/alegreya-sans-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  color-scheme: light dark;
  --cloth: #1f3a2e;        /* bottle-green book cloth */
  --cloth-deep: #172c23;
  --gilt: #d6b65f;         /* gold stamping */
  --paper: #f8f9f4;
  --stripe: #eef1e8;
  --field: #ffffff;
  --ink: #17201b;
  --muted: #5b6860;
  --rule: #d2d9cc;
  --link: #1d5c44;
  --stamp: #a2362a;        /* date-stamp red, for warnings and delete */
  --focus: #b08a22;
  --serif: Alegreya, 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Hiragino Mincho ProN', 'Noto Serif CJK JP', serif;
  --sans: 'Alegreya Sans', 'Segoe UI', system-ui, -apple-system, 'Noto Sans', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cloth: #14271f;
    --cloth-deep: #0d1a15;
    --paper: #111814;
    --stripe: #161f1a;
    --field: #0c120f;
    --ink: #e2e6db;
    --muted: #97a299;
    --rule: #2a372f;
    --link: #8fcaa9;
    --stamp: #e58d7e;
    --focus: #d6b65f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.22 var(--serif);
  font-variant-numeric: lining-nums;
}
.wrap { max-width: 62rem; margin-left: auto; margin-right: auto; padding-left: 10px; padding-right: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* ----- spine: title and section drawers ----- */

.spine { background: var(--cloth); color: var(--gilt); padding-top: env(safe-area-inset-top); }
.spine-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 8px; }
.spine h1 { margin: 0; font-size: 1.45rem; font-weight: 500; letter-spacing: .01em; line-height: 1.1; }
.on-cloth { background: none; border: 0; color: var(--gilt); font: 400 .9rem var(--sans); padding: 4px 2px; margin-left: 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(214, 182, 95, .5); }
#owner-tools { white-space: nowrap; }

.drawers { display: flex; gap: 6px; }
.drawer {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 2px 4px;
  color: var(--gilt); text-decoration: none;
  border: 1px solid rgba(214, 182, 95, .5); border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: var(--cloth-deep);
}
.drawer-name { font-size: 1rem; line-height: 1.15; white-space: nowrap; }
.drawer-count { font: 400 .74rem/1.1 var(--sans); font-variant-numeric: tabular-nums; opacity: .85; }
.drawer.current { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.drawer.current .drawer-name { font-weight: 700; }
.drawer.current .drawer-count { color: var(--muted); opacity: 1; }

/* ----- search and filters ----- */

.toolbar { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--rule); }
.toolbar-row { display: flex; gap: 8px; align-items: center; padding-top: 7px; padding-bottom: 7px; }
.search { flex: 1; position: relative; display: block; }
.search svg { position: absolute; left: 9px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; pointer-events: none; }
.search input { width: 100%; padding: 7px 10px 7px 32px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding-bottom: 8px; font: .88rem var(--sans); color: var(--muted); }
.filters select { margin-left: 4px; padding: 4px 6px; font-size: .92rem; max-width: 11rem; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  font-family: var(--sans); font-size: 1rem;
  background: var(--field); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 9px;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
textarea { width: 100%; resize: vertical; line-height: 1.3; }

button, .button { cursor: pointer; font: 400 .95rem var(--sans); border-radius: 6px; }
button:disabled { opacity: .4; cursor: default; }
.primary { background: var(--cloth); color: #f4ecd2; border: 1px solid var(--cloth); padding: 8px 16px; font-weight: 700; }
@media (prefers-color-scheme: dark) { .primary { background: #2c5a45; border-color: #2c5a45; } }
.button { display: inline-block; background: none; border: 1px solid var(--rule); color: var(--ink); padding: 7px 12px; text-decoration: none; }
.quiet { background: none; border: 0; color: var(--link); padding: 6px 6px; }
.quiet.active { font-weight: 700; }
.danger { background: none; border: 1px solid var(--stamp); color: var(--stamp); padding: 7px 12px; }
.linklike { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; font: inherit; }

/* ----- the shelf list ----- */

.status { font: .92rem var(--sans); color: var(--muted); margin: 8px 0 4px; padding: 0 6px; }
.intro { margin: 12px 6px 8px; max-width: 42rem; line-height: 1.35; }

.colhead { display: none; }
.shelf, .wishes { list-style: none; margin: 0; padding: 0; }

.row:nth-child(even) { background: var(--stripe); }
.summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 34%);
  grid-template-areas: "orig by" "trans by";
  column-gap: 10px;
  padding: 2px 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.t-movie .summary, .t-game .summary { grid-template-columns: minmax(0, 1fr) auto; }
.c-orig { grid-area: orig; }
.c-trans { grid-area: trans; font-style: italic; color: var(--muted); font-size: .96em; }
.c-by { grid-area: by; }
.c-fmt { display: none; }
.c-orig, .c-trans, .c-by { overflow-wrap: anywhere; }

.t-main { display: block; }
.t-top { color: var(--muted); font-size: .86em; font-style: normal; }
.t-sub { display: block; color: var(--muted); font-size: .86em; line-height: 1.2; padding-left: .7em; }
.c-trans .t-main { color: var(--ink); }
@media (prefers-color-scheme: dark) { .c-trans .t-main { color: #c4cabd; } }

.by { display: block; font: .88rem/1.3 var(--sans); }
.role { color: var(--muted); font-size: .86em; }
.ext { font: .86rem var(--sans); white-space: nowrap; }

.chip {
  display: inline-block; font: 400 .68rem/1.35 var(--sans); font-style: normal;
  color: var(--muted); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px;
  white-space: nowrap; vertical-align: .15em;
}

/* letter tabs, like the guide cards in a catalogue drawer */
.guide { border-bottom: 1px solid var(--cloth); margin-top: 9px; line-height: 0; }
.guide:first-child { margin-top: 6px; }
.guide span {
  display: inline-block; min-width: 1.9em; text-align: center;
  background: var(--cloth); color: var(--gilt);
  font: 700 .78rem/1.5 var(--sans); padding: 0 6px; border-radius: 4px 4px 0 0;
}

.row.open { background: var(--stripe); box-shadow: inset 3px 0 0 var(--gilt); }
.row.open .summary { padding-bottom: 1px; }
.detail { padding: 2px 6px 7px 9px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.detail dl { margin: 0; display: flex; flex-wrap: wrap; gap: 1px 16px; font: .9rem/1.35 var(--sans); }
.detail dl div { display: flex; gap: 5px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.detail .none { margin: 0; font: .88rem var(--sans); color: var(--muted); }
.detail .quiet { padding: 2px 6px; font-weight: 700; }

/* ----- wishlist ----- */

.wish { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 5px 6px; }
.wish:nth-child(even) { background: var(--stripe); }
.wish-text { flex: 1 1 16rem; min-width: 0; }
.wish .t-main { font-weight: 700; }
.wish-line { display: block; font-size: .95em; padding-left: .7em; overflow-wrap: anywhere; }
.wish-tools { white-space: nowrap; }
.wish-tools .quiet { padding: 2px 6px; }

/* ----- colophon ----- */

.colophon { margin-top: 26px; padding-bottom: calc(84px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); color: var(--muted); font-size: .95rem; line-height: 1.4; }
.colophon p { margin: 8px 6px 0; max-width: 46rem; }
.colophon p:empty { display: none; }
.colophon .fine { font: .82rem var(--sans); }

.add-fab {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; align-items: center; gap: 6px;
  background: var(--cloth); color: var(--gilt); border: 1px solid var(--gilt); border-radius: 999px;
  padding: 10px 18px 10px 13px; font: 700 1rem var(--sans);
  box-shadow: 0 3px 10px rgba(10, 25, 18, .35);
}
.add-fab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* ----- dialogs ----- */

dialog.sheet {
  border: 0; padding: 0; margin: 0;
  width: 100vw; max-width: none; height: 100dvh; max-height: none;
  background: var(--paper); color: var(--ink);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
dialog::backdrop { background: rgba(10, 22, 16, .55); }
dialog.sheet.small { height: fit-content; max-height: calc(100dvh - 20px); overflow-y: auto; width: min(26rem, calc(100vw - 20px)); margin: auto; border-radius: 10px; padding: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
dialog.sheet.small > form { display: block; }
.sheet h2 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 700; }
.sheet h3 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 700; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--cloth); color: var(--gilt); }
.sheet-head h2 { margin: 0; font-weight: 500; }
.sheet-head .quiet { color: var(--gilt); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; overscroll-behavior: contain; }
.sheet-foot { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.actions .grow { flex: 1; }
dialog.small .actions { justify-content: flex-end; }
.help { font: .9rem/1.35 var(--sans); color: var(--muted); margin: 4px 0 10px; }
.error { color: var(--stamp); font: .92rem/1.35 var(--sans); margin: 6px 0 0; }
.error:empty { display: none; }
.saved { font: .92rem var(--sans); color: var(--link); }
.hint { color: var(--muted); font-weight: 400; }

.field { display: block; font: 700 .86rem var(--sans); color: var(--muted); margin-bottom: 10px; }
.field input, .field select, .field textarea { display: block; width: 100%; margin-top: 3px; font-weight: 400; color: var(--ink); }
.field.kind select { width: auto; min-width: 12rem; }

fieldset { border: 0; border-top: 1px solid var(--rule); margin: 12px 0 0; padding: 6px 0 0; min-width: 0; }
legend { padding: 0 8px 0 0; font: 700 .86rem var(--sans); color: var(--muted); }
.trow, .arow, .irow { display: grid; gap: 5px; margin-bottom: 8px; }
.trow { grid-template-columns: 1fr 1fr auto; }
.trow input { grid-column: 1 / -1; }
.arow { grid-template-columns: 1fr 1fr; }
.arow .rm { justify-self: end; }
.irow { grid-template-columns: 7.5rem 1fr auto; }
.rm { font-size: .85rem; padding: 4px 4px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); }
.fields .wide { grid-column: 1 / -1; }

.lookup { background: var(--stripe); border-radius: 8px; padding: 9px 10px; margin-bottom: 4px; }
.lookup > label { font: 700 .86rem var(--sans); color: var(--muted); }
.lookup-row { display: flex; gap: 6px; margin-top: 4px; }
.lookup-row input { flex: 1; }
.lookup-msg { font: .9rem/1.35 var(--sans); color: var(--muted); margin: 6px 0 0; }
.lookup-msg:empty { display: none; }
.lookup-msg.bad { color: var(--stamp); }
.picks { list-style: none; margin: 6px 0 0; padding: 0; }
.pick { display: block; width: 100%; text-align: left; background: var(--field); border: 1px solid var(--rule); padding: 7px 9px; margin-bottom: 4px; font-size: .95rem; }

.group { border-top: 1px solid var(--rule); padding: 14px 0 16px; }
.group:first-of-type { border-top: 0; padding-top: 0; }
.group h3 + .help { margin-top: -4px; }
#form-settings h3:not(:first-child) { margin-top: 16px; }
#import-files { font-size: .92rem; max-width: 100%; border: 0; padding: 0; background: none; }

.viewfinder { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle { position: absolute; left: 10%; right: 10%; top: 32%; bottom: 32%; border: 2px solid var(--gilt); border-radius: 6px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }

/* ----- wider screens: three columns, like a catalogue ledger ----- */

@media (min-width: 760px) {
  body { font-size: 17px; }
  .wrap { padding-left: 20px; padding-right: 20px; }
  .spine h1 { font-size: 1.7rem; }
  .drawers { gap: 8px; }
  .drawer { flex: 0 0 8.2rem; flex-direction: row; justify-content: center; align-items: baseline; gap: 7px; padding: 7px 8px 6px; }
  .drawer-name { font-size: 1.08rem; }
  .toolbar-row { max-width: 62rem; }
  .search { max-width: 30rem; }

  .colhead, .summary {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .85fr) 4.2rem;
    grid-template-areas: "orig trans by fmt";
    column-gap: 16px;
  }
  .t-movie .summary, .t-game .summary { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .85fr) 4.2rem; }
  .colhead { padding: 10px 8px 3px; font: 700 .8rem var(--sans); color: var(--muted); border-bottom: 1px solid var(--rule); }
  .summary { padding: 2px 8px; }
  .c-trans { font-size: 1em; }
  .c-trans .t-main { color: inherit; }
  .c-fmt { display: block; grid-area: fmt; text-align: right; }
  .chip.inline { display: none; }
  .guide:first-child { margin-top: 8px; }
  .detail { padding: 2px 8px 8px 11px; }

  dialog.sheet:not(.small) { width: min(44rem, calc(100vw - 40px)); height: min(52rem, calc(100dvh - 40px)); margin: auto; border-radius: 10px; overflow: hidden; box-shadow: 0 16px 50px rgba(0, 0, 0, .35); }
  .arow { grid-template-columns: 1fr 1fr 1fr auto; }
  .trow { grid-template-columns: 8rem 8.5rem 1fr auto; }
  .trow input { grid-column: 3; grid-row: 1; }
  .trow .rm { grid-column: 4; }
  .fields { grid-template-columns: repeat(3, 1fr); }
}

@media print {
  .toolbar, .add-fab, #owner-tools, .fine button { display: none; }
  .spine { background: none; color: #000; }
  .drawer:not(.current) { display: none; }
}
