/* Samma formspråk som appen: en mörk kropp i grafit och en enda
   bakgrundsbelyst LCD-ruta. Gränsen är funktionell — det radion vet står på
   glaset, det man gör sitter på kroppen utanför. Färgerna är appens egna,
   ur lib/app/theme.dart. Rött betyder en enda sak: att någon sänder. */

:root {
  --body: #15171b;
  --frame: #0e1013;
  --card: #1b1e23;
  --raised: #2a2e35;
  --outline: #3d434c;
  --outline-faint: #2b3037;
  --text: #dce0e4;
  --text-faint: #9aa7b1;
  --primary: #8fc4dc;
  --on-primary: #0c1a22;
  --online: #5fbf6e;
  --transmit: #e0524d;

  --lcd-screen: #c7dde8;
  --lcd-glow: #d8eaf2;
  --lcd-edge: #8fa9b6;
  --lcd-ink: #13242f;
  --lcd-ink-faint: #52707f;

  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--body);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Ett finger som hålls på sändningsknappen ska inte markera text eller
     zooma sidan. */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#tx-strip {
  height: 4px;
  flex: none;
  background: var(--frame);
  transition: background .08s;
}
body.transmitting #tx-strip { background: var(--transmit); }
body.receiving #tx-strip { background: var(--primary); }

header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--frame);
}
header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .5px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-faint);
}
.link i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--outline);
}
.link.up i { background: var(--online); }

main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  overflow-y: auto;
}

.view { display: none; padding-bottom: 16px; }
.view.active { display: block; }
#view-chat.active { display: flex; flex-direction: column; height: 100%; padding-bottom: 0; }

/* -- Skärmglaset ---------------------------------------------------------- */

.bezel {
  margin: 10px 12px 0;
  padding: 7px;
  background: #08090b;
  border: 1px solid #31363d;
  border-radius: 16px;
}
.lcd {
  padding: 8px 14px 10px;
  border: 1px solid var(--lcd-edge);
  border-radius: 8px;
  /* Ljusare upptill: bakgrundsbelysning faller aldrig helt jämnt, och en
     spikrak enfärgad yta läses som en panel, inte som ett glas. */
  background: linear-gradient(var(--lcd-glow), var(--lcd-screen));
  color: var(--lcd-ink);
  font-family: var(--mono);
}
.lcd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 1.2px;
}
.lcd-badge {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--lcd-ink);
  color: var(--lcd-screen);
  font-weight: bold;
  letter-spacing: 1.5px;
}
.lcd-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lcd-ink-faint);
}
.lock { width: 13px; height: 13px; fill: var(--lcd-ink); }
.lcd-channel {
  margin: 2px 0;
  font-size: 64px;
  font-weight: bold;
  line-height: 1.1;
  text-align: center;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.lcd-status {
  min-height: 18px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lcd-status.faint { color: var(--lcd-ink-faint); font-weight: normal; }

/* -- Kanalväljaren -------------------------------------------------------- */

.dial {
  display: flex;
  gap: 12px;
  margin: 14px 12px 0;
}
.stepper { flex: 1; }
.stepper label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-faint);
}
.stepper > div { display: flex; }
.stepper button,
.stepper input {
  height: 44px;
  border: 1px solid var(--outline);
  background: var(--card);
  color: var(--text);
  font: bold 18px var(--mono);
}
.stepper button { width: 44px; flex: none; cursor: pointer; }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper button:active { background: var(--raised); }
.stepper input {
  flex: 1;
  min-width: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button { appearance: none; }

/* -- Listor ---------------------------------------------------------------- */

ul { list-style: none; margin: 0; padding: 0; }

.hint { margin: 10px 16px 0; font-size: 13px; color: var(--text-faint); }
.note {
  margin: 10px 12px 0;
  padding: 9px 12px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--card);
  font-size: 13px;
}

.peers { margin: 12px 12px 0; }
.peers li,
.scanner .who li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--outline-faint);
}
.peers .dot,
.scanner .dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--online);
}
.peers li.talking .dot,
.scanner li.talking .dot { background: var(--transmit); }
.peers .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peers .meta,
.scanner .meta { font: 11px var(--mono); color: var(--text-faint); }

.scanner { margin: 4px 12px 0; }
.scanner > li {
  margin-top: 10px;
  border: 1px solid var(--outline-faint);
  border-radius: 10px;
  background: var(--card);
}
.scanner > li.here { border-color: var(--primary); }
.scanner .channel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--text);
  font: bold 20px var(--mono);
  cursor: pointer;
}
.scanner .channel small { font: 12px system-ui, sans-serif; color: var(--text-faint); }
.scanner .who { padding: 0 12px 6px; }
.scanner .who li:last-child { border-bottom: 0; }

/* -- Mätarna --------------------------------------------------------------- */

.meters { margin: 14px 12px 0; display: grid; gap: 8px; }
.meter {
  display: grid;
  grid-template-columns: 70px 1fr 74px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-faint);
}
.meter code { font: 11px var(--mono); text-align: right; }
.bar {
  height: 10px;
  border-radius: 5px;
  background: var(--frame);
  border: 1px solid var(--outline-faint);
  overflow: hidden;
}
.bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width .12s linear;
}
#meter-in { background: var(--transmit); }

/* -- Sändningsknappen ------------------------------------------------------ */

.power,
.ptt {
  display: block;
  width: calc(100% - 24px);
  margin: 16px 12px 0;
  border-radius: 16px;
  font-weight: bold;
  letter-spacing: 1.5px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.power {
  padding: 18px;
  border: 1px solid var(--primary);
  background: #224250;
  color: #cde7f2;
  font-size: 15px;
}
.ptt {
  height: 132px;
  border: 2px solid var(--outline);
  background: var(--raised);
  color: var(--text);
  font-size: 16px;
  /* Fingret ska hålla knappen, inte rulla sidan eller öppna en meny. */
  touch-action: none;
}
.ptt:disabled { opacity: .45; cursor: default; }
.ptt.down {
  border-color: var(--transmit);
  background: var(--transmit);
  color: #fff3f2;
}
[hidden] { display: none !important; }

/* -- Chatten ---------------------------------------------------------------- */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat li {
  max-width: 82%;
  padding: 7px 11px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--outline-faint);
  align-self: flex-start;
  overflow-wrap: anywhere;
}
.chat li.mine {
  align-self: flex-end;
  background: #224250;
  border-color: #224250;
  color: #cde7f2;
}
.chat li.sealed .text { font-style: italic; color: var(--text-faint); }
.chat .who {
  display: block;
  font: 11px var(--mono);
  color: var(--text-faint);
  margin-bottom: 2px;
}
.chat-form,
.row { display: flex; gap: 8px; }
.chat-form {
  flex: none;
  padding: 10px 12px;
  border-top: 1px solid var(--outline-faint);
  background: var(--frame);
}

input[type='text'],
input[type='password'] {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  /* Sexton punkter, annars zoomar iOS in på fältet vid varje tryck. */
  font: 16px system-ui, sans-serif;
}
input:focus-visible,
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.chat-form button,
.row button {
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  cursor: pointer;
}
button.plain {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
}

/* -- Inställningar ---------------------------------------------------------- */

.card {
  margin: 12px 12px 0;
  padding: 14px;
  border: 1px solid var(--outline-faint);
  border-radius: 10px;
  background: var(--card);
}
.card h2 { margin: 0; font-size: 15px; }
.card .hint { margin: 4px 0 10px; }
.card .row + .hint { margin-top: 10px; }
.card .note { margin: 10px 0 0; background: var(--body); }

.diagnostics {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 10px 0;
  font-size: 13px;
}
.diagnostics dt { color: var(--text-faint); }
.diagnostics dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

/* -- Flikarna --------------------------------------------------------------- */

nav {
  flex: none;
  display: flex;
  justify-content: center;
  background: var(--frame);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  position: relative;
  flex: 1;
  max-width: 140px;
  padding: 13px 4px;
  border: 0;
  border-top: 2px solid transparent;
  background: none;
  color: var(--text-faint);
  font-size: 13px;
  cursor: pointer;
}
nav button.active { color: var(--primary); border-top-color: var(--primary); }
nav button i {
  position: absolute;
  top: 9px;
  margin-left: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}
