:root {
  color-scheme: light dark;
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f6f7f9;
  --text: #20242a;
  --muted: #626a75;
  --line: #d9dde3;
  --line-strong: #bfc5ce;
  --accent: #246fd3;
  --accent-hover: #185bb4;
  --accent-soft: #eaf2fd;
  --success: #16834d;
  --focus: #84b8ff;
  --shadow: 0 16px 44px rgba(22, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 280px;
  margin: 0;
  padding: 32px 20px 48px;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
#mapOutput:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

#wrapper {
  width: min(880px, 100%);
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 34px 34px 26px;
  text-align: center;
}

.eyebrow,
.result-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.65rem);
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.subtitle {
  max-width: 620px;
  margin: 12px auto 0;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 0 34px;
  padding: 5px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.tab {
  min-height: 44px;
  padding: 9px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 680;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(22, 31, 43, 0.13);
}

#mapPanel {
  padding: 24px 34px 34px;
}

.explanation {
  min-height: 49px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

code {
  padding: 0.08em 0.3em;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.92em;
}

.upload-area {
  min-height: 150px;
  border: 2px dashed var(--line-strong);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-area:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.upload-area.dragover {
  transform: scale(1.006);
}

.fileInputLabel {
  min-height: 146px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
  text-align: center;
}

.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 9px;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 700;
}

.upload-title {
  font-weight: 720;
}

.upload-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

#folderPath {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.privacy-note {
  margin: 12px 0 0;
  color: var(--success);
  font-size: 0.86rem;
}

.privacy-note span {
  margin-right: 5px;
  font-size: 0.6rem;
  vertical-align: 0.12em;
}

.result {
  margin-top: 26px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.result-kicker {
  color: var(--muted);
}

.result-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.copy-button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 10px 17px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

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

.copy-button:disabled {
  cursor: wait;
  opacity: 0.56;
}

.analysis-note {
  margin: 0 0 9px;
  padding: 9px 11px;
  background: #fff8df;
  border: 1px solid #eadb9e;
  border-radius: 7px;
  color: #685719;
  font-size: 0.84rem;
}

#mapOutput {
  width: 100%;
  min-height: 300px;
  max-height: min(64vh, 680px);
  margin: 0;
  overflow: auto;
  padding: 17px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: 0.87rem/1.52 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
  white-space: pre;
}

footer {
  width: min(880px, 100%);
  margin: 32px auto 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

footer p {
  margin: 0 0 8px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 1rem;
}

footer a {
  color: inherit;
  text-decoration: none;
}

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

@media (max-width: 620px) {
  body {
    padding: 14px 10px 32px;
  }

  #wrapper {
    border-radius: 11px;
  }

  .hero {
    padding: 27px 18px 20px;
  }

  .tabs {
    margin: 0 14px;
  }

  .tab {
    padding-inline: 7px;
    font-size: 0.9rem;
  }

  #mapPanel {
    padding: 19px 14px 25px;
  }

  .explanation {
    min-height: 0;
  }

  .result-header {
    align-items: flex-end;
  }

  .copy-button {
    padding-inline: 13px;
    font-size: 0.88rem;
  }

  #mapOutput {
    min-height: 260px;
    padding: 13px;
    font-size: 0.79rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.32rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #15171a;
    --surface: #202327;
    --surface-muted: #292d32;
    --text: #edf0f4;
    --muted: #a8afb9;
    --line: #383e46;
    --line-strong: #505864;
    --accent: #65a7ff;
    --accent-hover: #4a94f5;
    --accent-soft: #203b5b;
    --success: #67d99b;
    --focus: #77b1ff;
    --shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
  }

  .copy-button {
    background: #287bdc;
  }

  .copy-button:hover {
    background: #1f68bc;
  }

  .analysis-note {
    background: #3a3219;
    border-color: #66592c;
    color: #ead68a;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
