:root {
  font-family: system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: #111;
  color: #f4f4f4;
  line-height: 1.45;
}

main {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

header, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.app-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #2f2f2f;
  padding-bottom: 18px;
}

.brand { min-width: 0; }

.connection-summary {
  margin-top: 3px;
  color: #aaa;
  font-size: 0.9rem;
}

.auth-view {
  width: min(460px, 100%);
  margin: 16vh auto 0;
  text-align: center;
}

.auth-panel {
  border: 1px solid #3d3d3d;
  border-radius: 16px;
  background: #191919;
  padding: 28px;
}

.auth-panel p:not(.eyebrow) {
  margin: 14px 0 22px;
  color: #d1d1d1;
}

.login-button {
  display: inline-block;
  border: 1px solid #6f79d8;
  border-radius: 10px;
  background: #5865f2;
  color: #fff;
  padding: 12px 18px;
  font-weight: 700;
  text-decoration: none;
}

.login-button:hover { background: #6875f5; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid #3d3d3d;
  border-radius: 11px;
  background: #191919;
  padding: 7px;
}

#user-avatar,
.avatar-fallback {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
}

#user-avatar { object-fit: cover; }

.avatar-fallback {
  display: grid;
  place-items: center;
  background: #5865f2;
  font-weight: 800;
}

.user-details {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.user-details strong {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-badge {
  border-radius: 5px;
  background: #705520;
  color: #ffe6aa;
  padding: 2px 5px;
  font-size: 0.68rem;
  font-weight: 800;
}

.compact-button {
  padding: 7px 9px;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 1.5rem;
}

p { margin: 6px 0; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #aaa;
}

.voice-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: start;
  gap: 12px 20px;
  margin-bottom: 20px;
  border: 1px solid #3d435e;
  border-radius: 12px;
  background: #191b24;
  padding: 14px 16px;
}

.voice-details .eyebrow { margin-bottom: 8px; }
.voice-details strong { color: #dfbd79; }

.voice-state {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 2px solid #888;
  border-radius: 50%;
}

.status-dot.is-connected {
  border-color: #78b787;
  background: #78b787;
}

.voice-channel {
  color: #b8b8b8;
  font-size: 0.9rem;
}

.voice-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: start;
  gap: 8px;
}

.voice-actions button { padding: 9px 12px; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button:disabled:hover { background: #222; }

.voice-message {
  grid-column: 1 / -1;
  min-height: 1.2em;
  margin: 0;
  color: #d7c18f;
  font-size: 0.88rem;
}

.voice-message:empty,
.status-message:empty { display: none; }

.now-playing {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.now-playing p {
  min-width: 0;
  margin: 0;
  border: 1px solid #363636;
  border-radius: 10px;
  background: #191919;
  padding: 12px 16px;
}

.now-playing p {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.now-playing span {
  flex: 0 0 auto;
  color: #aaa;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.now-playing strong {
  min-width: 0;
  color: #dfbd79;
}

.now-playing p { overflow-wrap: anywhere; }

.status-message {
  min-height: 1.4em;
  margin: -8px 2px 18px;
  color: #bdbdbd;
  font-size: 0.9rem;
}

.player-section {
  margin-top: 24px;
  border: 1px solid #333;
  border-radius: 16px;
  background: #171717;
  padding: 20px;
}

.ambience-section { border-color: #55492d; }
.section-heading {
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.section-controls {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(100px, 220px) 48px;
  align-items: center;
  gap: 12px;
  margin: 0;
}

.volume-control input {
  width: 100%;
  accent-color: #b98f44;
}

.volume-control output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.category-button {
  min-height: 92px;
  padding: 18px;
  border-color: #55492d;
  background: #29251d;
  font-size: 1.15rem;
  font-weight: 750;
  text-align: left;
  overflow-wrap: anywhere;
}

.category-button:hover { background: #393225; }

.category-view-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.category-title {
  margin: 0;
  font-size: 1.35rem;
}

.back-button {
  border-color: #62583f;
  background: #29251d;
  font-weight: 700;
}

.sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

button {
  border: 1px solid #444;
  border-radius: 10px;
  background: #222;
  color: inherit;
  padding: 12px 16px;
  font: inherit;
  cursor: pointer;
}

button:hover { background: #333; }

button:focus-visible,
.login-button:focus-visible,
input:focus-visible {
  outline: 3px solid #d2a955;
  outline-offset: 2px;
}

.sound-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #3d3d3d;
  border-radius: 11px;
  background: #1d1d1d;
}

.sound-card.is-active {
  border-color: #756039;
  background: #29251d;
  box-shadow: 0 0 0 1px #756039;
}

.sound-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid #383838;
  font-weight: 650;
  text-align: left;
  overflow-wrap: anywhere;
}

.sound-label {
  min-width: 0;
}

.playing-indicator {
  flex: 0 0 auto;
  color: #f0ce88;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.playing-indicator[hidden] { display: none; }

.sound-card.is-active .sound-main { background: #342c1f; }
.sound-card.is-active .sound-main:hover { background: #403624; }

.sound-settings {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 8px;
}

.sound-settings.player-settings {
  display: flex;
  justify-content: flex-end;
}

.sound-settings button {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 0.88rem;
}

.sound-volume-button { text-align: left; }

.loop-toggle.is-enabled {
  border-color: #8e713a;
  background: #514324;
  color: #fff2cf;
  font-weight: 750;
}

.individual-volume {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 1px;
}

.individual-volume[hidden] { display: none; }

.individual-volume input {
  width: 100%;
  min-width: 0;
  accent-color: #b98f44;
}

.individual-volume output {
  text-align: right;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.stop-button {
  min-width: 100px;
  background: #4a1717;
}

.stop-button:hover { background: #652020; }
.secondary-stop { min-width: auto; }

.empty {
  border: 1px dashed #555;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  opacity: 0.75;
}

.sound-grid > .empty { grid-column: 1 / -1; }

@media (max-width: 600px) {
  main {
    width: min(100% - 20px, 1100px);
    padding-top: 20px;
  }

  .sound-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .now-playing { grid-template-columns: 1fr; }
  .voice-controls { grid-template-columns: 1fr; }
  .voice-actions { justify-content: flex-start; }
  .app-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .user-chip { flex: 1 1 100%; }
  .user-details { flex: 1; }
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
  }

  .volume-control { grid-template-columns: 1fr 48px; }
  .volume-control span { grid-column: 1 / -1; }
  .section-controls {
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
  }
  .section-controls .volume-control { flex: 1 1 240px; }
  .section-actions { justify-content: flex-start; }
}

@media (max-width: 380px) {
  main { width: calc(100% - 16px); }
  .category-grid { grid-template-columns: 1fr; }
  .player-section { padding: 14px; }
  .user-chip { width: 100%; }
  .voice-actions button,
  .section-actions button { flex: 1 1 auto; }
}
