/* twitchmon — near-black, hairline borders, amber signal */

:root {
  --bg: #09090b;
  --card: #0d0d10;
  --card-2: #101014;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #ededf0;
  --muted: #9a9aa6;
  --faint: #626270;
  --signal: #ffa028;
  --signal-hi: #ffb554;
  --signal-ink: #1a1000;
  --glow: rgba(255, 160, 40, 0.28);
  --danger: #ff5f57;
  --ok: #3ecf8e;
  /* Pushover priority ramp */
  --p-lowest: #626270;
  --p-low: #5aa2f0;
  --p-normal: #8b8b98;
  --p-high: #ffa028;
  --p-emergency: #ff5f57;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(900px 320px at 70% -140px, rgba(255, 160, 40, 0.045), transparent 70%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--signal); text-decoration: none; }
a:hover { color: var(--signal-hi); }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }

/* --- Header --- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.8rem 1.5rem;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.wordmark:hover { color: var(--text); }
.wordmark .led {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--signal);
  box-shadow: 0 0 10px var(--glow), 0 0 3px var(--glow);
  flex: none;
}

.status {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}
.status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(62, 207, 142, 0.5);
  flex: none;
  animation: pulse 2.4s ease-in-out infinite;
}
.status .dot.idle { background: var(--faint); box-shadow: none; animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none; }
}

.top nav { font-size: 0.85rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.top nav strong { color: var(--text); font-weight: 600; }
.top nav a { margin-left: 0.9rem; color: var(--muted); }
.top nav a:hover { color: var(--text); }
@media (max-width: 620px) {
  .status { display: none; }
}

/* --- Layout --- */

main { max-width: 1020px; margin: 1.75rem auto 4rem; padding: 0 1.25rem; }

.grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  /* The 1fr spacer row absorbs the terms column's extra height so the
     account panel hugs the channels panel instead of floating mid-page. */
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    'channels terms'
    'account  terms'
    '.        terms';
  gap: 0 1.25rem;
}
.col-channels { grid-area: channels; }
.col-terms { grid-area: terms; }
.col-account { grid-area: account; }
@media (max-width: 780px) {
  /* Single column: channels, then the terms workspace, account last. */
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: 'channels' 'terms' 'account';
  }
}

.acct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

section.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}
.hint { color: var(--muted); font-size: 0.84rem; margin-bottom: 1rem; }
.empty { color: var(--faint); font-size: 0.88rem; padding: 0.5rem 0; }

/* --- Flash messages --- */

.flash {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}
.flash.error { background: rgba(255, 95, 87, 0.08); border: 1px solid rgba(255, 95, 87, 0.35); color: #ffb3ad; }
.flash.notice { background: rgba(62, 207, 142, 0.08); border: 1px solid rgba(62, 207, 142, 0.35); color: #8fe0bd; }

/* --- Banner (Pushover not connected) --- */

.banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(255, 160, 40, 0.09), rgba(255, 160, 40, 0.02));
  border: 1px solid rgba(255, 160, 40, 0.3);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.25rem;
}
.banner p { flex: 1 1 260px; font-size: 0.9rem; color: var(--text); }
.banner p span { color: var(--muted); }

/* --- Controls --- */

input, select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0.55rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(255, 160, 40, 0.15);
}
input.mono { font-family: var(--mono); font-size: 0.85rem; }
select { cursor: pointer; }

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--signal-ink);
  background: var(--signal);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  box-shadow: 0 0 16px var(--glow);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
  background: var(--signal-hi);
  color: var(--signal-ink);
  box-shadow: 0 0 24px rgba(255, 160, 40, 0.4);
}

.btn-quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: none;
}
.btn-quiet:hover { background: var(--card-2); border-color: var(--line-strong); color: var(--text); box-shadow: none; }

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  box-shadow: none;
}
.btn-danger:hover { background: rgba(255, 95, 87, 0.1); color: var(--danger); box-shadow: none; }

.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

form.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
form.row input { flex: 1 1 150px; min-width: 0; }
form.stack { display: flex; flex-direction: column; gap: 0.6rem; }

/* --- Channel list --- */

.channel-list { list-style: none; }
.channel-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.15rem;
  border-bottom: 1px solid var(--line);
}
.channel-list li:last-child { border-bottom: none; }
.channel-list .name { font-family: var(--mono); font-size: 0.88rem; }
.channel-list .name::before { content: '#'; color: var(--faint); }
.channel-list form { display: inline; }

/* --- Terms --- */

.term {
  position: relative;
  background: transparent;
  border: 1px solid var(--line);
  border-left: 3px solid var(--p-normal);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
  transition: border-color 0.15s ease;
}
.term:hover { border-color: var(--line-strong); }
.term[data-priority="-2"], .term[data-priority="-2"]:hover { border-left-color: var(--p-lowest); }
.term[data-priority="-1"], .term[data-priority="-1"]:hover { border-left-color: var(--p-low); }
.term[data-priority="0"],  .term[data-priority="0"]:hover  { border-left-color: var(--p-normal); }
.term[data-priority="1"],  .term[data-priority="1"]:hover  { border-left-color: var(--p-high); }
.term[data-priority="2"],  .term[data-priority="2"]:hover  { border-left-color: var(--p-emergency); }

.term.new {
  border-style: dashed;
  border-left-style: solid;
}

.term-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.term-word {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}
.term-top input[name="term"] { flex: 1 1 180px; }

.assign { border: none; }
.assign legend {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-bottom: 0.45rem;
}
.assign .chips { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; }
.assign label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.83rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--muted);
}
.assign label:has(input:checked) { color: var(--text); }
.assign input[type="checkbox"] { accent-color: var(--signal); padding: 0; }

.term-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.9rem;
}

/* --- Tables (admin) --- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--line); }
th {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}
tr:last-child td { border-bottom: none; }
td.mono { font-family: var(--mono); font-size: 0.88rem; }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.tag.ok { background: rgba(62, 207, 142, 0.1); color: var(--ok); border: 1px solid rgba(62, 207, 142, 0.3); }
.tag.off { background: transparent; color: var(--faint); border: 1px solid var(--line-strong); }

/* --- Auth card (login / admin gate) --- */

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(600px 400px at 50% 30%, rgba(255, 160, 40, 0.05), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  position: relative;
}
/* Hairline amber gradient along the card's top edge. */
.auth-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
}
.auth-card .wordmark { font-size: 1.35rem; margin-bottom: 0.4rem; }
.auth-card .tagline {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1.75rem;
}
.auth-card .flash { margin-bottom: 1rem; }
.auth-card .btn { margin-top: 0.3rem; }
.auth-card .foot { margin-top: 1.5rem; font-size: 0.8rem; color: var(--faint); }
