:root {
  color-scheme: dark;
  --bg: #050b0f;
  --panel: #0a141a;
  --panel-raised: #0f1c23;
  --line: #1d303a;
  --line-strong: #2b4653;
  --text: #edf7f7;
  --muted: #88a0a9;
  --cyan: #35e1d0;
  --cyan-soft: rgba(53, 225, 208, 0.12);
  --amber: #f7b955;
  --danger: #ff6c74;
  --success: #56dda0;
  --radius: 18px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 48% -20%, rgba(39, 119, 125, 0.24), transparent 42%),
    linear-gradient(180deg, #071015 0%, var(--bg) 70%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1520px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 34px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--cyan);
  border-radius: 12px;
  color: var(--cyan);
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: inset 0 0 18px rgba(53, 225, 208, 0.12);
}
.brand h1 { margin: 0; font-size: 1.08rem; letter-spacing: 0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 0.78rem; }

.system-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 0.86rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px currentColor; }
.status-dot.ok { color: var(--success); background: var(--success); }
.status-dot.error { color: var(--danger); background: var(--danger); }

.workspace { display: grid; grid-template-columns: 292px minmax(430px, 1fr) 320px; gap: 16px; align-items: stretch; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(10, 20, 26, 0.92); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2); }
.sidebar, .activity { padding: 22px; }
.console { min-height: 730px; padding: 22px; display: flex; flex-direction: column; }

.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.05rem; }
.eyebrow { color: var(--cyan); font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.69rem; letter-spacing: 0.17em; }

.icon-button { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: var(--panel-raised); font-size: 1.25rem; }
.field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 0.78rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #071116;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
input:disabled { color: #587079; background: #091015; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.switch-row span { display: grid; gap: 4px; }
.switch-row strong { font-size: 0.86rem; }
.switch-row small { color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.switch-row input { width: 38px; min-height: auto; accent-color: var(--cyan); }

.button { min-height: 43px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; color: #061111; background: var(--cyan); font-weight: 750; }
.button:hover { filter: brightness(1.08); }
.button:disabled { cursor: not-allowed; opacity: 0.42; }
.button.secondary { border-color: var(--line-strong); color: var(--text); background: var(--panel-raised); }
.button.danger { border-color: rgba(255, 108, 116, 0.35); color: var(--danger); background: rgba(255, 108, 116, 0.1); }
.button.success { color: #04130d; background: var(--success); }
.button.compact { min-height: 36px; padding: 0 13px; font-size: 0.8rem; }
.full { width: 100%; }
.text-button { padding: 3px 0; border: 0; color: var(--muted); background: transparent; font-size: 0.78rem; }
.text-button:hover { color: var(--cyan); }
.connection-actions { display: grid; gap: 12px; margin-top: 18px; }
.device-form { display: grid; }
.device-form > .button + .button { margin-top: 9px; }
.device-meta { margin: 10px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.5; }

.radio-display { min-height: 250px; padding: 22px 24px; border: 1px solid var(--line-strong); border-radius: 14px; background: #061015; position: relative; overflow: hidden; }
.radio-display::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.17; background: repeating-linear-gradient(180deg, transparent 0, transparent 3px, rgba(255,255,255,.055) 4px); }
.radio-topline { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.76rem; }
.badge { padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.69rem; font-weight: 700; letter-spacing: 0.08em; }
.badge.online { border-color: rgba(86, 221, 160, 0.35); color: var(--success); background: rgba(86, 221, 160, 0.08); }
.badge.offline { color: var(--muted); }
.call-readout { margin-top: 42px; text-align: center; }
.call-readout h2 { margin: 9px 0 7px; font-size: clamp(1.65rem, 4vw, 2.6rem); letter-spacing: -0.045em; }
.call-readout p { margin: 0; color: var(--muted); }

.waveform { height: 42px; margin: 27px auto 0; display: flex; align-items: center; justify-content: center; gap: 5px; }
.waveform i { display: block; width: 3px; height: 7px; border-radius: 2px; background: var(--cyan); transition: height 180ms ease; }
.waveform.active i { animation: pulse 850ms ease-in-out infinite alternate; }
.waveform.active i:nth-child(3n) { animation-delay: -300ms; }
.waveform.active i:nth-child(2n) { animation-delay: -600ms; }
@keyframes pulse { from { height: 5px; opacity: .45; } to { height: 35px; opacity: 1; } }

.incoming-card { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 15px 16px; border: 1px solid rgba(247,185,85,.35); border-radius: 12px; background: rgba(247,185,85,.08); }
.incoming-label { color: var(--amber); font-size: .72rem; }
.incoming-card strong { font-size: 1rem; }
.incoming-card > span:nth-of-type(2) { color: var(--muted); font-size: .78rem; }
.incoming-actions { display: flex; gap: 8px; margin-left: auto; }

.dial-area { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.target-field { margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(15,28,35,.55); }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.command-block { position: relative; }
.hold-button { width: 100%; min-height: 101px; display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-align: left; background: rgba(15,28,35,.55); user-select: none; touch-action: none; }
.hold-button:active, .hold-button.recording { border-color: var(--amber); background: rgba(247,185,85,.1); }
.hold-button span:last-child { display: grid; gap: 5px; }
.hold-button small { color: var(--muted); }
.hold-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; color: var(--cyan); background: var(--cyan-soft); font-size: 1.35rem; }
.candidate { position: absolute; z-index: 4; inset: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; border: 1px solid var(--cyan); border-radius: 12px; background: #0b1b21; box-shadow: 0 12px 36px rgba(0,0,0,.35); }
.candidate > div:first-child { display: grid; gap: 4px; }
.candidate span { max-width: 190px; overflow: hidden; color: var(--muted); font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.candidate-actions { display: flex; align-items: center; gap: 10px; }

.talk-area { flex: 1; display: grid; place-items: center; align-content: center; gap: 24px; padding-top: 20px; }
.ptt-button { width: 190px; height: 190px; display: grid; justify-items: center; align-content: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--text); background: radial-gradient(circle, #13262e 0, #091319 67%); box-shadow: 0 18px 60px rgba(0,0,0,.38), inset 0 0 0 9px rgba(255,255,255,.015); user-select: none; touch-action: none; }
.ptt-button:disabled { cursor: not-allowed; opacity: .35; }
.ptt-button.ready:not(:disabled):hover { border-color: var(--cyan); box-shadow: 0 18px 60px rgba(0,0,0,.38), 0 0 36px rgba(53,225,208,.12); }
.ptt-button.recording { border-color: var(--amber); background: radial-gradient(circle, rgba(247,185,85,.25), #101718 67%); transform: scale(.98); }
.ptt-button strong { font-size: 1.05rem; }
.ptt-button small { color: var(--muted); }
.ptt-ring { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 5px; border: 1px solid var(--cyan); border-radius: 50%; }
.ptt-core { width: 14px; height: 14px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px rgba(53,225,208,.7); }
.ptt-button.recording .ptt-ring { border-color: var(--amber); }
.ptt-button.recording .ptt-core { background: var(--amber); box-shadow: 0 0 18px rgba(247,185,85,.8); }
.hangup { min-width: 140px; }

.activity { display: flex; min-height: 730px; flex-direction: column; }
.activity-log { flex: 1; min-height: 420px; max-height: 570px; overflow-y: auto; padding-right: 4px; }
.empty-log { margin-top: 42px; color: var(--muted); text-align: center; }
.empty-log span { color: var(--text); font-size: .9rem; }
.empty-log p { margin: 8px auto; max-width: 210px; font-size: .75rem; line-height: 1.55; }
.log-item { margin-bottom: 10px; padding: 12px; border-left: 2px solid var(--line-strong); border-radius: 0 8px 8px 0; background: rgba(15,28,35,.58); }
.log-item.info { border-color: var(--cyan); }
.log-item.warn { border-color: var(--amber); }
.log-item.error { border-color: var(--danger); }
.log-item time { display: block; margin-bottom: 5px; color: #607982; font-family: monospace; font-size: .65rem; }
.log-item p { margin: 0; font-size: .8rem; line-height: 1.5; overflow-wrap: anywhere; }
.service-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding-top: 16px; border-top: 1px solid var(--line); }
.service-grid div { padding: 9px 7px; border-radius: 8px; background: #071116; text-align: center; }
.service-grid span { display: block; margin-bottom: 3px; color: var(--muted); font-size: .65rem; }
.service-grid strong { color: var(--amber); font-size: .7rem; }
.service-grid strong.ready { color: var(--success); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: calc(100% - 32px); padding: 11px 16px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: #102028; box-shadow: 0 15px 48px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 270px 1fr; }
  .activity { grid-column: 1 / -1; min-height: auto; }
  .activity-log { min-height: 180px; max-height: 320px; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); padding-top: 10px; }
  .topbar { margin-bottom: 10px; }
  .system-state { max-width: 130px; text-align: right; }
  .workspace { display: flex; flex-direction: column; }
  .console { min-height: 650px; order: 1; }
  .sidebar { order: 2; }
  .activity { order: 3; }
  .dial-area { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .incoming-card { align-items: flex-start; flex-wrap: wrap; }
  .incoming-actions { width: 100%; margin-left: 0; }
  .incoming-actions .button { flex: 1; }
}
