:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #232733;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --speak: #3ba55d;
  --danger: #ed4245;
  --idle: #faa61a;
  --ring: #2b2f3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sakura { position: fixed; inset: 0; z-index: 0; pointer-events: none; display: block; }

.wrap { position: relative; z-index: 1; width: 100%; max-width: 460px; padding: 24px; }

.card {
  background: var(--card);
  border: 1px solid #262a34;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.logo {
  margin: 0;
  font-size: 30px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(90deg, #7d8cff, #b18cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo.small { font-size: 20px; }
.tag { color: var(--muted); margin: 8px 0 22px; font-size: 14px; }

input[type="text"], textarea {
  width: 100%; padding: 13px 14px; border-radius: 10px;
  border: 1px solid #333846; background: var(--card-2); color: var(--text);
  font-size: 15px; font-family: inherit;
}
input[type="text"] { margin-bottom: 14px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

button {
  padding: 12px 16px; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--card-2);
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: #2c313d; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }
.primary { width: 100%; background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.ghost { background: transparent; border: 1px solid #3a3f4b; }
#mute.on { background: var(--danger); }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.room-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
#status { font-size: 13px; color: var(--muted); }
#status.ok { color: var(--speak); }
#status.bad { color: var(--danger); }
.head-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; padding: 0; font-size: 17px; background: var(--card-2); border-radius: 10px; }

/* ---- peers ---- */
.peers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; min-height: 60px; }
.peer {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 0;
  background: var(--card-2); border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s; cursor: pointer;
}
.peer.speaking { border-color: var(--speak); box-shadow: 0 0 0 1px var(--speak), 0 0 16px rgba(59,165,93,0.35); }
.peer.has-banner .pname { text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
.peer.has-banner .you { background: rgba(0,0,0,0.4); color: #dfe2ea; }

.avatar {
  position: relative; width: 36px; height: 36px; border-radius: 50%;
  flex: none; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; overflow: visible;
  background-size: cover; background-position: center;
}
.avatar .initial { pointer-events: none; }
.avatar .status-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--card-2); background: var(--muted);
}
.status-dot.online { background: var(--speak); }
.status-dot.idle { background: var(--idle); }
.status-dot.dnd { background: var(--danger); }

.pname { font-size: 15px; font-weight: 500; }
.you { margin-left: 8px; font-size: 11px; color: var(--muted); background: #2b2f3a; padding: 2px 8px; border-radius: 20px; }

.meter { margin-left: auto; width: 84px; height: 6px; background: #33384a; border-radius: 3px; overflow: hidden; flex: none; }
.meter-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--speak), #7bd88f); border-radius: 3px; }

.controls { display: flex; gap: 10px; align-items: center; }
.controls #leave { flex: 1; }
.mic-btn { width: 46px; height: 46px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card-2); color: var(--text); flex: none; }
.mic-btn:hover { background: #2c313d; }
.mic-btn.on { background: var(--danger); color: #fff; }
.mic-btn.on:hover { background: #c93b3e; }
.mic-btn .ic-off { display: none; }
.mic-btn.on .ic-on { display: none; }
.mic-btn.on .ic-off { display: block; }

.mic-state { font-size: 11px; padding: 2px 7px; border-radius: 20px; font-weight: 600; flex: none; }
.mic-state.on { color: var(--speak); background: rgba(59,165,93,0.16); }
.mic-state.off { color: var(--danger); background: rgba(237,66,69,0.18); }
.peer.has-banner .mic-state { text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; text-align: center; }
#ptt-hint { color: var(--idle); }

/* ---- modals ---- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  background: var(--card); border: 1px solid #2c313d; border-radius: 14px;
  padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 12px; position: relative;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { width: 30px; height: 30px; padding: 0; border-radius: 8px; background: var(--card-2); color: var(--muted); }
.modal-x:hover { background: #33384a; color: var(--text); }
.modal-x.floating { position: absolute; top: 12px; right: 12px; z-index: 2; }

.set-row { display: flex; align-items: center; gap: 12px; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.set-row label { font-size: 13px; color: var(--muted); flex: none; width: 160px; }
.set-row.col label { width: auto; }
.set-row select { flex: 1; min-width: 0; padding: 7px 8px; border-radius: 8px; background: var(--card-2); color: var(--text); border: 1px solid #333846; font-size: 13px; }
.set-row input[type="range"] { flex: 1; }
.set-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.set-row input[type="color"] { width: 40px; height: 32px; padding: 0; border: 1px solid #333846; border-radius: 8px; background: var(--card-2); cursor: pointer; }
.set-row input[type="file"] { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
input[type="range"] { accent-color: var(--accent); cursor: pointer; }

/* profile editor / card banner + avatar */
.pe-banner, .pc-banner {
  position: relative; height: 96px; border-radius: 10px;
  background: linear-gradient(135deg, #3a4160, #2a2f45);
  background-size: cover; background-position: center; margin-bottom: 26px;
}
.pc-banner { border-radius: 12px 12px 0 0; margin: -20px -20px 26px; }
.pe-avatar, .pc-avatar {
  position: absolute; left: 18px; bottom: -22px;
  width: 64px; height: 64px; border-radius: 50%;
  border: 4px solid var(--card); background: var(--accent) center/cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; color: #fff;
}
.pc-body { display: flex; flex-direction: column; gap: 6px; }
.pc-name { font-size: 20px; font-weight: 700; }
.pc-status { font-size: 13px; color: var(--muted); }
.pc-about { font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* volume popup */
.vol-popup {
  position: fixed; z-index: 50; width: 190px;
  background: var(--card); border: 1px solid #3a3f4b; border-radius: 10px;
  padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 10px;
}
.vol-popup[hidden] { display: none; }
.vol-popup-head { display: flex; align-items: center; gap: 10px; }
.vol-popup-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vol-popup-close { flex: none; width: 26px; height: 26px; padding: 0; border-radius: 6px; background: var(--card-2); color: var(--muted); font-size: 13px; line-height: 1; }
.vol-popup-close:hover { background: #33384a; color: var(--text); }
.vol-popup input[type="range"] { width: 100%; }
.vol-popup > button { width: 100%; padding: 8px; font-size: 13px; }
