/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: repeating-linear-gradient(0deg, #33271d 0 3px, #392b20 4px, #30261d 6px);
  color: #28281f;
  font: 16px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

main {
  max-width: 960px;
  margin: 24px auto;
  padding: 24px clamp(16px, 4vw, 38px);
  background: #c2bda7;
  border: 8px ridge #524d3c;
  box-shadow: 0 12px 36px #17100c;
}

h1 {
  margin: 0;
  font: italic 36px/1 Georgia, serif;
  letter-spacing: -.06em;
}

h2 { margin: 0 0 8px; font-size: 19px; }
p { margin: 8px 0 16px; }

section {
  padding: 16px 0;
  border-bottom: 1px solid #898572;
}

small, output, pre, kbd, .screen, header span, .cap, label, summary {
  font-family: ui-monospace, monospace;
}

output { color: inherit; font-size: 12px; }

/* ---------- Header, account and tabs ---------- */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 9px;
  border-bottom: 3px double #4c4939;
  user-select: none;
}

header span { color: #494738; }

.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: ui-monospace, monospace;
}

nav { margin-top: 14px; }

nav button[aria-pressed=true] {
  background: #292e25;
  color: #ffe0a2;
  border-style: inset;
}

#loginError { color: #8a1f11; min-height: 1.5em; }

/* ---------- Form controls ---------- */
button, select {
  padding: 7px 12px;
  border: 2px outset #847e68;
  border-radius: 2px;
  background: #45473d;
  color: #fff3d2;
  font: inherit;
  cursor: pointer;
}

button:hover { background: #535547; }
button[aria-pressed=true] { color: #b5efa0; }

button:focus-visible, summary:focus-visible { outline: 3px solid #34769b; }

input { width: 100%; accent-color: #e3b46d; }

input[type=text] {
  padding: 8px;
  background: #ece7ce;
  color: #282a20;
  border: 2px inset #a09b83;
  font: 20px monospace;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 18px;
  align-items: end;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  max-width: 420px;
}

/* ---------- Radio rig: dial, waterfall, tuning ---------- */
.rig {
  margin-top: 16px;
  padding: 19px;
  background: linear-gradient(#45483f, #35382f);
  border: 4px ridge #716e58;
  border-radius: 4px;
  color: #efe6c6;
  user-select: none;
}

.upper, .scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upper small, .scale {
  color: #d4cfb5;
  font: 12px ui-monospace, monospace;
}

.scale { margin-bottom: 18px; }

#dial {
  padding: 0 12px;
  background: linear-gradient(#bba773, #efdaa3 65%, #c6aa72);
  border: 4px inset #514f40;
  color: #473217;
  font: clamp(25px, 5vw, 46px) ui-monospace, monospace;
  text-shadow: 0 1px #e7d8b1;
}

#dial small { color: #59472d; }

.scope {
  position: relative;
  margin-top: 14px;
  overflow: hidden;
  background: #10180f;
  border: 4px inset #5b5a48;
}

.scope::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 2px, #0002 3px);
}

.scope canvas {
  display: block;
  width: 100%;
  height: 150px;
  cursor: crosshair;
}

.scope i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid #ffcf82;
  pointer-events: none;
}

/* ---------- Chat rooms ---------- */
#log {
  height: 220px;
  padding: 12px 16px;
  overflow-y: auto;
  background: #222b20;
  color: #c0ce93;
  border: 4px inset #696a57;
  font: 16px/1.6 ui-monospace, monospace;
}

#log .line { overflow-wrap: anywhere; }
#log .call { color: #ffe0a2; margin-right: 8px; }
#log .call::after { content: ":"; }
#log .me .call { color: #b5efa0; }

#online, #roomStatus { font: 13px ui-monospace, monospace; color: #494738; margin: 8px 0 0; }

/* ---------- TX monitor ---------- */
.screen {
  margin: 12px 0;
  padding: 20px 24px;
  background: #222b20;
  color: #c0ce93;
  border: 4px inset #696a57;
  border-radius: 3px;
  user-select: none;
}

.cap {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.screen pre {
  height: 2em;
  margin: 12px 0;
  overflow: auto;
  font-size: 28px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.signal {
  min-height: 32px;
  padding-top: 8px;
  border-top: 1px solid #486050;
}

/* ---------- Key / paddle ---------- */
#pad {
  width: 100%;
  padding: 14px;
  background: linear-gradient(#d7c292, #a99361);
  color: #342e20;
  border: 3px outset #b8a376;
  border-radius: 4px;
  font: 700 18px ui-monospace, monospace;
  letter-spacing: .09em;
  white-space: pre-wrap;
  touch-action: none;
  user-select: none;
}

#pad.on {
  background: #ceb17b;
  color: #2a2519;
  border-style: inset;
}

#tip, #feedback { color: #494738; }
#tip { font-size: 14px; }

/* ---------- Sending drills ---------- */
#target {
  font: bold 24px monospace;
  letter-spacing: .08em;
}

/* ---------- Receive practice ---------- */
#copyForm {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

#result { margin: 10px 0; }

body.listening :is(.rig, .screen, #pad, #tip, #sendDrills, label:has(#mode)) {
  display: none;
}

/* ---------- Notes and reference ---------- */
details { padding: 14px 0; }
summary { cursor: pointer; font-weight: bold; }

.ref {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 4px;
  font: 16px monospace;
}

@media (max-width: 650px) {
  main { margin: 0; border-width: 4px; }
  .upper { gap: 8px; }
  #dial { font-size: 22px; }
}
