:root {
  --bg: #0f1115;
  --bg2: #161920;
  --card: #1b1f27;
  --line: #2a2f3a;
  --text: #f3f4f6;
  --muted: #9aa3b2;
  --accent: #ff7a1a;
  --accent2: #ffb020;
  --live: #2ed47a;
  --push: #ffc233;
  --off: #5b6372;
  --danger: #ff4d6d;
  --talk: #ff3b4e;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% 0%, #1a1d25 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1em; height: 1em; }
[hidden] { display: none !important; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  min-height: 100%;
}
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }

.hero-logo {
  width: 96px; height: 96px; border-radius: 28px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent2), var(--accent));
  color: #fff; font-size: 58px; box-shadow: 0 18px 40px -12px rgba(255, 122, 26, .55);
}
.title { margin: 6px 0 0; font-size: 30px; letter-spacing: .5px; }
.lead { margin: 0; color: var(--muted); max-width: 360px; }

.steps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 10px; width: 100%; max-width: 380px; text-align: left; }
.steps li { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.steps .n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); font-weight: 700; }
.inl { width: 1.15em; height: 1.15em; vertical-align: -3px; color: #3ba7ff; }
.codebox { background: var(--card); border: 1px dashed var(--accent); border-radius: 14px; padding: 12px 18px; display: grid; gap: 4px; }
.codebox b { font-size: 30px; letter-spacing: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.codebox small { color: var(--muted); }

.form { display: grid; gap: 12px; width: 100%; max-width: 360px; text-align: left; margin-top: 6px; }
.form label, .field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form input, .field input:not([type=range]) {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px;
  font-size: 17px; color: var(--text); outline: none;
}
.form input:focus, .field input:focus { border-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px !important; }
.err { color: var(--danger); margin: 0; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600; font-size: 16px;
}
.btn svg { font-size: 20px; }
.btn.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #1a0d00; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; font-size: 14px; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 42px; height: 42px; display: grid; place-items: center; font-size: 20px; }

/* --- header */
.top { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 1px; font-size: 18px; }
.brand svg { font-size: 26px; color: var(--accent); }
.conn { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.conn i { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.conn.ok i { background: var(--live); box-shadow: 0 0 0 4px rgba(46, 212, 122, .15); }
.conn.bad i { background: var(--danger); }

/* --- banners */
#banners { display: grid; gap: 8px; margin-bottom: 10px; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.banner.warn { border-left-color: var(--danger); }
.banner p { margin: 0; flex: 1; }
.banner button { flex: none; background: var(--accent); color: #1a0d00; border: 0; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 14px; }

/* --- targets */
.targets { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.targets::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 14px 9px 10px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line); font-weight: 600; font-size: 15px; white-space: nowrap;
}
.chip .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #111; position: relative; }
.chip .av::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--card); background: var(--off); }
.chip[data-state="live"] .av::after { background: var(--live); }
.chip[data-state="push"] .av::after { background: var(--push); }
.chip[data-state="none"] .av::after { display: none; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 122, 26, .14); }
.chip.all .av { background: linear-gradient(145deg, var(--accent2), var(--accent)); }
.chip.all .av svg { font-size: 16px; color: #1a0d00; }

/* --- stage */
.stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 6px; }
.ptt {
  position: relative; width: min(64vw, 240px); aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0;
  background: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  margin: 8px 0 2px;
}
.ptt .halo { position: absolute; inset: -14px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 122, 26, .28), transparent 70%); transition: transform .08s linear; }
.ptt .face {
  position: absolute; inset: 0; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(circle at 35% 30%, #ffc04d, var(--accent) 55%, #e2560a);
  color: #1a0d00; box-shadow: 0 24px 50px -16px rgba(255, 122, 26, .7), inset 0 -8px 18px rgba(0, 0, 0, .18), inset 0 6px 12px rgba(255, 255, 255, .25);
  transition: transform .12s ease, background .2s;
}
.ptt .face svg { font-size: 54px; }
.ptt .face b { font-size: 20px; letter-spacing: 1px; }
.ptt .face small { font-size: 14px; font-weight: 600; opacity: .8; max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptt.opening .face { transform: scale(.95); }
.ptt.talking .face { transform: scale(.95); background: radial-gradient(circle at 35% 30%, #ff7a86, var(--talk) 55%, #c4122a); color: #fff; }
.ptt.talking .halo { background: radial-gradient(circle, rgba(255, 59, 78, .45), transparent 70%); }
.ptt.talking::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(255, 59, 78, .55); animation: pulse 1.2s ease-out infinite; }
.ptt:disabled .face { filter: grayscale(.8) brightness(.7); }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.hint { margin: 0; color: var(--muted); font-size: 14px; min-height: 20px; text-align: center; }

.incoming {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, rgba(46, 212, 122, .18), rgba(46, 212, 122, .05)); border: 1px solid rgba(46, 212, 122, .45);
  border-radius: var(--radius); padding: 14px 16px;
}
.incoming .who { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.incoming .who span { color: var(--muted); font-size: 15px; }
.incoming .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--live); }
.bars { display: flex; align-items: center; gap: 4px; height: 30px; }
.bars i { width: 5px; border-radius: 3px; background: var(--live); height: 30%; animation: bar .9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -.15s; }
.bars i:nth-child(3) { animation-delay: -.45s; }
.bars i:nth-child(4) { animation-delay: -.3s; }
.bars i:nth-child(5) { animation-delay: -.6s; }
.bars i:nth-child(6) { animation-delay: -.75s; }
.bars i:nth-child(7) { animation-delay: -.2s; }
@keyframes bar { 0%, 100% { height: 25%; } 50% { height: 100%; } }

.video-box { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.video-box video, .video-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-box.self { aspect-ratio: 16 / 10; }
.video-box.self video { object-fit: cover; }
.vlabel { position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .55); padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.vlabel.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--talk); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.vbtn { position: absolute; top: 8px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; font-size: 18px; }
.vbtn.close { right: 8px; }
.vbtn.flip { right: 54px; }
.vwait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.video-box.has-video .vwait { display: none; }

/* --- replies */
.replies { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 6px 0 4px; }
.replies p { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.replies .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.replies button { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; font-weight: 600; font-size: 15px; }
.replies button:active { background: rgba(255, 122, 26, .2); }

.tools { display: flex; justify-content: center; margin: 8px 0 14px; }
.tools .btn.on { border-color: var(--talk); color: #ffb3bb; }

/* --- history */
.history { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 6px; }
.h-head { display: flex; align-items: center; justify-content: space-between; }
.history h2 { font-size: 15px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
#history { list-style: none; margin: 0; padding: 0; }
#history li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); }
#history li:first-child { border-top: 0; }
#history .av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #111; }
#history .meta { flex: 1; min-width: 0; }
#history .meta b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#history .meta small { color: var(--muted); font-size: 13px; }
#history .tick { color: var(--live); }
#history li.unheard .meta b::after { content: " • yeni"; color: var(--accent); font-size: 13px; }
#history .play { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg2); display: grid; place-items: center; font-size: 18px; color: var(--accent); }
#history .play.playing { color: var(--live); }
.empty { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 10px; }

/* --- settings sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg2); border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(20px + var(--safe-b)); border: 1px solid var(--line); border-bottom: 0;
}
.sheet-card header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -14px; background: var(--bg2); padding: 4px 0 8px; z-index: 1; }
.sheet-card h2 { margin: 0; font-size: 20px; }
.group { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 10px; }
.group h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.group .btn { justify-self: start; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }
.small { font-size: 12px; }
.toggle { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 1px 0 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatches button[aria-pressed="true"] { border-color: #fff; }
.status { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.status li { display: flex; align-items: center; gap: 10px; font-size: 14px; background: var(--card); border-radius: 12px; padding: 10px 12px; }
.status li span { flex: 1; }
.status li button { background: var(--accent); color: #1a0d00; border: 0; border-radius: 9px; padding: 6px 10px; font-weight: 700; font-size: 13px; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.members li { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 8px 10px; font-size: 15px; }
.members .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #111; font-size: 13px; flex: none; }
.members .nm { flex: 1; min-width: 0; }
.members .nm small { display: block; color: var(--muted); font-size: 12px; }
.members button { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; font-size: 13px; color: var(--muted); }
.invite { background: var(--card); border: 1px dashed var(--accent); border-radius: 14px; padding: 12px; display: grid; gap: 8px; justify-items: start; }
.invite p { margin: 0; font-size: 14px; color: var(--muted); }
.invite .code { font-size: 32px; letter-spacing: 5px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.danger .link { color: var(--danger); justify-self: start; padding-left: 0; }

/* --- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  background: #f3f4f6; color: #111; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45); max-width: calc(100% - 32px); text-align: center;
}
.toast.big { font-size: 20px; padding: 16px 22px; background: var(--live); color: #04220f; }

@media (min-width: 700px) {
  .screen:not(.center) { padding-top: 28px; }
}
