:root {
  color-scheme: dark;
  --bg: #14160f;
  --panel: #1c1f16;
  --panel-2: #25291d;
  --line: #3a3f30;
  --text: #f4f1e6;
  --muted: #b7b39f;
  --amber: #f0a202;
  --green: #9cbe6a;
  --red: #e07a5f;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(240, 162, 2, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(20, 22, 15, 0.92);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.channel { color: var(--amber); font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 0.04em; font-size: 1.35rem; }
.channel a, a.channel { color: inherit; text-decoration: none; }
a.channel { color: var(--amber); }
.nav { display: flex; gap: 14px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); }

.pill {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
}
.pill.on { color: var(--green); border-color: #4d5c38; }
.pill.off { color: var(--red); border-color: #6a4036; }

.logout { margin-left: auto; }
.logout button { padding: 6px 12px; }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

.home {
  display: grid;
  place-items: center;
  padding: 48px 20px;
}
.hero { width: min(34rem, 100%); }
.hero h1 {
  margin: 6px 0 10px;
  font-size: 2.6rem;
  letter-spacing: -0.03em;
  font-weight: 650;
}
.hero .lede { margin: 0 0 10px; font-size: 1.15rem; }
.hero p { line-height: 1.5; }
.hero .lede + p { color: var(--muted); margin-top: 0; }
.login { margin-top: 22px; max-width: 22rem; }
.enter { margin-top: 22px; }
.enter form { margin: 0; }
a.button {
  display: inline-block;
  background: var(--amber);
  color: #1a1404;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 650;
}
a.button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.message-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}
.message-mark {
  position: fixed;
  top: 18px;
  left: 20px;
  color: var(--amber);
  font-family: ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
  text-decoration: none;
}
.message-square {
  width: min(34rem, calc(100vw - 40px), calc(100dvh - 56px));
  aspect-ratio: 1;
  display: flex;
  background: var(--panel);
  border: 1px solid #5a614c;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 4vw, 2.4rem);
  overflow: auto;
}
.message-body {
  margin: auto;
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(1.55rem, 3vw, 2.05rem);
  line-height: 1.4;
  font-weight: 500;
}
.sheet { width: min(40rem, 100%); margin: 0 auto; padding: 22px 20px 48px; }
.sheet.messages {
  width: min(72rem, 100%);
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.messages #list { margin-top: 0; }
.sheet.analytics { width: min(72rem, 100%); }
#map { height: 440px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); margin-bottom: 14px; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.95); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-container a { color: var(--amber); }
.stats { display: flex; gap: 16px; color: var(--muted); margin: 0 0 12px; }
.table-wrap { overflow-x: auto; }
table.visits { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.visits th, .visits td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.visits th { color: var(--muted); font-weight: 650; }
.visits td.clip { max-width: 16rem; overflow-wrap: anywhere; }
.sheet form, .msg {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.sheet form { display: flex; flex-direction: column; gap: 8px; }
#fields, #confirm, #repeat-fields { display: flex; flex-direction: column; gap: 8px; }
#fields[hidden], #confirm[hidden], #repeat-fields[hidden] { display: none; }
.summary { white-space: pre-wrap; margin: 0; }
label.check { flex-direction: row; align-items: center; color: var(--text); }
label.check input { width: auto; }
#list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.msg .token { font-family: ui-monospace, monospace; color: var(--amber); text-decoration: none; }
.msg .message { white-space: pre-wrap; margin: 8px 0; }
.msg .log { margin-top: 8px; }
.msg .log p { margin: 4px 0; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 68px);
}

aside, main { padding: 18px 20px 32px; }
aside {
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 68px;
  align-self: start;
  max-height: calc(100vh - 68px);
  overflow: auto;
}

h2, h3 { margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 0.95rem; }

#feeds { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 6px; }
#feeds button.feed {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
#feeds button.feed.active, #feeds button.feed:hover { background: var(--panel-2); border-color: var(--line); }
.feed .name { display: block; font-family: ui-monospace, monospace; }
.feed .blurb { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--line); }
.dot.on { background: var(--green); }

#ad-form, #composer, .login, #feed-head, .card, .plain {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

#ad-form, #composer, .login { display: flex; flex-direction: column; gap: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
input, textarea, select, button {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
button { background: var(--amber); color: #1a1404; border-color: transparent; font-weight: 650; cursor: pointer; }
button.ghost, button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#feed-head { margin-bottom: 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
#feed-head h2 { font-family: ui-monospace, monospace; }
#posts { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.card .meta, .plain .meta { color: var(--muted); font-size: 0.78rem; margin-bottom: 6px; }
.card a { color: var(--amber); }
.card .message { white-space: pre-wrap; margin: 8px 0 0; }
.card pre {
  margin: 10px 0 0;
  padding: 10px;
  overflow: auto;
  background: #10120c;
  border-radius: 8px;
  font-size: 0.82rem;
}
.empty { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
.error { min-height: 1.2em; color: var(--red); }
#earlier { margin-bottom: 14px; }

@media (max-width: 800px) {
  header { flex-wrap: wrap; }
  .logout { margin-left: 0; }
  .layout, .sheet.messages { grid-template-columns: 1fr; }
  aside {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
