:root {
  color-scheme: light;
  --bg: linear-gradient(135deg, #f3e5ff 0%, #ede9ff 100%);
  --panel: linear-gradient(135deg, #faf8ff 0%, #f5f2ff 100%);
  --text: #3d1f5c;
  --muted: #7d5a9f;
  --line: #e8d5ff;
  --accent: #9b6fc4;
  --accent-dark: #7c4eb8;
  --accent-light: #d4a5f5;
  --red: #d84c6b;
  --green: #7fc97e;
  --blue: #6f8ce4;
  --amber: #c99d5a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(156, 111, 196, 0.3);
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

main,
.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.device-card,
aside,
.chart-panel,
.music-section,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(156, 111, 196, 0.08);
}

.device-card {
  padding: 16px;
}

.device-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.status {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
}

.status.online {
  background: #dff4e9;
  color: var(--green);
}

.status.offline {
  background: #f8e0df;
  color: var(--red);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.metric {
  border-left: 3px solid var(--line);
  padding-left: 9px;
}

.metric strong {
  display: block;
  font-size: 19px;
}

.metric span,
.last-seen,
.detail-list dt,
#lastfm-updated {
  color: var(--muted);
  font-size: 12px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  margin-top: 14px;
}

aside,
.chart-panel,
.music-section {
  padding: 16px;
}

.device-tabs {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.device-tabs button {
  background: #f0e8ff;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
}

.device-tabs button.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.charts {
  display: grid;
  gap: 14px;
}

canvas {
  width: 100%;
  max-width: 100%;
}

.music-section {
  margin: 14px 0 36px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
}

.music-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.music-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.music-list li {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.music-list strong,
.music-list span {
  display: block;
}

.music-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: inherit;
  transition: color 0.2s ease;
}

.music-list a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.music-list a.spotify-link::after {
  content: " 🎵";
}

.music-list span {
  color: var(--muted);
  font-size: 13px;
}

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

.login-panel {
  width: min(380px, calc(100% - 32px));
  padding: 22px;
}

.login-panel form,
.login-panel label {
  display: grid;
  gap: 8px;
}

.login-panel form {
  margin-top: 18px;
  gap: 14px;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 10px;
}

.error {
  color: var(--red);
  font-size: 14px;
}

@media (max-width: 860px) {
  .device-grid,
  .detail-layout,
  .music-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 16px;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  canvas {
    height: auto !important;
    min-height: 160px;
  }
}

@media (max-width: 768px) {
  main,
  .topbar {
    width: calc(100% - 16px);
  }

  .topbar {
    padding: 20px 0 16px;
    flex-direction: column;
    gap: 14px;
  }

  .topbar form {
    width: 100%;
  }

  .topbar button {
    width: 100%;
  }

  .device-grid {
    gap: 10px;
  }

  .device-card {
    padding: 12px;
  }

  .metric-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
  }

  aside,
  .chart-panel,
  .music-section {
    padding: 12px;
  }

  .music-grid {
    gap: 12px;
  }

  .music-list li {
    padding-top: 6px;
  }

  h3 {
    margin-bottom: 8px;
  }

  .section-title {
    margin-bottom: 12px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 14px;
  }

  h3 {
    font-size: 13px;
  }

  .metric strong {
    font-size: 16px;
  }

  .device-tabs {
    margin: 10px 0;
  }

  .detail-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .metric-row {
    gap: 6px;
  }

  canvas {
    min-height: 140px;
  }

  button {
    font-size: 14px;
    min-height: 36px;
    padding: 0 12px;
  }
}