:root {
  color-scheme: dark;
  --ink: #131c26;
  --slate: #202d38;
  --paper: #f2eee5;
  --mist: #b9c8cc;
  --copper: #f4b585;
  --coral: #ff9b9b;
}

* { box-sizing: border-box; }
.app-body { margin: 0; min-width: 320px; min-height: 100vh; font-family: system-ui, sans-serif; line-height: 1.55; background: var(--ink); color: var(--paper); }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
.app-shell { min-height: 100vh; }
.app-header { border-bottom: 1px solid #40515c; }
.app-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; max-width: 1120px; margin: auto; padding: .9rem 1rem; }
.brand { font-family: Georgia, serif; font-size: 1.25rem; font-weight: 700; text-decoration: none; }
.app-nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.app-nav__link { min-height: 44px; display: inline-flex; align-items: center; color: var(--mist); text-decoration-thickness: 1px; text-underline-offset: .3em; }
.app-nav__link:hover { color: var(--paper); }
.logout-form { margin-left: auto; }
.app-main { max-width: 1120px; padding: clamp(2rem, 5vw, 4rem) 1rem; margin: auto; }
.page-heading { max-width: 42rem; }
.page-heading__context { color: var(--copper); margin: 0 0 .65rem; }
.page-title, .section-title { font-family: Georgia, serif; line-height: 1.18; font-weight: 400; }
.page-title { font-size: clamp(1.9rem, 5vw, 2.7rem); margin: 0 0 1rem; }
.section-title { font-size: clamp(1.4rem, 3vw, 1.65rem); margin: 0 0 1rem; }
.body-copy { color: var(--mist); max-width: 65ch; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .65rem 1.1rem; border: 1px solid var(--copper); border-radius: .4rem; cursor: pointer; }
.button--primary { background: var(--copper); color: var(--ink); font-weight: 700; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button--quiet { background: transparent; color: var(--paper); }
.login-layout { display: grid; gap: 2rem; align-items: start; padding-top: clamp(1rem, 6vw, 5rem); }
.login-intro .page-title { max-width: 13ch; }
.login-panel { background: var(--slate); padding: clamp(1.25rem, 4vw, 2rem); border-radius: .75rem; }
.form-stack { display: grid; gap: 1.2rem; }
.field { display: grid; gap: .4rem; color: var(--paper); }
.field--check { display: flex; align-items: center; min-height: 2rem; }
.field__input { width: 100%; min-height: 48px; padding: .7rem; color: var(--paper); background: var(--ink); border: 1px solid #81939a; border-radius: .35rem; }
.status-message { padding: .8rem 1rem; border-radius: .35rem; }
.status-message--error { color: var(--coral); background: var(--ink); border-left: 3px solid var(--coral); }
.shelf-preview, .empty-library__steps { display: flex; gap: .6rem; flex-wrap: wrap; }
.shelf-preview__tag, .empty-library__step { padding: .4rem .7rem; color: var(--paper); border: 1px solid #7f99a3; border-radius: .2rem; overflow-wrap: anywhere; }
.shelf-preview { margin-top: 1.8rem; }
.empty-library { margin-top: 2.5rem; max-width: 46rem; padding: clamp(1.5rem, 4vw, 2.5rem); background: var(--slate); border-radius: .75rem; }
.empty-library__mark { width: 3rem; height: 4rem; display: grid; place-items: center; font-family: Georgia, serif; font-size: 2rem; color: var(--ink); background: var(--copper); margin-bottom: 1.6rem; border-radius: .15rem .4rem .4rem .15rem; }
.empty-library__steps { margin-top: 1.6rem; }
.page-heading .button { margin-top: .8rem; text-decoration: none; }
.back-link, .text-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--copper); text-underline-offset: .25em; }
.form-panel, .detail-section { max-width: 50rem; margin-top: 2rem; padding: clamp(1.25rem, 4vw, 2rem); background: var(--slate); border-radius: .7rem; }
.form-panel { max-width: 32rem; }
.game-list { display: grid; gap: .8rem; margin-top: 2rem; }
.library-filters { display: grid; gap: .75rem; align-items: end; margin-top: 2rem; padding: 1rem; border: 1px solid #40515c; background: #18232d; }
.library-filter-actions { display: grid; gap: .3rem; }
.library-filter-actions .button { width: 100%; white-space: nowrap; }
.library-filter-actions .text-link { min-height: auto; justify-content: center; font-size: .9rem; }
.library-count { margin: 1.2rem 0 -1.1rem; color: var(--mist); }
.game-entry { display: flex; min-width: 0; gap: 1rem; padding: 1rem; background: var(--slate); border-radius: .5rem; }
.game-entry__cover { display: grid; flex: 0 0 4.8rem; width: 4.8rem; min-height: 6.6rem; place-items: center; padding: .5rem; background: var(--ink); color: var(--mist); text-align: center; font-size: .8rem; border-radius: .2rem; }
.game-entry img.game-entry__cover { padding: 0; height: 6.6rem; object-fit: cover; }
.game-entry__body { min-width: 0; }
.game-entry__body .section-title { overflow-wrap: anywhere; margin: 0; }
.game-entry__body .section-title a { color: var(--paper); text-underline-offset: .25em; }
.game-entry__status { margin: .3rem 0 .7rem; color: var(--mist); }
.location-list, .assigned-locations { display: flex; flex-wrap: wrap; gap: .5rem; }
.location-tag { display: inline-flex; padding: .25rem .6rem; color: var(--paper); border: 1px solid #7f99a3; border-radius: .2rem; overflow-wrap: anywhere; }
.location-list__empty { color: var(--mist); }
.location-list__empty--wishlist { color: var(--copper); }
.game-heading { display: flex; align-items: start; gap: 1.3rem; margin-top: 1rem; }
.game-heading__cover { flex-basis: 6rem; width: 6rem; min-height: 8rem; }
.game-heading img.game-heading__cover { flex-basis: 6rem; width: 6rem; height: 8rem; padding: 0; object-fit: cover; }
.game-heading .page-title { overflow-wrap: anywhere; }
.assigned-locations { align-items: center; margin-bottom: 1.5rem; }
.assigned-location { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: .35rem; }
.assigned-location form { margin: 0; }
.location-remove { display: inline-grid; width: 2rem; min-width: 2rem; height: 2rem; place-items: center; padding: 0; color: var(--paper); background: transparent; border: 1px solid #69818b; border-radius: .25rem; cursor: pointer; font: 1.35rem/1 system-ui, sans-serif; }
.location-remove:hover { color: var(--coral); border-color: var(--coral); background: #2a1d23; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; margin: 1rem 0; }
.inline-form .field { flex: 1 1 12rem; min-width: 0; }
.field__textarea { min-height: 7rem; resize: vertical; }
.date-fields, .duration-fields { display: grid; gap: 1rem; }
.detail-section--danger { border: 1px solid #8d5656; }
.disk-list { list-style: none; padding: 0; }
.disk-list li { border-bottom: 1px solid #40515c; }
.status-message { margin-top: 1.5rem; background: var(--slate); }
.game-summary { max-width: 50rem; margin-top: 2rem; }
.search-form { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; margin: 1.5rem 0; }
.search-form .field { flex: 1 1 14rem; min-width: 0; }
.search-form .field:nth-child(2) { flex: 0 1 8rem; }
.search-status { min-height: 1.7rem; color: var(--mist); }
.result-list { display: grid; gap: .6rem; margin: 1rem 0; }
.result-row { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr) auto; align-items: center; gap: .75rem 1rem; min-width: 0; padding: .75rem; background: var(--slate); border-radius: .5rem; }
.result-row__cover { display: grid; place-items: center; width: 3.75rem; height: 5.1rem; object-fit: cover; border-radius: .2rem; }
.result-row__cover--empty { padding: .3rem; text-align: center; color: var(--mist); background: var(--ink); font-size: .75rem; }
.result-row__details { min-width: 0; }
.result-row__title { margin: 0; font-size: 1rem; font-weight: 650; overflow-wrap: anywhere; }
.result-row__meta { margin: .25rem 0 0; color: var(--mist); font-size: .9rem; overflow-wrap: anywhere; }
.result-row .button { min-width: 5rem; }
.result-row form { justify-self: end; }
.import-heading { display: grid; gap: 1.5rem; align-items: end; margin-bottom: 2rem; }
.import-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; background: #40515c; border: 1px solid #40515c; }
.import-summary div { padding: .7rem; background: var(--slate); }
.import-summary dt { color: var(--mist); font-size: .75rem; }
.import-summary dd { margin: .15rem 0 0; font: 1.5rem/1 Georgia, serif; color: var(--copper); }
.import-list { display: grid; gap: 1px; background: #40515c; border: 1px solid #40515c; }
.import-list__labels { display: none; }
.import-entry { display: grid; grid-template-columns: .55rem minmax(0, 1fr); gap: .8rem; padding: 1rem; background: var(--slate); }
.import-entry__state { width: .55rem; height: .55rem; margin-top: .35rem; border-radius: 50%; background: var(--mist); }
.import-entry--existing .import-entry__state { background: #63d7ad; }
.import-entry--already-assigned .import-entry__state { background: #81939a; }
.import-entry--missing .import-entry__state, .import-entry--ambiguous .import-entry__state { background: #f4c15d; }
.import-entry__source { display: flex; gap: .8rem; align-items: start; }
.import-entry__index { color: var(--copper); font: 1rem/1 Georgia, serif; padding-top: .2rem; }
.import-entry .text-link { margin-top: .4rem; }
.import-picker select { width: 100%; min-height: 2.7rem; padding: .45rem .65rem; color: var(--paper); background: var(--ink); border: 1px solid #81939a; border-radius: .3rem; }
.import-action { display: inline-flex; min-height: 2.7rem; align-items: center; color: var(--mist); }
.import-action--warning { color: var(--coral); font-size: .85rem; }
.import-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem; margin-top: 1.5rem; }
.import-result-actions .text-link { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.attribution { color: var(--mist); font-size: .85rem; margin-top: 2rem; }
.attribution a { color: var(--paper); }
.edition-choice { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-top: 1rem; }
.edition-choice .button { text-align: center; }

@media (max-width: 30rem) {
  .result-row { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .result-row__cover { width: 3.5rem; height: 4.8rem; align-self: start; }
  .result-row form { grid-column: 2; justify-self: start; }
}

@media (min-width: 48rem) {
  .app-header__inner { padding: 1rem 2rem; }
  .app-main { padding-left: 2rem; padding-right: 2rem; }
  .login-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); gap: 4rem; }
  .game-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-filters .field:first-child { grid-column: 1 / -1; }
  .date-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duration-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .import-heading { grid-template-columns: minmax(0, 1fr) 23rem; }
  .import-list__labels { display: grid; grid-template-columns: minmax(15rem, 1fr) minmax(22rem, 1fr); gap: 1.5rem; padding: .55rem 1rem; color: var(--mist); background: var(--ink); font-size: .78rem; }
  .import-entry { grid-template-columns: .55rem minmax(15rem, 1fr) minmax(22rem, 1fr); gap: 1.5rem; }
}

@media (min-width: 70rem) {
  .library-filters { grid-template-columns: minmax(14rem, 2fr) repeat(3, minmax(10rem, 1fr)) minmax(9.5rem, auto); }
  .library-filters .field:first-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Compact library system: shared surfaces, scan-friendly rows and restrained copper actions. */
:root { --ink: #0c141b; --slate: #15222c; --paper: #eef2ed; --mist: #afbec4; --copper: #f2b278; --coral: #ff9d9a; --line: #36505d; --raised: #1a2a35; }
.app-body { background: var(--ink); font-size: .96rem; }
.app-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--ink) 94%, transparent); backdrop-filter: blur(12px); border-bottom-color: var(--line); }
.app-header__inner { max-width: 1200px; gap: .65rem 1.5rem; padding-top: .65rem; padding-bottom: .65rem; }
.brand { font-size: 1.08rem; letter-spacing: -.02em; }
.app-nav { gap: .1rem .9rem; }
.app-nav__link { min-height: 38px; font-size: .9rem; }
.logout-form .button { min-height: 38px; padding: .4rem .7rem; border-color: transparent; }
.app-main { max-width: 1200px; padding-top: clamp(1.5rem, 3vw, 2.75rem); padding-bottom: clamp(2rem, 4vw, 3.5rem); }
.page-heading { max-width: 62rem; padding-bottom: 1.35rem; border-bottom: 1px solid var(--line); }
.page-heading__context { margin-bottom: .35rem; font-size: .85rem; }
.page-title { font-size: clamp(1.8rem, 3.5vw, 2.45rem); margin-bottom: .55rem; }
.section-title { font-size: clamp(1.2rem, 2vw, 1.45rem); margin-bottom: .6rem; }
.body-copy { margin: .35rem 0; }
.button { min-height: 42px; border-radius: .3rem; transition: background-color .15s ease, border-color .15s ease; }
.button--primary { box-shadow: inset 0 -1px 0 rgb(0 0 0 / .22); }
.button--quiet { border-color: #63808b; }
.button--quiet:hover { background: var(--raised); border-color: var(--copper); }
.form-panel, .detail-section { max-width: none; padding: 1.1rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--slate); }
.form-stack { gap: .9rem; }
.personal-form { grid-template-columns: minmax(11rem, 1fr) minmax(13rem, 1fr) minmax(18rem, 2fr); align-items: end; }
.personal-form .date-fields, .personal-form .personal-options, .personal-form .personal-field--cover, .personal-form .personal-cover-link, .personal-form .field--wide, .personal-form .form-action--wide { grid-column: 1 / -1; }
.personal-options { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; min-height: 44px; }
.personal-options .field--check { margin: 0; }
.field { gap: .28rem; font-size: .9rem; }
.field__input { min-height: 44px; padding: .55rem .65rem; border-color: #69818b; background: #101b23; }
.field__textarea { min-height: 6rem; }
.detail-section--danger { border-color: #895959; background: #211d22; }
.game-list { grid-template-columns: minmax(0, 1fr); gap: 1px; margin-top: 1rem; border: 1px solid var(--line); background: var(--line); }
.game-entry { gap: .85rem; padding: .8rem; border-radius: 0; background: var(--slate); }
.game-entry:hover { background: var(--raised); }
.game-entry__cover { flex-basis: 4rem; width: 4rem; min-height: 5.5rem; border-radius: .15rem; }
.game-entry img.game-entry__cover { height: 5.5rem; }
.game-entry__body { display: grid; align-content: center; gap: .35rem; width: 100%; }
.game-entry__status { width: fit-content; margin: 0; padding: .14rem .5rem; color: var(--copper); border: 1px solid #806544; border-radius: 999px; font-size: .78rem; line-height: 1.35; }
.location-list { gap: .35rem; }
.location-tag { padding: .16rem .5rem; border-color: #597480; background: #101b23; font-size: .85rem; }
.location-list__empty { padding: .16rem 0; font-size: .85rem; }
.library-filters { gap: .65rem; margin-top: 1rem; padding: .85rem; border-color: var(--line); background: var(--raised); }
.library-count { margin-top: .85rem; }
.empty-library { margin-top: 1.5rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--slate); }
.search-form, .inline-form { gap: .6rem; }
.result-list { gap: 1px; border: 1px solid var(--line); background: var(--line); }
.result-row { padding: .7rem; border-radius: 0; background: var(--slate); }
.import-heading { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.import-summary { border-color: var(--line); background: var(--line); }
.import-summary div, .import-entry { background: var(--slate); }
.import-entry { padding: .8rem; }
.import-list { border-color: var(--line); background: var(--line); }
.status-message { border: 1px solid var(--line); border-radius: .3rem; }

@media (min-width: 48rem) {
  .game-entry { display: grid; grid-template-columns: 4rem minmax(0, 1fr); align-items: center; }
  .game-entry__body { grid-template-columns: minmax(12rem, 1.2fr) auto minmax(14rem, 1fr); align-items: center; gap: .8rem; }
  .game-entry__body .section-title { grid-column: 1; grid-row: 1; }
  .game-entry__status { grid-column: 1; grid-row: 2; }
  .game-entry__body .location-list { grid-column: 3; grid-row: 1 / span 2; justify-content: flex-start; }
  .form-panel { max-width: 46rem; }
}

@media (max-width: 47.99rem) {
  .personal-form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
  .personal-form .personal-field--tags { grid-column: 1 / -1; }
}
