/* JeddrAudio Patch List — dark studio theme
   Ported from the original HSL design tokens (§2.3). */

:root {
  --background: hsl(220 20% 10%);
  --card:       hsl(220 18% 13%);
  --card-hover: hsl(220 18% 16%);
  --primary:    hsl(35 100% 55%);
  --accent:     hsl(35 80% 50%);
  --led-glow:   hsl(35 100% 55%);
  --foreground: hsl(40 20% 92%);
  --muted:      hsl(40 10% 60%);
  --border:     hsl(220 15% 22%);
  --danger:     hsl(0 70% 55%);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit;
  font-weight: 500;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: hsl(220 25% 10%);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: hsl(0 70% 55% / .12); }
.btn-ghost { background: transparent; border-color: transparent; }

/* ---- Labels / inputs ---------------------------------------------------- */
.label-studio {
  display: block;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .68rem;
  color: var(--muted);
  margin: .6rem 0 .25rem;
}
.input-studio {
  width: 100%;
  font: inherit;
  color: var(--foreground);
  background: hsl(220 20% 9%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .6rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-studio:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px hsl(35 100% 55% / .25);
}

/* ---- Login -------------------------------------------------------------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
}
.login-title { margin: 0; font-size: 1.6rem; }
.login-sub {
  margin: .15rem 0 1.25rem;
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
}
.login-card .btn-primary { margin-top: 1.25rem; }
.login-error { color: var(--danger); min-height: 1.2em; margin: .6rem 0 0; font-size: .85rem; }

/* ---- App header --------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.2rem;
  background: hsl(220 20% 10% / .8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: .7rem; }
.header-logo { font-size: 1.6rem; color: var(--primary); }
.header-title { font-weight: 700; font-size: 1.05rem; }
.header-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  color: var(--muted);
}
.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  flex: 1 1 280px;
}
.header-meta input {
  font: inherit;
  color: var(--foreground);
  background: hsl(220 20% 9%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .55rem;
}
.meta-name { flex: 2 1 160px; font-weight: 600; }
.meta-desc { flex: 2 1 160px; }
.meta-date { flex: 0 0 auto; color-scheme: dark; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Channel grid ------------------------------------------------------- */
.channel-grid {
  display: grid;
  gap: .9rem;
  padding: 1.2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 560px)  { .channel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 820px)  { .channel-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .channel-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1400px) { .channel-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1700px) { .channel-grid { grid-template-columns: repeat(6, 1fr); } }

/* ---- Channel strip ------------------------------------------------------ */
.channel-strip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  transition: border-color .15s, box-shadow .15s, transform .08s, opacity .15s;
}
.channel-strip:hover { border-color: hsl(220 15% 30%); }
.channel-strip.filled {
  border-color: hsl(35 100% 55% / .4);
  box-shadow: 0 0 0 1px hsl(35 100% 55% / .15);
}
.channel-strip.dragging { opacity: .4; }
.channel-strip.drag-over { border-color: var(--primary); transform: scale(1.02); }

.channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
  cursor: grab;
}
.channel-header:active { cursor: grabbing; }
.channel-number {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  text-shadow: 0 0 10px hsl(35 100% 55% / .4);
}
.channel-number .split {
  font-size: .8rem;
  opacity: .45;
  margin-left: .25rem;
}

/* 48V LED toggle */
.phantom {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  user-select: none;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.phantom-indicator {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: hsl(220 15% 25%);
  transition: background .15s, box-shadow .15s;
}
.phantom-on .phantom-indicator {
  background: var(--led-glow);
  box-shadow: 0 0 8px 1px var(--led-glow);
}
.phantom-on { color: var(--primary); }

.channel-field { margin-top: .45rem; }
.channel-field .label-studio { margin: 0 0 .15rem; }

/* ---- Footer ------------------------------------------------------------- */
.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1rem 1.2rem 2rem;
  color: var(--muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}
.app-footer strong { color: var(--primary); font-family: 'JetBrains Mono', monospace; }

/* ---- Dialog ------------------------------------------------------------- */
.dialog {
  width: min(560px, 92vw);
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
}
.dialog-sm { width: min(380px, 92vw); }
.dialog::backdrop { background: hsl(220 30% 4% / .65); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.dialog-row-end { justify-content: flex-end; }
.dialog-row .input-studio { flex: 1 1 180px; width: auto; }
.dialog-empty { color: var(--muted); text-align: center; padding: 1rem 0; }

.session-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.session-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: .5rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.session-item:hover { background: var(--card-hover); border-color: hsl(220 15% 30%); }
.session-item-main { flex: 1 1 auto; min-width: 0; }
.session-item-name { font-weight: 600; }
.session-item-meta {
  font-size: .78rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item-del {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: .3rem .45rem;
  border-radius: 8px;
}
.session-item-del:hover { color: var(--danger); background: hsl(0 70% 55% / .12); }

/* ---- Toasts ------------------------------------------------------------- */
.toast-host {
  position: fixed;
  bottom: 1rem; right: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 100;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: .65rem .9rem;
  font-size: .88rem;
  box-shadow: 0 8px 24px hsl(220 30% 4% / .5);
  animation: toast-in .2s ease;
}
.toast-error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* custom scrollbar */
.session-list::-webkit-scrollbar { width: 10px; }
.session-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
