/* ============================================================
   THE STACKS — hi-fi console theme
   Warm charcoal chassis, engraved format labels, mono spec type.
   ============================================================ */
:root {
  --bg:        #201f1c;   /* warm charcoal chassis */
  --bg-raise:  #282723;   /* card face */
  --bg-inset:  #1a1917;   /* inset wells (inputs) */
  --line:      #38362f;
  --line-soft: #2e2c27;
  --text:      #d9d5cc;
  --text-dim:  #98938a;
  --accent:    #e2a13d;   /* VU-meter amber */
  --accent-dn: #b57e2a;
  --danger:    #d1705c;

  /* format label tints (muted, engraved) */
  --tint-lp:     #e2a13d;
  --tint-cd:     #8fb6c9;
  --tint-dvd:    #c98f8f;
  --tint-bluray: #7f9fd1;
  --tint-book:   #9dc08b;

  --font-display: 'Archivo', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-display);
}
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--bg-raise), var(--bg));
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 800; letter-spacing: .22em; font-size: 1.05rem;
  color: var(--text);
}
.brand-mark::after { content: ""; display: block; height: 2px; margin-top: 3px;
  background: var(--accent); width: 2.2em; }
.brand-sub {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim); margin-top: 5px;
}
.header-actions { margin-left: auto; display: flex; gap: .6rem; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-display); font-weight: 600; font-size: .85rem;
  padding: .5rem .95rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--text);
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--text-dim); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #201a10; }
.btn-accent:hover { background: var(--accent-dn); border-color: var(--accent-dn); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: rgba(209,112,92,.12); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- inputs ---------- */
input[type=text], input[type=search], input[type=number], input[type=password],
select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem .7rem;
}
textarea { width: 100%; min-height: 5.5rem; resize: vertical; }
label { font-size: .8rem; color: var(--text-dim); }

/* ---------- format chips (the engraved labels) ---------- */
.chip {
  font-family: var(--font-mono); font-size: .6rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 3px;
  border: 1px solid; background: var(--bg-inset);
  display: inline-block;
}
.chip-lp     { color: var(--tint-lp);     border-color: color-mix(in srgb, var(--tint-lp) 45%, transparent); }
.chip-cd     { color: var(--tint-cd);     border-color: color-mix(in srgb, var(--tint-cd) 45%, transparent); }
.chip-dvd    { color: var(--tint-dvd);    border-color: color-mix(in srgb, var(--tint-dvd) 45%, transparent); }
.chip-bluray { color: var(--tint-bluray); border-color: color-mix(in srgb, var(--tint-bluray) 45%, transparent); }
.chip-book   { color: var(--tint-book);   border-color: color-mix(in srgb, var(--tint-book) 45%, transparent); }

/* ---------- search console ---------- */
.console {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--line-soft);
}
.console-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.console input[type=search] { flex: 1 1 260px; }
.type-toggle { display: flex; gap: .35rem; flex-wrap: wrap; }
.type-toggle button {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; cursor: pointer;
  padding: .38rem .6rem; border-radius: 4px;
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
}
.type-toggle button.on { color: var(--accent); border-color: var(--accent); }
.filters {
  display: none; flex-wrap: wrap; gap: .6rem; margin-top: .7rem;
}
.filters.open { display: flex; }
.filters input { flex: 1 1 150px; min-width: 0; }
.filters .year-pair { display: flex; gap: .4rem; flex: 0 1 190px; }
.filters .year-pair input { width: 50%; }
.result-line {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .1em;
  color: var(--text-dim); margin-top: .7rem; text-transform: uppercase;
}
.result-line b { color: var(--accent); font-weight: 500; }

/* ---------- shelf grid ---------- */
.shelf {
  display: grid; gap: 1.1rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  padding: 1.25rem;
}
.card { display: flex; flex-direction: column; gap: .45rem; }
.card .sleeve {
  aspect-ratio: 1 / 1; overflow: hidden; border-radius: 5px;
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  box-shadow: 3px 3px 0 0 var(--bg-inset);   /* the shelf shadow */
  display: grid; place-items: center;
  transition: transform .15s, box-shadow .15s;
}
.card:hover .sleeve { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 0 var(--bg-inset); }
.card .sleeve img { width: 100%; height: 100%; object-fit: cover; }
.card .sleeve.book-shape { aspect-ratio: 2 / 3; }
.card .sleeve.disc-shape { aspect-ratio: 3 / 4; }
.card .no-cover {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .12em;
  color: var(--text-dim); text-transform: uppercase; text-align: center; padding: .5rem;
}
.card .card-title { font-weight: 600; font-size: .86rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .card-meta {
  font-family: var(--font-mono); font-size: .66rem; color: var(--text-dim);
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
}
.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 4rem 1rem; color: var(--text-dim);
}
.empty-state .btn { margin-top: 1rem; }

/* ---------- detail: the spec plate ---------- */
.detail-wrap {
  display: grid; grid-template-columns: minmax(220px, 380px) 1fr;
  gap: 2rem; padding: 2rem 1.25rem; max-width: 1050px; margin: 0 auto;
}
.detail-cover { border-radius: 6px; border: 1px solid var(--line);
  box-shadow: 6px 6px 0 0 var(--bg-inset); width: 100%; }
.detail-head h1 { font-size: 1.6rem; font-weight: 800; margin: .3rem 0 .2rem; line-height: 1.2; }
.detail-head .creator { color: var(--text-dim); font-size: 1.05rem; margin: 0 0 1rem; }
.spec-plate {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-raise); overflow: hidden; margin-top: 1rem;
}
.spec-plate .plate-title {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--text-dim);
  padding: .55rem .9rem; border-bottom: 1px solid var(--line-soft);
  background: var(--bg-inset);
}
.spec-row { display: grid; grid-template-columns: 130px 1fr;
  padding: .5rem .9rem; border-bottom: 1px solid var(--line-soft); }
.spec-row:last-child { border-bottom: 0; }
.spec-row dt { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-dim); align-self: center; }
.spec-row dd { margin: 0; font-size: .92rem; }
.detail-notes { margin-top: 1.25rem; color: var(--text); white-space: pre-wrap; }
.detail-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }

/* ---------- add/edit page ---------- */
.add-wrap { max-width: 880px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.tabs button {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; cursor: pointer;
  background: none; border: none; color: var(--text-dim);
  padding: .6rem .9rem; border-bottom: 2px solid transparent;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.on { display: block; }

.lookup-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lookup-row select { flex: 0 0 auto; }
.lookup-row input { flex: 1 1 220px; }

.lookup-results { display: flex; flex-direction: column; gap: .5rem; }
.hit {
  display: grid; grid-template-columns: 56px 1fr auto; gap: .8rem;
  align-items: center; padding: .55rem .7rem;
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  border-radius: 6px; cursor: pointer; text-align: left; color: var(--text);
  font: inherit; width: 100%;
}
.hit:hover { border-color: var(--accent); }
.hit img, .hit .ph { width: 56px; height: 56px; object-fit: cover; border-radius: 4px;
  background: var(--bg-inset); }
.hit .ph { display: grid; place-items: center; font-family: var(--font-mono);
  font-size: .55rem; color: var(--text-dim); }
.hit .hit-title { font-weight: 600; font-size: .88rem; }
.hit .hit-meta { font-family: var(--font-mono); font-size: .66rem; color: var(--text-dim); }
.hit .hit-go { font-family: var(--font-mono); font-size: .62rem; color: var(--accent);
  letter-spacing: .12em; }

#scanner-box { max-width: 420px; margin: 0 auto 1rem; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); }
.scan-hint { font-family: var(--font-mono); font-size: .68rem; color: var(--text-dim);
  text-align: center; letter-spacing: .08em; }

.item-form { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; margin-top: 1.5rem;
  padding-top: 1.25rem; border-top: 1px dashed var(--line); }
.item-form .full { grid-column: 1 / -1; }
.item-form .field { display: flex; flex-direction: column; gap: .3rem; }
.form-cover { display: flex; gap: 1rem; align-items: center; grid-column: 1 / -1; }
.form-cover img { width: 84px; height: 84px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); }
.form-actions { grid-column: 1 / -1; display: flex; gap: .6rem; margin-top: .5rem; }
.save-note { font-family: var(--font-mono); font-size: .7rem; color: var(--tint-book);
  align-self: center; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(360px, 92vw); padding: 2.2rem 2rem;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 8px 8px 0 0 var(--bg-inset);
}
.login-card .brand { margin-bottom: 1.6rem; }
.login-form { display: flex; flex-direction: column; gap: .7rem; }
.login-form .check { display: flex; gap: .5rem; align-items: center; font-size: .8rem;
  color: var(--text-dim); }
.login-error { color: var(--danger); font-size: .85rem; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .detail-wrap { grid-template-columns: 1fr; padding-top: 1.25rem; }
  .detail-cover { max-width: 300px; }
  .item-form { grid-template-columns: 1fr; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .9rem .7rem;
    padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- locations ---------- */
.loc-layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 60px); }
.loc-sidebar {
  border-right: 1px solid var(--line); padding: 1rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.loc-new { display: flex; gap: .4rem; margin-bottom: .8rem; }
.loc-new input { flex: 1; min-width: 0; }
.loc-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text);
  font: inherit; text-align: left; width: 100%;
}
.loc-item:hover { border-color: var(--line); }
.loc-item.on { border-color: var(--accent); background: var(--bg-raise); }
.loc-item .loc-name { flex: 1; font-weight: 600; font-size: .88rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-item .loc-count { font-family: var(--font-mono); font-size: .66rem; color: var(--text-dim); }
.loc-item .loc-tools { display: none; gap: .2rem; }
.loc-item:hover .loc-tools, .loc-item.on .loc-tools { display: flex; }
.loc-tools button { background: none; border: none; cursor: pointer; color: var(--text-dim);
  font-size: .75rem; padding: .1rem .25rem; }
.loc-tools button:hover { color: var(--accent); }
.loc-main { padding: 1rem 1.25rem; }
.loc-main-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.loc-main-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.loc-main-head .result-line { margin: 0; }
.loc-main .shelf { padding: 1rem 0; }

/* ---------- select mode + action bar ---------- */
body.selecting .card .sleeve { cursor: pointer; }
.card { position: relative; }
.card .tick {
  position: absolute; top: .4rem; left: .4rem; z-index: 2;
  width: 22px; height: 22px; border-radius: 5px;
  border: 1px solid var(--text-dim); background: rgba(26,25,23,.85);
  display: none; place-items: center;
  font-size: .8rem; color: transparent;
}
body.selecting .card .tick { display: grid; }
.card.picked .tick { border-color: var(--accent); color: var(--accent); }
.card.picked .sleeve { outline: 2px solid var(--accent); outline-offset: -2px; }
.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: none; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .7rem 1.25rem;
  background: var(--bg-raise); border-top: 1px solid var(--accent);
}
.action-bar.on { display: flex; }
.action-bar .sel-count { font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.action-bar select { min-width: 170px; }

@media (max-width: 720px) {
  .loc-layout { grid-template-columns: 1fr; }
  .loc-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}

.source-link { color: var(--accent); border-bottom: 1px dotted var(--accent); }
.source-link:hover { border-bottom-style: solid; }

/* ---------- cover picker ---------- */
.cover-tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.cover-tools input { flex: 1 1 220px; min-width: 0; }
.cover-gallery { display: flex; flex-wrap: wrap; gap: .5rem; }
.cover-opt {
  padding: 0; border: 2px solid var(--line); border-radius: 6px;
  background: var(--bg-inset); cursor: pointer; overflow: hidden;
  width: 96px; height: 96px;
}
.cover-opt img { width: 100%; height: 100%; object-fit: cover; }
.cover-opt:hover { border-color: var(--text-dim); }
.cover-opt.on { border-color: var(--accent); }
