:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1e232e;
  --line: #2a3140;
  --text: #e8ecf4;
  --muted: #97a1b4;
  --accent: #7c5cff;
  --accent-2: #23d3a2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1b1740 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  min-height: 100vh;
}

button, input, textarea { font: inherit; color: inherit; }

/* Login ------------------------------------------------------------------ */
body.login { display: grid; place-items: center; }

body.login form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  width: min(360px, 90vw);
  display: grid;
  gap: 14px;
}

body.login h1 { margin: 0 0 4px; font-size: 22px; }
body.login .error { margin: 0; color: #ff7a85; font-size: 13px; }

body.login input, body.login button {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 12px 14px;
}

body.login button {
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
  cursor: pointer;
}

/* Layout ----------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 18px;
  max-width: 1500px;
  margin: 0 auto;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand h1 { font-size: 17px; margin: 0; }
.brand form button {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px;
}

.book-list, .track-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.book-list button, .track-list button {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.book-list button:hover, .track-list button:hover { border-color: var(--line); }
.book-list button.active, .track-list button.active { border-color: var(--accent); background: #241f45; }
.track-list .dur { float: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Player ----------------------------------------------------------------- */
.now h1 { margin: 0 0 4px; font-size: 26px; }
.now .sub { color: var(--muted); margin: 0 0 22px; }

.scrub { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.scrub input[type=range] { flex: 1; accent-color: var(--accent); }
.scrub .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 52px; }

.controls { display: flex; align-items: center; gap: 12px; margin: 18px 0 26px; }

.controls button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}

.controls .play {
  background: var(--accent);
  border-color: transparent;
  font-weight: 700;
  min-width: 96px;
}

.controls select {
  margin-left: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
}

/* Chat ------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; display: grid; gap: 12px; align-content: start; max-height: 60vh; }

.msg { padding: 10px 13px; border-radius: 12px; background: var(--panel-2); }
.msg.user { background: #241f45; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 4px; }
.msg .sources { margin-top: 8px; font-size: 12px; color: var(--muted); }
.msg .sources div { margin-top: 3px; }

.composer { display: flex; gap: 8px; margin-top: 14px; }
.composer textarea {
  flex: 1;
  resize: none;
  height: 62px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.composer button {
  background: var(--accent-2);
  color: #05231b;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  cursor: pointer;
}

.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .messages { max-height: 42vh; }
}
