:root {
  color-scheme: dark;
  --bg: #0a0f0e;
  --surface: #111716;
  --surface-2: #171f1d;
  --surface-3: #1d2724;
  --field: #0d1312;
  --line: #2d3934;
  --line-strong: #43534c;
  --text: #edf2e8;
  --muted: #a8b6ad;
  --faint: #77877f;
  --green: #69b68d;
  --water: #6aa7c8;
  --amber: #cda85d;
  --red: #d06e62;
  --ink: #050807;
  --radius: 3px;
  --shadow: 0 10px 24px rgb(0 0 0 / 20%);
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/atkinson-hyperlegible-400.ttf") format("truetype");
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/atkinson-hyperlegible-700.ttf") format("truetype");
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgb(105 182 141 / 55%);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: var(--green);
  cursor: pointer;
}

button:hover {
  border-color: rgb(237 242 232 / 38%);
  filter: brightness(1.05);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

button.danger {
  color: var(--text);
  background: rgb(208 110 98 / 18%);
  border-color: rgb(208 110 98 / 56%);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.app-shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 4px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.12;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.brand p,
.feed-heading p,
.panel-heading p,
.dialog-heading p,
.empty-state,
.meta,
.source-line {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.app-views {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.view-panel {
  display: grid;
  gap: 16px;
}

.view-panel[hidden],
[hidden] {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(380px, 0.9fr) minmax(500px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.filters,
.feed-pane,
.map-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  color: var(--text);
  background: var(--field);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--water);
  box-shadow: 0 0 0 2px rgb(106 167 200 / 22%);
}

.filter-actions,
.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.feed-pane {
  min-height: calc(100vh - 112px);
  padding: 12px;
}

.feed-heading,
.panel-heading,
.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.posts-list {
  display: grid;
  gap: 9px;
}

.load-more-button {
  width: 100%;
  margin-top: 12px;
}

.post-card {
  display: grid;
  align-items: stretch;
  justify-content: stretch;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  color: var(--text);
  background: var(--field);
  text-align: left;
}

.post-card.selected {
  border-color: rgb(105 182 141 / 86%);
  box-shadow: inset 3px 0 0 rgb(105 182 141 / 88%);
}

.post-card:hover {
  border-color: rgb(106 167 200 / 62%);
}

.post-card:focus-visible {
  outline: 2px solid rgb(106 167 200 / 55%);
  outline-offset: 2px;
}

.post-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.freshness-badge {
  display: grid;
  place-items: center;
  min-width: 78px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  color: var(--text);
  background: var(--surface-2);
  line-height: 1.1;
}

.freshness-badge span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.freshness-badge strong {
  font-size: 13px;
}

.freshness-fresh {
  border-color: rgb(105 182 141 / 58%);
  background: rgb(105 182 141 / 12%);
}

.freshness-recent {
  border-color: rgb(106 167 200 / 52%);
  background: rgb(106 167 200 / 11%);
}

.freshness-aging {
  border-color: rgb(205 168 93 / 55%);
  background: rgb(205 168 93 / 12%);
}

.freshness-old {
  border-color: rgb(208 110 98 / 52%);
  background: rgb(208 110 98 / 11%);
}

.post-summary,
.post-setup {
  line-height: 1.42;
}

.post-setup {
  border-left: 3px solid rgb(105 182 141 / 75%);
  padding-left: 9px;
  color: #cfe4d8;
}

.tag-row,
.accuracy-row,
.catalog-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.pill,
.accuracy-tag,
.catalog-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: var(--radius);
  padding: 0 8px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
}

.pill {
  color: var(--ink);
  background: var(--green);
  border-color: transparent;
}

.accuracy-tag {
  color: var(--muted);
  background: var(--field);
}

.source-line {
  font-size: 13px;
}

.policy-note {
  border: 1px solid rgb(205 168 93 / 38%);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  background: rgb(205 168 93 / 8%);
  font-size: 13px;
  line-height: 1.45;
}

.intel-pane {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.map-panel,
.detail-panel {
  padding: 12px;
}

#spot-map {
  display: block;
  width: min(100%, clamp(300px, 28vw, 400px));
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--field);
  border: 1px solid var(--line);
}

.detail-panel {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: var(--field);
  overflow-wrap: anywhere;
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.original-text {
  white-space: pre-wrap;
  max-height: clamp(140px, 24vh, 280px);
  overflow: auto;
  border-left: 3px solid var(--water);
  padding: 10px 12px;
  color: var(--muted);
  background: var(--field);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.source-state {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: var(--radius);
  padding: 0 8px;
  color: var(--ink);
  background: var(--green);
  font-size: 12px;
}

.source-state.off {
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

a {
  color: var(--water);
}

.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgb(205 168 93 / 44%);
  border-radius: var(--radius);
  padding: 0 12px;
  color: #e6cc92;
  background: rgb(205 168 93 / 8%);
  text-decoration: none;
  white-space: nowrap;
}

.support-link:hover {
  border-color: rgb(205 168 93 / 72%);
  background: rgb(205 168 93 / 14%);
}

.hidden {
  display: none !important;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(0 0 0 / 62%);
}

#import-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
}

.preview-output {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--muted);
  background: var(--field);
}

.empty-list,
.empty-state,
.error-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.error-state {
  color: #efb2aa;
  border-color: rgb(208 110 98 / 48%);
  background: rgb(208 110 98 / 8%);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  border-top: 1px solid var(--line);
}

.site-footer p {
  max-width: 760px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.legal-shell {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.legal-card,
.admin-header,
.admin-toolbar,
.submission-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.legal-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.legal-card header,
.legal-section {
  display: grid;
  gap: 8px;
}

.legal-card h1 {
  font-size: 28px;
}

.legal-card p,
.legal-card li {
  color: var(--muted);
  line-height: 1.6;
}

.legal-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-shell {
  display: grid;
  gap: 16px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 16px;
}

.admin-header p,
.admin-message,
.submission-heading p {
  color: var(--muted);
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.submission-list {
  display: grid;
  gap: 12px;
}

.submission-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.submission-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.submission-card details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--field);
}

.submission-card summary {
  cursor: pointer;
  color: var(--muted);
}

.submission-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 1140px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 220px minmax(360px, 1fr);
  }

  .intel-pane {
    grid-column: 1 / -1;
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    gap: 12px;
    padding-bottom: 12px;
  }

  .topbar-actions,
  .post-main,
  .feed-heading,
  .panel-heading,
  .admin-header,
  .submission-heading,
  .site-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .site-footer nav {
    justify-content: flex-start;
  }

  .workspace,
  .intel-pane,
  .dialog-grid,
  .admin-toolbar,
  .submission-actions {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }

  .feed-pane {
    min-height: 0;
  }
}
