:root {
  --bg: #F6F2EB;
  --bg-soft: #FAF7F2;
  --surface: #FFFFFF;
  --border: #E8E0D2;
  --border-soft: #F0E9DD;
  --text: #25303D;
  --text-2: #4B5563;
  --muted: #8A8E97;
  --accent: #4E7CB0;
  --accent-hover: #3F6A99;
  --accent-soft: #E8F0F8;
  --accent-2: #C77D55;
  --success: #4F8C5C;
  --danger: #C0524C;
  --shadow-sm: 0 1px 2px rgba(37, 48, 61, 0.05);
  --shadow-md: 0 4px 16px rgba(37, 48, 61, 0.06);
  --shadow-lg: 0 12px 32px rgba(37, 48, 61, 0.08);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, #EFE6D6 0%, rgba(239, 230, 214, 0) 60%),
    radial-gradient(900px 500px at 100% 0%, #E8EEF6 0%, rgba(232, 238, 246, 0) 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  padding: 36px 20px 28px;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  align-items: center;
}
.hero-portrait {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(135deg, #2A323D 0%, #1A2028 100%);
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--surface);
  position: relative;
  flex-shrink: 0;
}
.hero-portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-lg) - 4px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.hero-copy { min-width: 0; }
.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.site-header h1 {
  margin: 0 0 10px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
}
.tagline {
  margin: 0;
  color: var(--text-2);
  max-width: 620px;
  font-size: 16px;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-md);
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.panel-meta, .panel-action { grid-column: 1 / -1; }

/* ---------- Image panel ---------- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  transition: border-color 0.18s ease, background 0.18s ease;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 20px;
  cursor: pointer;
  text-align: center;
  min-height: 160px;
}
.file-label input[type="file"] { display: none; }
.file-label-main {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.file-label-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

.preview-wrap {
  margin-top: 16px;
  text-align: center;
}
.preview-wrap img {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}
.file-info { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

.hidden { display: none !important; }

/* ---------- Map panel ---------- */
.map-search {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.map-search input,
.coords input,
.field textarea,
.field input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.map-search input {
  flex: 1;
  padding: 10px 14px;
}
.map-search input:focus,
.coords input:focus,
.field textarea:focus,
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.map-search button,
.download-btn {
  background: var(--accent);
  border: none;
  color: white;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.map-search button {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.map-search button:hover { background: var(--accent-hover); }
.map-search button:active { transform: translateY(1px); }

.search-results {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.search-results .result {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-2);
  transition: background 0.1s ease;
}
.search-results .result:last-child { border-bottom: none; }
.search-results .result:hover { background: var(--accent-soft); color: var(--text); }

#map {
  height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.leaflet-container { font-family: inherit; }

.coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.coords label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.coords input {
  padding: 9px 12px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

/* ---------- Meta panel ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}
.field:last-child { margin-bottom: 0; }
.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.field em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}
.field textarea,
.field input[type="text"] {
  padding: 10px 14px;
  resize: vertical;
}
.counter {
  align-self: flex-end;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.counter.over { color: var(--danger); font-weight: 600; }

/* ---------- Action panel ---------- */
.panel-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
}
.download-btn {
  padding: 13px 32px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 12px rgba(78, 124, 176, 0.25);
}
.download-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(78, 124, 176, 0.32);
}
.download-btn:active:not(:disabled) { transform: translateY(1px); }
.download-btn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
}
.status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}
.status.success { color: var(--success); font-weight: 500; }
.status.error { color: var(--danger); font-weight: 500; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px 20px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.site-footer a { color: var(--text-2); }

/* ---------- Tabs bar ---------- */
.tabs-bar {
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
}
.tab {
  padding: 14px 18px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- Viewer single-column ---------- */
.layout-single { grid-template-columns: 1fr; }

/* ---------- Viewer results panel ---------- */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; }
.meta-actions { display: flex; gap: 6px; }
.link-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.link-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.link-btn.hidden { display: none; }

.cat {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-soft);
}
.cat:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cat h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cat p { margin: 0; font-size: 14px; }
.cat a { font-weight: 500; }
.kv {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px 16px;
  margin: 0;
}
.kv dt {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  padding: 2px 0;
}
.kv dd {
  font-size: 13px;
  margin: 0;
  color: var(--text);
  word-break: break-word;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.kv code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}
.muted { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .header-inner {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 20px;
  }
  .hero-portrait {
    margin: 0 auto;
    width: 180px;
    height: 180px;
  }
  .site-header h1 { font-size: 32px; }
  .layout { grid-template-columns: 1fr; }
  #map { height: 280px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; padding-bottom: 0; }
  .kv dt:first-child { margin-top: 0; }
}
