/* ppt-mon — terminal-surveillance theme (SPEC §6.1). Mobile-first single
   fixed-width column on a dark surface; all colour/geometry from design tokens. */

:root {
  --bg: #05060a;
  --surface: #0a0c10;
  --surface-2: #0f1218;
  --border: #1c2333;
  --border-2: #2a3654;
  --text: #e8ecf4;
  --text-dim: #c8cdd8;
  --muted: #5c6578;
  --accent: #00e5a0; /* mine / owned / primary actions */
  --danger: #ff4f6e; /* contested / destructive */
  --led-open: #3a4152;
  --radius: 6px;

  --font-ui: 'IBM Plex Mono', ui-monospace, monospace;
  --font-display: 'Space Mono', ui-monospace, monospace;
}

[hidden] {
  display: none !important;
} /* required by house stack */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  color: var(--text-dim);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 2px;
}

@keyframes ptPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* --- app frame: centre a fixed-width column ------------------------------- */

.frame {
  width: 100%;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  max-height: 920px;
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

/* --- header --------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #101520 0%, var(--surface-2) 100%);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-badge {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 0 12px #00e5a066;
  flex-shrink: 0;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
  line-height: 1;
}

.subtitle {
  font-size: 8.5px;
  letter-spacing: 2.2px;
  color: var(--accent);
  opacity: 0.75;
  text-transform: uppercase;
  margin-top: 4px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--danger);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px #00e5a066;
  animation: ptPulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

/* Feed older than POLL_STALE_MINUTES (or not loaded): dot goes red. */
.status--stale .status-dot {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

.status-updated {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* --- screen (scrollable middle) ------------------------------------------- */

.screen {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.empty-hint {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-align: center;
  margin-top: 40px;
}

/* --- tab bar -------------------------------------------------------------- */

.tabbar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 13px 0 11px;
  text-align: center;
  text-decoration: none;
  position: relative;
}

.tab-label {
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.tab-underline {
  display: block;
  height: 2px;
  width: 40%;
  margin: 8px auto 0;
  background: transparent;
  border-radius: 1px;
}

.tab--active .tab-label {
  color: var(--accent);
}

.tab--active .tab-underline {
  background: var(--accent);
  box-shadow: 0 0 8px #00e5a066;
}

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 13px;
  border-radius: 5px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  cursor: pointer;
  text-align: center;
}

.btn--primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

/* --- form fields + validation states (SPEC §6.1) -------------------------- */

.field-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

.field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  letter-spacing: 1px;
  outline: none;
  width: 100%;
}

.field:focus {
  border-color: var(--border-2);
}

/* Toggled by the debounced live-validation JS (Stages 5/6). */
.field.is-valid {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 8px #00e5a044;
}

.field.is-invalid {
  border-color: var(--danger);
}

/* --- login ---------------------------------------------------------------- */

.app--login {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 320px;
}

.brand--login {
  justify-content: center;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form .field {
  margin-bottom: 10px;
}

.login-form .btn {
  margin-top: 10px;
  width: 100%;
}

.form-error {
  color: var(--danger);
  font-size: 11px;
  letter-spacing: 0.5px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 16px;
  text-align: center;
}

/* --- status LEDs + status lines (consumed from Stage 5) ------------------- */

.led {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--led-open);
}

.led--mine {
  background: var(--accent);
  box-shadow: 0 0 10px #00e5a066;
}
.led--theirs {
  background: var(--danger);
  box-shadow: 0 0 10px #ff4f6e55;
}
.led--open {
  background: var(--led-open);
  box-shadow: none;
}
.led--unknown {
  background: var(--muted);
  box-shadow: none;
}

.status-line {
  font-size: 11px;
  margin-top: 5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.status-line--mine {
  color: var(--accent);
}
.status-line--theirs {
  color: var(--danger);
}
.status-line--open {
  color: var(--muted);
}
.status-line--unknown {
  color: var(--muted);
}

/* --- payphones screen: stats row (SPEC §6.3) ------------------------------ */

.stats {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.stat--monitored {
  color: var(--muted);
}
.stat--owned {
  color: var(--accent);
}
.stat--contested {
  color: var(--danger);
}

/* --- payphones screen: watchlist rows ------------------------------------- */

.phone-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.phone-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 6px;
  border-bottom: 1px solid var(--border);
}

.phone-main {
  flex: 1;
  min-width: 0;
}

.phone-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.phone-id {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.phone-coords {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.phone-flag {
  font-family: var(--font-display);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 3px;
  padding: 1px 4px;
}

.phone-address {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-top: 3px;
}

.phone-time {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Bin (delete) button — drawn from spans so no external asset is needed. */
.bin-btn {
  position: relative;
  width: 14px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 6px;
  padding: 4px;
  box-sizing: content-box;
}

.bin-lid {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 2px;
  background: var(--danger);
  border-radius: 1px;
}

.bin-lid::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 4px;
  width: 6px;
  height: 2px;
  background: var(--danger);
  border-radius: 1px;
}

.bin-body {
  position: absolute;
  top: 7px;
  left: 5px;
  width: 12px;
  height: 11px;
  border: 1.5px solid var(--danger);
  border-top: none;
  border-radius: 0 0 2px 2px;
}

/* + MONITOR NEW PHONE */
.add-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  text-decoration: none;
}

/* --- modals (add / delete confirm) — inline no-JS baseline (SPEC §6.7) ----- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: 88%;
  max-width: 320px;
  background: var(--surface-2);
  border-radius: 8px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.modal--accent {
  border: 1px solid var(--accent);
  box-shadow:
    0 0 40px #00e5a033,
    0 24px 48px rgba(0, 0, 0, 0.5);
}
.modal--danger {
  border: 1px solid var(--danger);
  box-shadow:
    0 0 40px #ff4f6e33,
    0 24px 48px rgba(0, 0, 0, 0.5);
  max-width: 300px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}

.modal-title--accent {
  color: var(--accent);
}
.modal-title--danger {
  color: var(--danger);
  margin-bottom: 10px;
}

.modal-close {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-body--center {
  text-align: center;
}

.modal-line {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 6px;
}

.modal-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
}

.lookup-line {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
  padding: 8px 0 4px;
}

.lookup-line--error {
  color: var(--danger);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.modal-actions > * {
  flex: 1;
}
.modal-actions form {
  margin: 0;
}
.modal-actions form .btn {
  width: 100%;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  text-decoration: none;
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- options screen (SPEC §6.6) ------------------------------------------- */
/* Toggles and selectors are native checkbox/radio inputs so the screen works
   with JS disabled; the reveal/selected states are driven purely by CSS sibling
   selectors off :checked. Stage 9 layers live gamer-tag validation on top. */

.options-form {
  display: flex;
  flex-direction: column;
}

.save-banner {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 0 0 16px;
  text-align: center;
  box-shadow: 0 0 12px #00e5a033;
}

.opt-section {
  margin-bottom: 22px;
}

.opt-heading {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.opt-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.opt-hint,
.opt-hint-static {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.opt-hint.is-valid {
  color: var(--accent);
}
.opt-hint.is-invalid {
  color: var(--danger);
}

.opt-error {
  font-size: 10px;
  color: var(--danger);
  letter-spacing: 1px;
  margin-top: 4px;
  text-transform: uppercase;
}

/* --- channel cards (email / ntfy) ---------------------------------------- */

.channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  overflow: hidden;
}

.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
}

.channel-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

.channel-sub {
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-top: 2px;
}

.channel-reveal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 13px 13px;
}

/* Native inputs are visually hidden; their labels are the interactive control. */
.toggle-input,
.mode-input,
.chip-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  width: 38px;
  height: 20px;
  background: #2a323e;
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}

.toggle-input:checked ~ .channel-head .toggle {
  background: var(--accent);
}
.toggle-input:checked ~ .channel-head .toggle .toggle-knob {
  transform: translateX(18px);
}

/* Collapse a channel's config until its toggle is on. */
.toggle-input:not(:checked) ~ .channel-reveal {
  display: none;
}

/* Keyboard focus visibility (labels aren't focusable, the inputs are). */
.toggle-input:focus-visible ~ .channel-head .toggle {
  box-shadow: 0 0 0 2px var(--accent);
}

/* --- notify mode cards (once / continuous) -------------------------------- */

.mode-block {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.mode-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
}

.mode-card-sub {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1px;
}

#mode_once:checked ~ .mode-cards label[for='mode_once'],
#mode_continuous:checked ~ .mode-cards label[for='mode_continuous'] {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px #00e5a022;
}

.mode-input:focus-visible ~ .mode-cards {
  outline: 1px solid var(--accent);
}

/* Repeat interval only applies to continuous mode. */
.interval-reveal {
  margin-top: 12px;
  display: none;
}
#mode_continuous:checked ~ .interval-reveal {
  display: block;
}

/* --- interval chips ------------------------------------------------------- */

.chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.chip-input:checked + .chip {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px #00e5a022;
}

.chip-input:focus-visible + .chip {
  box-shadow: 0 0 0 2px var(--accent);
}

.opt-save {
  width: 100%;
  margin-top: 4px;
}

/* --- error page ----------------------------------------------------------- */

.error {
  max-width: 460px;
  margin: 4rem auto;
  padding: 0 1rem;
}

.error h1 {
  color: var(--danger);
}

.error pre {
  white-space: pre-wrap;
  word-break: break-word;
}
