:root {
  --paper: #f7f5ef;
  --panel: #ffffff;
  --ink: #1d2524;
  --muted: #66706c;
  --line: #d9ded9;
  --teal: #136f63;
  --teal-soft: #e5f3ef;
  --burgundy: #8b2f47;
  --brass: #b9852a;
  --charcoal: #222827;
  --shadow: 0 18px 45px rgba(29, 37, 36, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--charcoal);
  color: white;
  font-weight: 800;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-button,
.ghost-button,
.secondary-button,
.primary-button,
.picker-toggle {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.nav-button.active,
.primary-button {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.secondary-button {
  background: var(--teal-soft);
  border-color: #b9d7cf;
  color: #0f5c52;
}

.ghost-button {
  background: transparent;
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.public-view {
  width: min(1180px, calc(100vw - 32px));
  margin: 34px auto;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.public-panel,
.coverage-panel,
.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.public-panel h1,
.public-panel h2,
.coverage-panel h2,
.admin-section h2,
.sidebar-head h2,
.chat-empty h2 {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.18;
}

.public-panel h1 {
  font-size: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--burgundy);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.intro {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 22px;
}

.stacked-form {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 700;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.turnstile-slot {
  min-height: 70px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.form-status,
.empty-state,
.empty-menu {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.otp-fields {
  display: grid;
  gap: 10px;
}

.workspace-visual {
  grid-row: span 2;
  margin: 0;
  min-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.workspace-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.coverage-panel {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto 34px;
}

.coverage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.coverage-total,
.coverage-list-panel summary span:last-child {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf4f5;
  color: #40504f;
  padding: 0 12px;
  font-weight: 800;
  white-space: nowrap;
}

.coverage-map-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf2f3;
}

.coverage-map {
  width: 100%;
  aspect-ratio: 1000 / 520;
  display: block;
}

.coverage-ocean {
  fill: #eaf2f3;
}

.coverage-country,
.coverage-marker {
  stroke: white;
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
  transition: fill 120ms ease, stroke 120ms ease;
}

.coverage-country {
  fill: #d3dcde;
}

.coverage-marker {
  fill: #879799;
}

.coverage-country.covered {
  fill: #27815f;
  cursor: pointer;
}

.coverage-marker.covered {
  fill: var(--burgundy);
  cursor: pointer;
}

.coverage-country.covered:hover,
.coverage-country.covered:focus,
.coverage-country.covered.selected,
.coverage-marker.covered:hover,
.coverage-marker.covered:focus,
.coverage-marker.covered.selected {
  fill: var(--brass);
  stroke: var(--charcoal);
  stroke-width: 1.4;
  outline: none;
}

.coverage-tooltip {
  position: absolute;
  z-index: 5;
  width: min(260px, calc(100% - 24px));
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.coverage-tooltip strong,
.coverage-tooltip small,
.coverage-tooltip span {
  display: block;
}

.coverage-tooltip small {
  color: var(--muted);
}

.coverage-map-message {
  fill: var(--muted);
  font-weight: 800;
}

.coverage-list-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.coverage-list-panel summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 800;
}

.coverage-list {
  max-height: 430px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding-top: 4px;
}

.coverage-list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  padding: 12px;
  display: grid;
  gap: 9px;
  cursor: pointer;
}

.coverage-list-item:hover,
.coverage-list-item:focus,
.coverage-list-item.selected {
  border-color: #b9d7cf;
  background: var(--teal-soft);
  outline: none;
}

.coverage-list-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.country-code {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #f1e8d6;
  color: #644716;
  font-size: 12px;
  font-weight: 900;
}

.coverage-list-main strong,
.coverage-list-main small,
.coverage-list-meta small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.coverage-list-main small,
.coverage-list-meta small {
  color: var(--muted);
  margin-top: 3px;
}

.app-view {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.thread-sidebar {
  border-right: 1px solid var(--line);
  background: #fbfaf6;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

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

.sidebar-head h2 {
  font-size: 18px;
  margin: 0;
}

.thread-list {
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.thread-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.thread-item.active {
  border-color: #b9d7cf;
  background: var(--teal-soft);
}

.thread-open,
.thread-hide {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.thread-open strong,
.thread-open small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-open small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.thread-hide {
  color: var(--muted);
  font-size: 12px;
}

.chat-surface {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--paper);
}

.messages {
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.message {
  width: min(850px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px;
}

.message.user {
  justify-self: end;
  background: #fffaf0;
  border-color: #ead8af;
}

.message header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.message-content {
  line-height: 1.55;
}

.message-content p,
.message-content ul {
  margin: 0 0 12px;
}

.message-content p:last-child,
.message-content ul:last-child {
  margin-bottom: 0;
}

.message-content h3,
.message-content h4,
.message-content h5 {
  font-size: 16px;
  margin: 14px 0 8px;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 6px;
  padding: 1px 6px;
  background: #f4e9f0;
  color: var(--burgundy);
  font-weight: 800;
  text-decoration: none;
}

.sources {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.sources summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.sources ol {
  margin: 10px 0 0 18px;
  padding: 0;
}

.feedback {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.feedback button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  min-height: 30px;
  padding: 0 10px;
}

.feedback button.selected {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.feedback select {
  width: min(310px, 100%);
  min-height: 30px;
  padding: 4px 8px;
}

.chat-empty {
  width: min(640px, 100%);
  margin: 60px auto 0;
  text-align: center;
  color: var(--muted);
}

.chat-empty img {
  width: min(420px, 100%);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
}

.composer {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: relative;
}

.legislation-picker {
  position: relative;
}

.picker-toggle {
  width: 100%;
  min-height: 46px;
}

.question-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.chat-disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.picker-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(360px, 86vw);
  max-height: 340px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  z-index: 10;
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px;
  border-radius: 6px;
}

.check-row:hover {
  background: var(--teal-soft);
}

.check-row input {
  width: 16px;
  margin-top: 2px;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row small {
  color: var(--muted);
  margin-top: 2px;
}

.ask-button {
  min-height: 46px;
}

.admin-view {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.audit-item span {
  color: var(--muted);
}

button:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 920px) {
  .public-view {
    grid-template-columns: 1fr;
  }

  .workspace-visual {
    grid-row: auto;
    min-height: 260px;
  }

  .coverage-header {
    display: grid;
  }

  .app-view {
    height: auto;
    min-height: calc(100vh - 68px);
    grid-template-columns: 1fr;
  }

  .thread-sidebar {
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-surface {
    min-height: 620px;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 12px;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .topnav {
    width: 100%;
    flex-wrap: wrap;
  }

  .public-panel {
    padding: 18px;
  }

  .coverage-panel {
    padding: 18px;
  }

  .coverage-list {
    grid-template-columns: 1fr;
  }

  .public-panel h1 {
    font-size: 28px;
  }

  .app-view {
    min-height: calc(100vh - 116px);
  }

  .messages {
    padding: 14px;
  }

  .section-head,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }
}
