:root {
  color-scheme: dark;
  --desktop: #050806;
  --window: #1b2420;
  --window-light: #4f6257;
  --window-dark: #050806;
  --ink: #c7d3cc;
  --screen: #050a07;
  --screen-2: #0b120e;
  --green: #8eab95;
  --green-muted: #6f8976;
  --blue: #a6bba9;
  --yellow: #aab58a;
  --magenta: #91a98f;
  --red: #b26d6d;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: var(--desktop);
  color: var(--green);
  font-family: "Courier New", Courier, monospace;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  border: 0;
  box-shadow: inset 0 0 90px #000;
  content: "";
  pointer-events: none;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.6rem;
  background: #fff;
  color: #000;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.desktop {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.chat-window {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  border: 1px solid var(--window-light);
  border-right-color: var(--window-dark);
  border-bottom-color: var(--window-dark);
  background: var(--window);
  box-shadow: none;
}

.title-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.3rem 0.35rem;
  border-bottom: 1px solid #5c7264;
  background: #173224;
  color: #cfddd2;
}

.title-bar h1 {
  flex: 1;
  margin: 0;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.window-icon,
.window-controls span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid var(--window-light);
  border-right-color: var(--window-dark);
  border-bottom-color: var(--window-dark);
  background: #25312b;
  color: var(--ink);
  font: bold 0.85rem Arial, Helvetica, sans-serif;
}

.window-icon {
  background: #31463a;
  color: #b8c9bd;
}

.window-controls {
  display: flex;
  gap: 0.2rem;
}

.menu-bar,
.channel-bar,
.status-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.menu-bar {
  min-height: 34px;
  padding: 0 0.6rem;
  border-bottom: 2px solid var(--window-dark);
  background: #202a25;
  font-size: 0.9rem;
}

.connection {
  margin-left: auto;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
}

.connection i,
.presence i,
.users-panel li i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.35rem;
  border: 1px solid #395e45;
  background: #71977a;
  box-shadow: 0 0 5px #55745e;
}

.channel-bar {
  min-height: 38px;
  padding: 0 0.7rem;
  border-top: 2px solid var(--window-light);
  border-bottom: 2px solid var(--window-dark);
  background: #18231d;
  font-size: 0.9rem;
}

.channel-bar span {
  overflow: hidden;
  color: #84988b;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 190px;
  min-height: 0;
  flex: 1;
  border-top: 2px solid var(--window-light);
}

.profile-panel,
.users-panel {
  background: #121815;
  color: #aebdb4;
}

.profile-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  border-right: 3px ridge var(--window);
  scrollbar-color: #4f6257 #121815;
}

.avatar-frame {
  aspect-ratio: 1;
  width: 100%;
  padding: 5px;
  border: 2px solid var(--window-dark);
  border-right-color: var(--window-light);
  border-bottom-color: var(--window-light);
  background: #050705;
}

.avatar-frame img,
.avatar-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px dashed var(--green-muted);
  color: var(--green-muted);
}

.avatar-placeholder span {
  font-size: 2rem;
  font-weight: 700;
}

.avatar-placeholder small {
  margin-top: 0.35rem;
}

.profile-copy {
  padding-bottom: 1rem;
  border-bottom: 1px dotted #66717c;
}

.handle {
  margin: 1rem 0 0.25rem;
  color: var(--magenta);
  font-weight: 700;
}

.presence {
  margin: 0 0 1rem;
  color: #95b39b;
  font-size: 0.85rem;
}

dl,
dd {
  margin: 0;
}

dl div {
  margin-top: 0.8rem;
}

dt {
  color: #71877a;
  font-size: 0.72rem;
  text-transform: uppercase;
}

dd {
  margin-top: 0.2rem;
  color: #cbd7cf;
  font-size: 0.85rem;
  line-height: 1.35;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.room-list p,
.panel-heading,
.server-box p {
  margin: 0 0 0.4rem;
  color: #71877a;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.room-list a,
.room-list span {
  padding: 0.25rem;
  text-decoration: none;
}

.room-list .active {
  background: #26382f;
  color: #d3dfd6;
}

.room-list small {
  color: #697b70;
}

.spotify-widget {
  margin-top: auto;
  padding-top: 1.25rem;
}

.spotify-title-row,
.spotify-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.spotify-label {
  margin: 0;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.spotify-day {
  padding: 0.12rem 0.28rem;
  border: 1px solid #405348;
  color: #8fa393;
  font-size: 0.62rem;
}

.spotify-loading,
.spotify-error {
  min-height: 58px;
  margin-top: 0.45rem;
  padding: 0.65rem;
  border: 1px solid #405348;
  background: #050805;
  color: #819888;
  font-size: 0.7rem;
  line-height: 1.5;
}

.spotify-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.spotify-loading[hidden],
.spotify-error[hidden] {
  display: none;
}

.spotify-led {
  width: 7px;
  height: 7px;
  border: 1px solid #405c48;
  background: #708d75;
  box-shadow: 0 0 5px #526a58;
  animation: receiver-blink 1.2s steps(2, end) infinite;
}

.spotify-error span,
.spotify-error small {
  display: block;
}

.spotify-error span {
  color: var(--red);
  font-weight: 700;
}

.spotify-error small {
  margin-top: 0.35rem;
  color: #75887a;
}

.spotify-footer {
  margin-top: 0.4rem;
  color: #667b6d;
  font-size: 0.68rem;
}

.spotify-footer b {
  color: #9caf9f;
}

.spotify-link {
  color: #819888;
  font-size: 0.72rem;
  text-decoration: none;
}

.spotify-link:hover,
.spotify-link:focus-visible {
  color: #b8c9bd;
  text-decoration: underline;
}

@keyframes receiver-blink {
  50% {
    opacity: 0.35;
  }
}

.chat-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: var(--screen);
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem;
  scrollbar-color: #617063 #101611;
}

.system-message {
  margin: 0 0 0.6rem;
  color: var(--green-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.system-message strong {
  color: var(--yellow);
}

.message {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 0.55rem;
  margin: 1.35rem 0;
  color: #bdd0c2;
  line-height: 1.72;
}

.message time {
  color: #718b77;
}

.username {
  color: var(--magenta);
}

.message h2 {
  margin: 0 0 0.6rem;
  color: var(--blue);
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.1;
}

.message p {
  margin: 0;
  max-width: 68ch;
}

.command-hint {
  margin-top: 1.5rem;
  color: var(--yellow);
}

kbd {
  padding: 0.1rem 0.3rem;
  border: 1px solid #768a7a;
  background: #101b13;
  color: #fff;
  font: inherit;
}

.command-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.45rem 0.6rem;
  border-top: 1px solid #34483b;
  background: #0c120e;
}

.command-line label {
  color: var(--green);
  font-size: 0.86rem;
  white-space: nowrap;
}

.command-line input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: #d3dfd6;
  font: inherit;
  caret-color: var(--green);
}

.command-line input:focus {
  box-shadow: inset 0 -1px var(--green);
}

.command-line button {
  min-height: 30px;
  border: 2px solid var(--window-light);
  border-right-color: var(--window-dark);
  border-bottom-color: var(--window-dark);
  background: var(--window);
  color: var(--ink);
  font: bold 0.75rem Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.command-line button:active {
  border-color: var(--window-dark) var(--window-light) var(--window-light)
    var(--window-dark);
}

.users-panel {
  padding: 1rem 0.8rem;
  border-left: 3px ridge var(--window);
}

.users-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.users-panel li {
  margin: 0.65rem 0;
  font-size: 0.86rem;
}

.users-panel li .admin-dot {
  border-color: #4b634f;
  background: #9aad8e;
  box-shadow: 0 0 5px #65765f;
}

.server-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 2rem;
  padding: 0.7rem;
  border: 1px dotted #506259;
  color: #9aa9a0;
  font-size: 0.72rem;
  line-height: 1.35;
}

.server-box strong {
  color: var(--green);
}

.status-bar {
  min-height: 34px;
  justify-content: space-between;
  padding: 0.35rem 0.55rem;
  border-top: 3px ridge var(--window);
  background: #19221d;
  font-size: 0.75rem;
}

.status-bar span {
  padding: 0.2rem 0.45rem;
  border: 2px solid var(--window-dark);
  border-right-color: var(--window-light);
  border-bottom-color: var(--window-light);
}

.copyright {
  display: none;
}

.terminal-response {
  margin: 0.65rem 0;
  color: var(--blue);
  line-height: 1.55;
}

.terminal-response .prompt {
  color: #718b77;
}

.terminal-response.error {
  color: var(--red);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .desktop {
    width: 100%;
    padding: 0;
  }

  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .users-panel {
    display: none;
  }

  .status-bar span:last-child {
    display: none;
  }
}

@media (max-width: 580px) {
  body::before {
    border-width: 0;
  }

  .desktop {
    width: 100%;
    padding: 0;
  }

  .chat-window {
    border: 0;
  }

  .window-controls span:not(:last-child),
  .menu-bar span:not(.connection),
  .channel-bar span,
  .status-bar span:nth-child(2) {
    display: none;
  }

  .workspace {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .profile-panel {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 0.8rem;
    overflow: visible;
    padding: 0.7rem;
    border-right: 0;
    border-bottom: 3px ridge var(--window);
  }

  .profile-copy {
    padding: 0;
    border: 0;
  }

  .handle {
    margin-top: 0;
  }

  .profile-copy dl,
  .room-list {
    display: none;
  }

  .spotify-widget {
    grid-column: 1 / -1;
    margin-top: 0;
    padding-top: 0.25rem;
  }

  .chat-log {
    min-height: 430px;
    padding: 0.85rem;
  }

  .message {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.35rem;
  }

  .message time {
    display: none;
  }

  .message > div,
  .message > p {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
  }

  .command-line {
    align-items: stretch;
  }

  .command-line label {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .connection i,
  .presence i {
    animation: status-pulse 2.2s steps(2, end) infinite;
  }
}

@keyframes status-pulse {
  50% {
    opacity: 0.45;
  }
}

/* Keep the desktop chat window locked to the visible browser area. */
@media (min-width: 581px) {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
  }

  .desktop,
  .chat-window {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .workspace {
    min-height: 0;
    overflow: hidden;
  }

  .profile-panel,
  .chat-panel,
  .users-panel {
    min-height: 0;
  }
}

/* Keep panel scrolling available without showing scrollbar tracks. */
.profile-panel,
.chat-log {
  scrollbar-width: none;
}

.profile-panel::-webkit-scrollbar,
.chat-log::-webkit-scrollbar {
  display: none;
}

/* Compact daily-track card. */
.spotify-widget {
  flex: 0 0 auto;
  overflow: hidden;
}

.spotify-track-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  min-height: 54px;
  margin-top: 0.45rem;
  padding: 0.45rem;
  border: 1px solid #465b4c;
  background: #0a100c;
  color: #bdcec1;
  text-decoration: none;
}

.spotify-track-card[hidden] {
  display: none;
}

.spotify-track-card:hover,
.spotify-track-card:focus-visible {
  border-color: #718b77;
  background: #101a13;
  outline: 1px dotted #8eab95;
  outline-offset: -4px;
}

.spotify-play-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #5f7867;
  background: #17241b;
  color: #a9bead;
  font-size: 0.72rem;
}

.spotify-track-copy {
  min-width: 0;
}

.spotify-track-copy strong,
.spotify-track-copy small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.spotify-track-copy strong {
  color: #c9d6cc;
  font-size: 0.75rem;
}

.spotify-track-copy small {
  margin-top: 0.18rem;
  color: #758b7c;
  font-size: 0.64rem;
}

.spotify-open {
  color: #8da393;
  font-size: 0.62rem;
  white-space: nowrap;
}
