:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --elev: #18243b;
  --text: #e6edf7;
  --muted: #9fb1d1;
  --accent: #4ea1ff;
  --accent-2: #7bd389;
  --danger: #ff5c5c;
  --tab: #22324f;
  --border: #243555;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -20%, #16223a 0%, var(--bg) 60%);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(180deg, #0e1626 0%, #0b1220 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 0.3px; }
.user-info { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.callsign { font-weight: 700; color: var(--text); background: #1b2a47; padding: 2px 8px; border-radius: 6px; }
.link-button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.link-button:hover { background: #13223e; }

.app-main { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; height: calc(100% - 58px); }

.radio-panel, .side-panel, .quick-messages, .placeholder {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.02);
}

.radio-panel { display: flex; flex-direction: column; min-height: 0; }
.channel-tabs { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); background: #0f1a30; border-top-left-radius: 12px; border-top-right-radius: 12px; }
.tab { background: var(--tab); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.tab:hover { background: #2b416d; }
.tab.active { background: linear-gradient(180deg, #2b416d 0%, #23365b 100%); border-color: #3a5891; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }

/* Colored channel tabs */
.tab[data-channel="Global"] { background: #2b2b2b; border-color: #3a3a3a; }
.tab.active[data-channel="Global"], .tab:hover[data-channel="Global"] { background: #3a3a3a; border-color: #4a4a4a; }
.tab[data-channel="Thames Valley Police"] { background: #103a66; border-color: #215b9e; }
.tab.active[data-channel="Thames Valley Police"], .tab:hover[data-channel="Thames Valley Police"] { background: #1a508b; border-color: #2b70c6; }
.tab[data-channel="South Central Ambulance Service"] { background: #0f4a2e; border-color: #2a7b52; }
.tab.active[data-channel="South Central Ambulance Service"], .tab:hover[data-channel="South Central Ambulance Service"] { background: #176242; border-color: #2f9a6b; }

.radio-feed { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.radio-line { background: var(--elev); border: 1px solid var(--border); padding: 8px 10px; border-radius: 8px; line-height: 1.3; }
.radio-prefix { font-weight: 700; margin-right: 6px; }
.radio-prefix.tvp { color: #4ea1ff; }
.radio-prefix.scas { color: #7bd389; }

.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: #0f1a30; }
.composer input { flex: 1; background: #0d162a; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); }
.composer button { background: var(--accent); border: none; color: #00122b; padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.composer button:hover { filter: brightness(1.05); }

.side-panel { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.quick-messages, .placeholder { flex: 1; display: flex; flex-direction: column; }
.quick-messages h2, .placeholder h2 { margin: 12px; font-size: 16px; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 12px 12px; }
.quick-btn { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #1a2847; color: var(--text); cursor: pointer; text-align: left; }
.quick-btn:hover { filter: brightness(1.15); }
.quick-btn.primary, .quick-btn.success, .quick-btn.warning, .quick-btn.danger { background: #1a2847; border-color: var(--border); }

.placeholder-body { margin: 0 12px 12px; flex: 1; border: 2px dashed #2a3d66; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop[aria-hidden="false"] { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 420px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal form { display: grid; gap: 10px; }
label { font-size: 14px; color: var(--muted); }
input, select { background: #0f1a30; border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
button.primary { background: var(--accent); border: none; color: #00122b; padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
button.primary:hover { filter: brightness(1.05); }
.form-hint { margin: 0; font-size: 12px; color: var(--muted); }

/* Responsive */
@media (max-width: 980px) {
  .app-main { grid-template-columns: 1fr; height: auto; }
  .side-panel { min-height: 50vh; }
}
