/* lab980 dark/mono. One palette, defined once, no framework. */

:root {
  --bg: #101215;
  --panel: #171a1f;
  --edge: #262b33;
  --ink: #d6dbe2;
  --dim: #8a93a0;
  --accent: #5fb0e5;
  --warn: #e0a06a;
  --bad: #e06c75;
  --good: #8cc98c;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute is only a UA-stylesheet `display: none`, so ANY
   display rule of ours beats it — `.search-opts label { display: flex }` was
   silently showing a control that JS had hidden. Make the attribute win. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
code { color: var(--warn); }

/* --- header ---------------------------------------------------------------- */

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--edge);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.bar h1 {
  font-size: 1rem;
  margin: 0;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.bar h1 span { color: var(--dim); margin-left: .4em; }

.bar-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

button, .ghost, select, input {
  font: inherit;
  color: var(--ink);
  background: #1d2128;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: .4rem .7rem;
  cursor: pointer;
}
button:hover, .ghost:hover { border-color: #3a424e; }
button:disabled { opacity: .45; cursor: not-allowed; }
.accent { background: #16344a; border-color: #27536f; color: #cfe6f7; }
.accent:hover { background: #1b3f5a; }
.wide { width: 100%; margin-top: .75rem; }
a.ghost { text-decoration: none; display: inline-block; }
input[type="search"], input[type="number"], input[type="password"] { cursor: text; }

.banner {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--edge);
  background: #2a1f1a;
  color: var(--warn);
}
.banner.bad { background: #2a1a1c; color: var(--bad); }
.banner.good { background: #1a2a1e; color: var(--good); }

/* --- layout ---------------------------------------------------------------- */

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  align-items: start;
}

@media (min-width: 900px) {
  main:has(.panel:not([hidden])) { grid-template-columns: 1fr 24rem; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel h2 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); }

.hint { color: var(--dim); font-size: .82rem; line-height: 1.5; }
.empty { color: var(--dim); padding: 2rem 0; text-align: center; }

/* --- pads ------------------------------------------------------------------ */

.pads {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .6rem;
}

.pad {
  position: relative;
  border: 1px solid var(--edge);
  border-left: 3px solid var(--pad-color, var(--accent));
  border-radius: var(--radius);
  background: #1a1e24;
  padding: .6rem .7rem .5rem;
  text-align: left;
  min-height: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: transform .06s ease, background .12s ease;
}
.pad:hover { background: #1f242b; }
.pad:active, .pad.playing { transform: translateY(1px); background: #253039; }
.pad.playing { box-shadow: inset 0 0 0 1px var(--pad-color, var(--accent)); }

.pad-label { font-weight: 600; overflow-wrap: anywhere; }
/* The pad's trigger is a real button for keyboard and screen-reader reasons,
   but it must not look like one — the pad is the affordance. It cannot be the
   pad element itself, because the pad also holds the rename/loop/remove
   buttons and nesting a button inside a button is invalid. */
button.pad-label {
  all: unset;
  cursor: pointer;
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}
button.pad-label:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pad-meta { color: var(--dim); font-size: .74rem; margin-top: auto; }
.pad-key {
  position: absolute;
  top: .4rem;
  right: .45rem;
  font-size: .68rem;
  color: var(--dim);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 0 .3rem;
}
.pad-nc { color: var(--warn); }

.pad-edit {
  display: flex;
  gap: .35rem;
  margin-top: .4rem;
}
.pad-edit button { padding: .15rem .4rem; font-size: .72rem; background: transparent; }

/* --- search ---------------------------------------------------------------- */

.search-form { display: flex; gap: .5rem; }
.search-form input { flex: 1; }
.search-opts { display: flex; flex-direction: column; gap: .3rem; margin: .6rem 0; font-size: .82rem; color: var(--dim); }
.search-opts label { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; cursor: pointer; }
/* The parenthetical belongs under its label, not squeezed beside it. */
.search-opts label .hint { flex-basis: 100%; margin-left: 1.4rem; }
.search-opts input[type="number"] { width: 4rem; padding: .15rem .3rem; }

.results { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.result {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  background: #1a1e24;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem;
  align-items: center;
}
.result-name { overflow-wrap: anywhere; }
.result-meta { grid-column: 1 / -1; color: var(--dim); font-size: .74rem; }
.result-actions { display: flex; gap: .35rem; }
.result-actions button { padding: .25rem .5rem; font-size: .78rem; }
.lic { border: 1px solid var(--edge); border-radius: 3px; padding: 0 .25rem; font-size: .7rem; }
.lic-by-nc { color: var(--warn); border-color: #4a3a28; }
.lic-cc0 { color: var(--good); border-color: #2a4030; }

/* --- credits --------------------------------------------------------------- */

.credits-list { margin: .75rem 0; padding-left: 1.1rem; font-size: .82rem; }
.credits-list li { margin-bottom: .5rem; }
.credits-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
#credits-summary { font-size: .82rem; margin: .5rem 0; }
#credits-summary .flag { color: var(--warn); }

/* --- footer + dialog ------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--edge);
  padding: 1rem;
  color: var(--dim);
  font-size: .78rem;
}
.foot p { margin: .25rem 0; max-width: 60rem; }

dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 28rem;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin-top: 0; font-size: .9rem; text-transform: uppercase; color: var(--dim); }
dialog input { width: 100%; margin: .75rem 0; }
dialog menu { display: flex; gap: .5rem; justify-content: flex-end; margin: 0; padding: 0; }

/* --- translated titles, dedup, similarity scan ------------------------------ */

.pad-original,
.result-original,
.variant-name {
  color: var(--dim);
  font-size: .72rem;
  overflow-wrap: anywhere;
}
/* The original sits under the translated label, quieter than it but never
   hidden: it is the name the credits will carry. */
.pad-original { margin-top: -.15rem; font-style: italic; }
.result-original { display: block; font-style: italic; margin-top: .1rem; }

@keyframes pad-flash {
  0%, 100% { box-shadow: none; }
  25%, 75% { box-shadow: 0 0 0 2px var(--accent); }
}
.pad.flash { animation: pad-flash 1.6s ease; }

.banner-action {
  margin-left: .6rem;
  padding: .1rem .5rem;
  font-size: .78rem;
  background: transparent;
  border-color: currentColor;
  color: inherit;
}

.variants { margin-top: .35rem; grid-column: 1 / -1; }
.variants summary { color: var(--dim); font-size: .76rem; cursor: pointer; }
.variants summary:hover { color: var(--ink); }
.variants ul { list-style: none; margin: .4rem 0 0; padding: 0 0 0 .75rem; border-left: 1px solid var(--edge); }
.variants li {
  display: flex;
  gap: .5rem;
  align-items: center;
  justify-content: space-between;
  padding: .2rem 0;
}
.variants .variant-name { font-size: .78rem; color: var(--ink); }

.board-tools { margin-top: 1.25rem; }
#scan-result { margin-top: .6rem; }
.scan-group {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .45rem .6rem;
  margin-bottom: .4rem;
  border: 1px solid var(--edge);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--panel);
}
.scan-hit { padding: .15rem .45rem; font-size: .76rem; background: transparent; }
