:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ec;
  --ink: #1e2521;
  --muted: #677269;
  --line: #dfe5de;
  --accent: #2f6f68;
  --accent-dark: #1f514c;
  --accent-soft: #dbece7;
  --amber: #9b6b21;
  --amber-soft: #f4ead8;
  --danger: #9a3d35;
  --danger-soft: #f4dfdc;
  --shadow: 0 18px 48px rgba(34, 48, 41, 0.08);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: #17211d;
  color: #f5f7f2;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: #24342f;
  color: #dceee8;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: #aab8af;
  font-size: 12px;
  line-height: 1.4;
}

.steps {
  display: grid;
  gap: 6px;
}

.step {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 8px;
  color: #c8d2ca;
  text-decoration: none;
}

.step:hover,
.step.is-active {
  background: #24342f;
  color: #ffffff;
}

.step span {
  color: #819188;
  font-size: 12px;
  font-weight: 700;
}

.step strong {
  font-size: 13px;
  font-weight: 650;
}

.sidebar-summary {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-summary dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

.sidebar-summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-summary dt {
  color: #aab8af;
  font-size: 12px;
}

.sidebar-summary dd {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
}

.workspace {
  min-width: 0;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.topbar {
  order: 0;
}

.review-panel {
  order: 1;
}

#summary {
  order: 2;
}

#taste {
  order: 3;
}

#archive {
  order: 4;
}

#export {
  order: 5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.topbar h2 {
  max-width: 820px;
  margin: 4px 0 0;
  font-size: clamp(26px, 4vw, 46px);
  line-height: 1.04;
  font-weight: 780;
}

.system-status {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.topbar-actions,
.export-actions,
.detail-actions,
.review-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.run-select-field {
  min-width: min(360px, 42vw);
  display: grid;
  gap: 4px;
}

.run-select-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.run-select-field select {
  height: 36px;
  max-width: 100%;
  font-weight: 680;
}

.compact-field {
  min-width: 190px;
}

.compact-field span {
  margin-bottom: 4px;
  font-size: 11px;
}

.compact-field select {
  height: 36px;
}

#csv-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button,
.ghost-button,
.file-button,
.tab-button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.file-button,
.tab-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover,
.file-button:hover,
.tab-button:hover,
.tab-button.is-active {
  border-color: #b8c5bb;
  background: var(--surface-muted);
}

.ghost-button:disabled,
.tab-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.section-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel h3,
.detail-panel h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.import-panel textarea,
.background-panel textarea,
.export-panel textarea,
.ai-panel textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fbfcfa;
  line-height: 1.45;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.export-panel textarea {
  min-height: 170px;
}

.ai-panel textarea {
  min-height: 260px;
}

.background-panel textarea {
  min-height: 210px;
}

.background-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.background-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.background-summary p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.background-list {
  display: grid;
  gap: 8px;
  max-height: 150px;
  overflow: auto;
  color: var(--ink);
  font-size: 12px;
}

.background-list span {
  display: block;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.panel-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.import-help {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.import-help div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.import-help strong,
.import-help span {
  display: block;
}

.import-help strong {
  font-size: 12px;
  margin-bottom: 3px;
}

.import-help span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

label span,
.category-filter legend {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fbfcfa;
  color: var(--ink);
}

.category-filter {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.category-filter legend {
  grid-column: 1 / -1;
}

.category-filter label,
.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-size: 13px;
}

.vibe-field {
  display: block;
  margin-top: 14px;
}

.toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.run-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-grid div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid strong {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.summary-grid span {
  font-size: 14px;
  line-height: 1.4;
}

.notes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.notes p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.archive-list {
  display: grid;
}

.archive-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.archive-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.archive-row:last-child {
  padding-bottom: 0;
}

.archive-row.is-current {
  color: var(--accent-dark);
}

.archive-row strong,
.archive-row span {
  display: block;
}

.archive-row strong {
  font-size: 14px;
}

.archive-row span,
.archive-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.archive-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf7;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td {
  font-size: 13px;
  line-height: 1.4;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfa;
}

tbody tr.is-selected {
  background: #fbfcfa;
  box-shadow: inset 3px 0 0 var(--accent);
}

.place-title,
.rec-title {
  display: grid;
  gap: 3px;
}

.place-title strong,
.rec-title strong {
  font-size: 14px;
}

.place-title a,
.rec-title a {
  color: var(--accent-dark);
  font-size: 12px;
}

.rec-address {
  color: var(--muted);
  font-size: 12px;
}

.rec-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rec-summary {
  display: none;
}

.pill-row,
.chip-list,
.detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-muted);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 760;
}

.status-pill {
  background: var(--accent-soft);
}

.status-pill.inferred {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.rejected {
  background: var(--danger-soft);
  color: var(--danger);
}

.profile-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.ai-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
}

.signal-block + .signal-block {
  margin-top: 16px;
}

.signal-block h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.map-panel {
  min-height: 330px;
}

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

.imported-dot {
  background: var(--ink);
}

.rec-dot {
  background: var(--accent);
}

.background-dot {
  background: var(--amber);
}

.map-canvas {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(47, 111, 104, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 111, 104, 0.08) 1px, transparent 1px),
    #fbfcfa;
  background-size: 42px 42px;
}

.map-point {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 10px rgba(23, 33, 29, 0.2);
}

.map-point.saved {
  background: var(--ink);
}

.map-point.recommended {
  background: var(--accent);
}

.map-point.background {
  background: var(--amber);
}

.map-label {
  position: absolute;
  transform: translate(8px, -50%);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.recommendation-table table {
  min-width: 900px;
}

.decision-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.decision-buttons button,
.reject-reasons button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.decision-buttons button:hover,
.reject-reasons button:hover {
  background: var(--surface-muted);
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfa;
  align-self: start;
  position: sticky;
  top: 18px;
}

.detail-panel h3 {
  margin-top: 2px;
}

#detail-meta {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-copy {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.detail-copy p {
  margin: 0;
}

.detail-copy ul {
  margin: 0;
  padding-left: 18px;
}

.detail-copy li {
  margin: 4px 0;
}

.detail-actions {
  margin-top: 16px;
}

.reject-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.confidence {
  display: grid;
  gap: 5px;
  min-width: 120px;
}

.confidence-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.confidence-meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.confidence small {
  color: var(--muted);
  font-weight: 720;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
  }

  .steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .sidebar-summary {
    grid-column: 1 / -1;
    margin-top: 0;
    padding: 12px;
  }

  .sidebar-summary dl {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-summary div {
    display: grid;
    gap: 3px;
    justify-content: start;
  }

  .layout-grid,
  .profile-grid,
  .ai-grid,
  .background-grid,
  .summary-grid,
  .archive-row,
  .review-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 840px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    gap: 12px;
  }

  .brand {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p,
  .sidebar-summary {
    display: none;
  }

  .steps {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .steps::-webkit-scrollbar {
    display: none;
  }

  .step {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    min-height: 34px;
    padding: 0 13px;
  }

  .step span {
    display: none;
  }

  .step strong {
    font-size: 12px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .topbar h2 {
    font-size: 25px;
    line-height: 1.12;
  }

  .system-status {
    font-size: 12px;
  }

  .topbar {
    order: 0;
  }

  .review-panel {
    order: 1;
  }

  #summary {
    order: 2;
  }

  #archive {
    order: 4;
  }

  #taste {
    order: 3;
  }

  #export {
    order: 5;
  }

  .panel {
    padding: 14px;
  }

  .steps,
  .control-grid,
  .category-filter,
  .import-help {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .export-actions,
  .archive-actions {
    align-items: stretch;
  }

  .topbar-actions,
  .review-tabs,
  .export-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .run-select-field {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .review-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .primary-button,
  .ghost-button,
  .file-button,
  .tab-button {
    width: 100%;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-grid div {
    min-height: 0;
    padding: 12px;
  }

  .run-meta {
    text-align: left;
  }

  .map-panel {
    display: none;
  }

  .review-layout {
    display: grid;
    gap: 14px;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-collapse: separate;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(34, 48, 41, 0.06);
  }

  tbody tr:last-child {
    margin-bottom: 0;
  }

  tbody tr.is-selected {
    background: #fbfcfa;
    box-shadow:
      inset 3px 0 0 var(--accent),
      0 10px 28px rgba(34, 48, 41, 0.06);
  }

  td {
    padding: 9px 0;
    border-bottom: 0;
  }

  td:not(.spot-cell)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .spot-cell {
    padding-top: 0;
  }

  .rec-title {
    gap: 6px;
  }

  .rec-title strong {
    font-size: 17px;
    line-height: 1.22;
  }

  .rec-links {
    margin-top: 2px;
  }

  .rec-summary {
    display: block;
    margin: 4px 0 0;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
  }

  .pill-row {
    gap: 5px;
  }

  .confidence {
    min-width: 0;
  }

  .decision-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .decision-buttons button {
    width: 100%;
    padding: 0 7px;
  }

  .status-pill {
    margin-top: 8px;
  }

  .detail-panel {
    display: none;
  }
}
