/* Guitarbin — warm valve-amp aesthetic: charcoal chassis, amber glow,
   tab text as the hero in mono. */

:root {
  --ink:        #14110d;
  --chassis:    #1c1813;
  --panel:      #221d17;
  --panel-lift: #2a241c;
  --line:       #3a3126;
  --cream:      #f0e6d6;
  --cream-dim:  #b6aa96;
  --muted:      #857a68;
  --amber:      #e8a33d;
  --amber-soft: #f2c67f;
  --rust:       #c05f34;
  --danger:     #b8482f;

  --rail-w:  312px;
  --pedal-w: 296px;

  --font-display: "Instrument Serif", Georgia, serif;
  --font-ui: "Archivo", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --tab-size: 14px;
}

* { box-sizing: border-box; }

/* Author `display` rules outrank the UA rule behind the hidden attribute,
   so panels toggled with el.hidden need this to actually disappear. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #241e17 0%, transparent 60%),
    linear-gradient(180deg, var(--chassis) 0%, var(--ink) 100%);
  background-attachment: fixed;
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Fine grain over the whole chassis */
.grain {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

::selection { background: var(--amber); color: var(--ink); }

/* ── Type ─────────────────────────────────────────────── */

.wordmark {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: .01em;
  color: var(--cream);
  line-height: 1;
}

.tagline {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Buttons ──────────────────────────────────────────── */

.btn {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 9px 16px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream-dim);
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s, transform .1s;
}

.btn:hover { color: var(--cream); border-color: var(--amber); }
.btn:active { transform: translateY(1px); }

.btn-amber {
  background: var(--amber);
  border-color: var(--amber);
  color: #221a0c;
}
.btn-amber:hover {
  background: var(--amber-soft);
  border-color: var(--amber-soft);
  color: #221a0c;
}

.btn-danger:hover { color: #f0b6a6; border-color: var(--danger); }
.btn-block { width: 100%; margin-top: 8px; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--cream-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color .16s, border-color .16s;
}
.icon-btn:hover { color: var(--amber); border-color: var(--amber); }
.icon-btn.is-on { color: var(--amber); border-color: var(--amber); }

/* ── Login ────────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 32px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}

.login-mark { margin-bottom: 26px; }
.login-mark .wordmark { display: block; }
.login-mark .tagline { display: block; margin-top: 6px; }

.login-card label {
  display: block;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.login-card .btn { width: 100%; margin-top: 18px; }

.login-error {
  margin: 12px 0 0;
  font-size: 12px;
  color: #e79b84;
}

/* ── Inputs ───────────────────────────────────────────── */

input[type="text"],
input[type="search"],
input[type="password"],
textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--cream);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

input:focus, textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232,163,61,.12);
}

input::placeholder { color: var(--muted); }

textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  min-height: 420px;
  resize: vertical;
}

/* ── Shell ────────────────────────────────────────────── */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}

.brand { display: flex; align-items: baseline; gap: 16px; }

.brand-rule {
  width: 54px;
  height: 1px;
  background: linear-gradient(90deg, var(--amber), transparent);
}

.topbar-actions { display: flex; gap: 10px; }

.frame {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--pedal-w);
  min-height: 0;
}

/* ── Library rail ─────────────────────────────────────── */

.rail {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(0,0,0,.16);
}

.searchbox { padding: 18px 18px 12px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 8px 4px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .16s, border-color .16s;
}

.tab:hover { color: var(--cream-dim); }
.tab.is-active { color: var(--amber); border-bottom-color: var(--amber); }

.rail-scroll { flex: 1; overflow-y: auto; padding: 10px 12px 20px; min-height: 0; }

.songlist { list-style: none; margin: 0; padding: 0; }

.song {
  padding: 10px 12px;
  border-radius: 2px;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}

.song:hover { background: var(--panel-lift); }

.song.is-active {
  background: var(--panel-lift);
  border-left-color: var(--amber);
}

.song-title {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cream);
  line-height: 1.35;
}

.song-meta {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.song-star { color: var(--amber); margin-left: 6px; }

.rail-empty {
  padding: 26px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ── Stage ────────────────────────────────────────────── */

.stage { overflow-y: auto; padding: 34px 40px 60px; min-height: 0; }

.placeholder {
  max-width: 380px;
  margin: 16vh auto 0;
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}

.placeholder-glyph {
  font-family: var(--font-display);
  font-size: 58px;
  color: var(--line);
  margin: 0 0 12px;
}

.sheet { max-width: 860px; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 400;
  line-height: 1.1;
  margin: 0;
}

.sheet-artist {
  margin: 6px 0 0;
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--amber);
}

.sheet-actions { display: flex; align-items: center; gap: 8px; }
.zoom { display: flex; gap: 4px; }

.sheet-source {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.sheet-source a { color: var(--cream-dim); }

.tabtext {
  margin: 22px 0 0;
  padding: 26px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--tab-size);
  line-height: 1.62;
  color: var(--cream);
  white-space: pre-wrap;
  overflow-x: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

/* Chord tokens inside the tab text */
.chord {
  font: inherit;
  color: var(--amber);
  font-weight: 700;
  background: transparent;
  border: 0;
  border-bottom: 1px dotted rgba(232,163,61,.45);
  padding: 0;
  cursor: pointer;
  transition: color .14s, background .14s;
}

.chord:hover { color: #ffd08a; background: rgba(232,163,61,.13); }
.chord.is-active { background: rgba(232,163,61,.2); color: #ffd9a0; }

/* ── Editor ───────────────────────────────────────────── */

.editor { max-width: 860px; }

.editor-heading {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  margin: 0 0 24px;
}

.field { display: block; margin-bottom: 18px; }

.field > span {
  display: block;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-row { display: flex; gap: 18px; }
.field-row .field { flex: 1; }

.editor-actions { display: flex; gap: 10px; }

/* ── Chord pedal ──────────────────────────────────────── */

.pedal { padding: 28px 20px; border-left: 1px solid var(--line); }

.pedal-plate {
  position: sticky;
  top: 28px;
  padding: 22px 20px 18px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--panel-lift), var(--panel));
  box-shadow:
    0 18px 40px rgba(0,0,0,.5),
    inset 0 1px 0 rgba(255,255,255,.05);
}

.pedal-screw {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6a5c46, #241f18);
}
.pedal-screw.tl { top: 8px; left: 8px; }
.pedal-screw.tr { top: 8px; right: 8px; }
.pedal-screw.bl { bottom: 8px; left: 8px; }
.pedal-screw.br { bottom: 8px; right: 8px; }

.pedal-label {
  margin: 0;
  font-size: 10px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.pedal-chord {
  margin: 6px 0 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(232,163,61,.45);
  min-height: 34px;
}

.pedal-window {
  background: #f4efe4;
  border-radius: 3px;
  padding: 10px;
  min-height: 190px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3);
}

.pedal-window img { width: 100%; display: block; }

.pedal-hint {
  margin: 0;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  color: #6b6152;
  text-align: center;
}

.pedal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.pedal-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cream-dim);
  min-width: 54px;
  text-align: center;
}

/* ── Toast ────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 11px 20px;
  border-radius: 2px;
  border: 1px solid var(--amber);
  background: var(--panel-lift);
  color: var(--cream);
  font-size: 13px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  animation: toast-in .2s ease-out;
}

.toast.is-error { border-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.is-busy { opacity: .5; pointer-events: none; }

/* ── Narrow screens ───────────────────────────────────── */

@media (max-width: 1180px) {
  .frame { grid-template-columns: 260px minmax(0, 1fr); }
  .pedal {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .pedal-plate { position: static; max-width: 320px; margin: 0 auto; }
}

@media (max-width: 820px) {
  .frame { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 45vh; }
  .stage { padding: 24px 20px 40px; }
  .sheet-title { font-size: 30px; }
}
