:root {
  --bg: #fff8ee;
  --panel: #fffdfa;
  --panel-2: #fbf1e4;
  --line: #eadbcc;
  --ink: #3b2a20;
  --muted: #8a7363;
  --accent: #e2785f;
  --accent-ink: #ffffff;
  --accent-soft: #f9d4c4;
  --danger: #c2413a;
  --ok: #3f9b68;
  --warn: #d49a2a;
  --shadow: 0 10px 30px #7a4a2a14;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1512; --panel: #241d18; --panel-2: #2d241e; --line: #3d3129; --ink: #f6ebe1; --muted: #b59f8f;
    --accent: #f0907a; --accent-ink: #2a140c; --accent-soft: #5a3326; --danger: #ef7d75; --ok: #6cc796; --warn: #e9b955;
    --shadow: 0 10px 30px #0006; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1512; --panel: #241d18; --panel-2: #2d241e; --line: #3d3129; --ink: #f6ebe1; --muted: #b59f8f;
  --accent: #f0907a; --accent-ink: #2a140c; --accent-soft: #5a3326; --danger: #ef7d75; --ok: #6cc796; --warn: #e9b955;
  --shadow: 0 10px 30px #0006; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Nunito, system-ui, sans-serif; min-height: 100vh; }
a { color: var(--accent); }
h1, h2 { font-family: 'Baloo 2', Nunito, sans-serif; line-height: 1.15; margin: 0 0 8px; }
h1 { font-size: 30px; }
h2 { font-size: 19px; margin-top: 8px; }
.muted, .hint { color: var(--muted); }
.hint { display: block; font-size: 12px; margin-top: 4px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { font-size: 26px; }
.brand strong { display: block; font-family: 'Baloo 2', sans-serif; letter-spacing: .04em; line-height: 1; }
.brand small { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.account { display: flex; align-items: center; gap: 10px; }
.user { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.user img { border-radius: 50%; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none; }
.button.small { padding: 6px 12px; font-size: 13px; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.quiet { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.button:hover:not(:disabled) { filter: brightness(1.05); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button:focus-visible, select:focus-visible, input:focus-visible, .module-link:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }

.welcome { max-width: 640px; margin: 72px auto; padding: 0 16px; text-align: center; }
.welcome h1 { font-size: 40px; }
.welcome h1 span { color: var(--accent); }
.welcome p { color: var(--muted); margin: 12px 0 24px; }
.error-text { color: var(--danger) !important; }

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { border-right: 1px solid var(--line); padding: 20px 16px; background: var(--panel); }
.sidebar select { margin-bottom: 18px; }
.module-nav { display: flex; flex-direction: column; gap: 4px; }
.module-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.module-link:hover { background: var(--panel-2); }
.module-link.active { background: var(--accent-soft); }
.module-text strong { display: block; }
.module-text small { color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.missing { background: var(--warn); }
.dot.down { background: var(--danger); }

.content { padding: 28px 32px 64px; max-width: 980px; width: 100%; }
.module-header p { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.form h2 + .grid, .form h2 + .field { margin-top: 4px; }
.form h2:not(:first-child) { margin-top: 22px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { margin-bottom: 12px; }
.field-label { display: block; font-weight: 800; font-size: 13px; margin-bottom: 6px; }
input:not([type="checkbox"]):not([type="color"]), select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); color: var(--ink); font: inherit; }
.toggle { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.colors { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.color { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 700; font-size: 13px; }
.color input { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.notice { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 18px 20px; }
.notice p { margin: 0; }
.notice.error { color: var(--danger); border-color: var(--danger); }
.loading { color: var(--muted); padding: 20px 0; }

.logs { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.log time { color: var(--muted); font-size: 12px; font-weight: 700; }
.log-embed { border-left: 4px solid var(--accent); background: var(--panel-2); border-radius: 8px; padding: 10px 14px; margin-top: 4px; overflow-wrap: anywhere; }
.log-embed p { margin: 4px 0; white-space: pre-wrap; }
.log-embed dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; margin: 8px 0 4px; }
.log-embed dt { font-weight: 800; font-size: 12px; }
.log-embed dd { margin: 0; white-space: pre-wrap; }

.now-playing { display: flex; gap: 20px; align-items: flex-start; }
.artwork { width: 140px; height: 140px; object-fit: cover; border-radius: 14px; flex: none; background: var(--panel-2); }
.artwork.placeholder { display: grid; place-items: center; font-size: 42px; }
.now-text { min-width: 0; }
.now-text h2 { margin-top: 4px; overflow-wrap: anywhere; }
.now-text h2 a { color: var(--ink); text-decoration: none; }
.now-text p { margin: 2px 0; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }
.tracks { list-style: none; margin: 8px 0 0; padding: 0; }
.track { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.track-index { color: var(--muted); font-weight: 800; text-align: right; }
.track-text a { color: var(--ink); font-weight: 700; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-text small { color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 700; box-shadow: var(--shadow); max-width: calc(100vw - 32px); z-index: 5; }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .user span, .user { font-size: 13px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .module-nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .module-link { flex: none; padding: 8px 12px; }
  .module-text small { display: none; }
  .content { padding: 20px 16px 48px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .now-playing { flex-direction: column; }
  .artwork { width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 200px; }
  .welcome h1 { font-size: 32px; }
}
