:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f1f4f7;
  --line: #d9dee7;
  --line-strong: #c2cad6;
  --text: #171a1f;
  --muted: #5d6673;
  --accent: #e95d18;
  --accent-strong: #c8480d;
  --accent-soft: #fff1e9;
  --success: #166f45;
  --success-soft: #e9f7ef;
  --warning: #8a6100;
  --warning-soft: #fff6dd;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.password-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.password-input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 93, 24, 0.14);
}

.password-input::placeholder {
  color: var(--muted);
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-muted);
}

.app-shell {
  width: min(100%, 1440px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
}

.topbar,
.stats-strip,
.toolbar,
.map-panel,
.list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.brand {
  min-width: 0;
}

.brand h1,
.toolbar-copy h2,
.section-header h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.35rem;
}

.toolbar-copy h2,
.section-header h2 {
  font-size: 1rem;
}

.eyebrow,
.map-label,
.stat-label {
  margin: 0 0 3px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-meta,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-meta span,
.status-pill,
.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1;
}

.link-button,
.primary-button,
.ghost-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 7px 10px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.link-button,
.ghost-button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.link-button:hover,
.ghost-button:hover {
  background: var(--surface-muted);
}

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

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

.stats-strip {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(150px, 0.7fr) minmax(280px, 2fr);
  gap: 0;
  overflow: hidden;
}

.stat-card,
.progress-card {
  min-width: 0;
  padding: 9px 12px;
  border-right: 1px solid var(--line);
}

.progress-card {
  border-right: 0;
}

.stat-card:last-child {
  border-right: 0;
}

.stat-card strong {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0;
}

.target-divider {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.progress-card {
  display: grid;
  gap: 7px;
}

.progress-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.progress-header .stat-label {
  margin-bottom: 0;
}

.progress-header strong {
  font-size: 0.9rem;
  line-height: 1;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.progress-card p {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.2;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-style: dashed;
  cursor: pointer;
}

.toolbar.is-dragover,
.toolbar:focus-visible {
  outline: 0;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.toolbar-copy {
  min-width: 0;
}

.toolbar-copy p:last-child {
  margin: 0;
  color: var(--muted);
}

.status-pill {
  color: var(--success);
  background: var(--success-soft);
  border-color: #c9e7d6;
}

.upload-dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: min(760px, calc(100vh - 24px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
}

.upload-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-panel {
  max-height: inherit;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
}

.dialog-header,
.dialog-actions,
.upload-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-header,
.dialog-actions {
  padding: 12px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2,
.upload-review-header h3,
.upload-preview-body h4 {
  margin: 0;
  letter-spacing: 0;
}

.dialog-header h2 {
  font-size: 1.05rem;
  line-height: 1.15;
}

.upload-form {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.field-label {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.upload-password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.upload-review {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
}

.upload-review-header h3 {
  font-size: 0.95rem;
  line-height: 1.2;
}

.upload-preview-list {
  min-height: 180px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.upload-preview-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.upload-preview-card img {
  width: 96px;
  height: 96px;
  display: block;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-muted);
}

.upload-preview-body {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
}

.upload-preview-body h4 {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.2;
}

.dialog-actions {
  border-top: 1px solid var(--line);
}

.workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 10px;
  align-items: stretch;
}

.map-panel,
.list-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.section-header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.map-notice {
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #ead79a;
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
  line-height: 1.4;
}

#map {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #e9eef2;
}

body.is-file-mode #map {
  background: #f5f0e8;
}

.results {
  min-height: 0;
  flex: 1;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.empty-state,
.result-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.empty-state {
  padding: 12px;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.result-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
}

.result-card img {
  width: 58px;
  height: 58px;
  display: block;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-muted);
}

.result-body {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.result-body h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.result-meta,
.result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.meta-chip {
  min-height: 22px;
  padding: 4px 6px;
  border-color: transparent;
  border-radius: 5px;
  background: var(--surface-muted);
}

.meta-chip.success {
  color: var(--success);
  background: var(--success-soft);
}

.meta-chip.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.focus-button {
  justify-self: start;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
}

.focus-button:hover {
  text-decoration: underline;
}

.exif-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  overflow: hidden;
}

.exif-table {
  display: grid;
  max-height: 260px;
  overflow: auto;
}

.exif-row {
  display: grid;
  grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
  gap: 8px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
}

.exif-row:last-child {
  border-bottom: 0;
}

.exif-key,
.exif-value,
.popup-exif-row {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

.exif-key,
.popup-exif-key {
  color: var(--accent-strong);
}

.exif-value,
.popup-exif-row {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exif-empty {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted);
}

.sticker-pin {
  position: relative;
  width: 38px;
  height: 46px;
  display: grid;
  place-items: start center;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.25));
}

.sticker-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: #ffffff;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  transform: translateX(-50%) rotate(45deg);
}

.sticker-pin-frame {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  padding: 2px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
}

.sticker-pin-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 999px;
  background: var(--surface-muted);
}

.sticker-cluster {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.25);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 700;
}

.sticker-cluster.medium {
  width: 48px;
  height: 48px;
}

.sticker-cluster.large {
  width: 54px;
  height: 54px;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.sticker-popup .leaflet-popup-content {
  width: min(280px, calc(100vw - 96px));
  margin: 10px;
}

.popup-card {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.popup-card img {
  width: 100%;
  height: 150px;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-muted);
}

.popup-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.popup-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.popup-exif {
  display: grid;
  gap: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.grid-label {
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 1040px) {
  .app-shell {
    height: auto;
  }

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

  #map {
    min-height: 520px;
  }

  .list-panel {
    max-height: 420px;
  }
}

@media (min-width: 1041px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
  }

  .workspace {
    height: calc(100vh - 248px);
    min-height: 360px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta,
  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-pill {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .password-input {
    width: 100%;
    grid-column: 1 / -1;
  }

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

  .dialog-actions,
  .upload-password-row {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    display: grid;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-card {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .stat-card:nth-child(2) {
    border-right: 0;
  }

  .stat-card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  #map {
    min-height: 430px;
  }
}

@media (max-width: 460px) {
  .topbar-meta span {
    display: none;
  }

  .upload-preview-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .upload-preview-card img {
    width: 72px;
    height: 72px;
  }
}
