:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --fg: #1f2933;
  --accent: #2563eb;
  --border: #d2d6dc;
  --shadow: rgba(17, 24, 39, 0.1);
  --radius: 12px;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
}

:root.theme-light {
  --bg: #f7f7f8;
  --fg: #1f2933;
  --border: #d2d6dc;
  --shadow: rgba(17, 24, 39, 0.1);
}

:root.theme-dark {
  --bg: #0f172a;
  --fg: #f8fafc;
  --border: #1e293b;
  --shadow: rgba(15, 23, 42, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light):not(.theme-dark) {
    --bg: #0f172a;
    --fg: #f8fafc;
    --border: #1e293b;
    --shadow: rgba(15, 23, 42, 0.35);
  }
}

body {
  margin: 0;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 320px) var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  padding: 2.25rem 1rem 1.5rem;
}

.header h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem);
}

.tagline {
  margin: 0 auto;
  max-width: 48rem;
  line-height: 1.6;
  opacity: 0.82;
}

.header__controls {
  margin-top: 1.5rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(37, 99, 235, 0.08);
  padding: 0.4rem;
  border-radius: 999px;
}

.lang-switcher__btn {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.lang-switcher__btn.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.theme-toggle {
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.38rem 1rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.main {
  width: min(960px, 90vw);
  margin: 0 auto 2.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.uploader {
  border: 1.5px dashed rgba(37, 99, 235, 0.35);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  background: rgba(37, 99, 235, 0.04);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 18px 45px -24px var(--shadow);
}

.uploader.dragover {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.uploader__cta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.uploader__hint {
  margin: 0;
  opacity: 0.7;
}

.uploader__note {
  margin-top: 1.5rem;
  line-height: 1.7;
  opacity: 0.68;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
}

.button:active {
  transform: translateY(1px);
}

.button input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.results {
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  border: 1px solid rgba(37, 99, 235, 0.1);
  padding: 1.75rem;
  box-shadow: 0 10px 35px -18px var(--shadow);
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .results {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(148, 163, 184, 0.16);
  }
}

:root.theme-dark .results {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148, 163, 184, 0.16);
}

.results h2 {
  margin-top: 0;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}

.results__content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.placeholder {
  margin: 0;
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  background: rgba(148, 163, 184, 0.12);
  color: inherit;
  opacity: 0.7;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 40px -22px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .card {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.18);
  }
}

:root.theme-dark .card {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.18);
}

.card__content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.card__header h3 {
  margin: 0;
  font-size: 1.1rem;
  word-break: break-word;
  flex: 1;
}

.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .badge {
    background: rgba(96, 165, 250, 0.22);
    color: #bfdbfe;
  }
}

:root.theme-dark .badge {
  background: rgba(96, 165, 250, 0.22);
  color: #bfdbfe;
}

.card__actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.copy-json-button {
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.copy-json-button:hover {
  background: var(--accent);
  color: #fff;
}

.strip-metadata-button {
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.strip-metadata-button:hover {
  background: var(--accent);
  color: #fff;
}

.card__section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card__section h4 {
  margin: 0;
  font-size: 1rem;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.preview__image {
  max-width: 100%;
  max-height: 360px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  object-fit: contain;
  box-shadow: 0 10px 25px -20px var(--shadow);
}

.preview__placeholder {
  margin: 0;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(148, 163, 184, 0.15);
  text-align: center;
  opacity: 0.85;
}

.preview__thumbnail {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.85rem;
  color: rgba(31, 41, 55, 0.75);
}

.preview__thumbnail img {
  max-width: 160px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 6px 16px -12px var(--shadow);
}

.metadata-section {
  gap: 1.5rem;
}

.metadata__groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.metadata__group {
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .metadata__group {
    background: rgba(15, 23, 42, 0.45);
    border-color: rgba(148, 163, 184, 0.22);
  }
}

:root.theme-dark .metadata__group {
  background: rgba(15, 23, 42, 0.45);
  border-color: rgba(148, 163, 184, 0.22);
}

.metadata__category {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--accent);
}

.metadata__entries {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.metadata__entry {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metadata__tag {
  font-weight: 600;
}

.metadata__tag::after {
  content: "：";
  margin-left: 0.25rem;
  color: rgba(37, 99, 235, 0.9);
}

.metadata__value {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(148, 163, 184, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metadata__valueText {
  white-space: pre-wrap;
  word-break: break-word;
}

.metadata__valueText.is-collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.metadata__valueToggle {
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.metadata__valueToggle:hover {
  text-decoration: underline;
}

.embedded-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.embedded-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}

.embedded-item img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  object-fit: cover;
}

.embedded-item span {
  font-size: 0.85rem;
  opacity: 0.8;
}

.map__coords {
  margin: 0 0 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.map-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px -20px var(--shadow);
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.map-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.risk-section {
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.risk-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.risk-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.risk-item__label {
  font-weight: 600;
}

.risk-item__badge {
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
}

.risk-item--high .risk-item__badge {
  background: #dc2626;
}

.risk-item--medium .risk-item__badge {
  background: #f59e0b;
}

.risk-item--low .risk-item__badge {
  background: #16a34a;
}

.risk-item__detail {
  color: rgba(31, 41, 55, 0.75);
  font-size: 0.85rem;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .risk-section {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(148, 163, 184, 0.3);
  }

  :root:not(.theme-light) .risk-item__detail {
    color: rgba(226, 232, 240, 0.85);
  }
}

:root.theme-dark .risk-section {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(148, 163, 184, 0.3);
}

:root.theme-dark .risk-item__detail {
  color: rgba(226, 232, 240, 0.85);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.status svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.status.processing {
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

.status.error {
  color: #dc2626;
}

.status.success {
  color: #059669;
}

.alert {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  box-shadow: 0 10px 30px var(--shadow);
}

.alert--error {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .alert--error {
    background: rgba(220, 38, 38, 0.18);
    border-color: rgba(220, 38, 38, 0.4);
    color: #fecaca;
  }
}

:root.theme-dark .alert--error {
  background: rgba(220, 38, 38, 0.18);
  border-color: rgba(220, 38, 38, 0.4);
  color: #fecaca;
}

.footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  opacity: 0.75;
  font-size: 0.85rem;
}

.footer__link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.footer__link:hover {
  text-decoration: underline;
}

.noscript {
  margin: 0;
  padding: 1rem;
  text-align: center;
  background: #f87171;
  color: #fff;
}

@media (max-width: 640px) {
  .header__controls {
    width: 100%;
  }

  .results {
    padding: 1.25rem;
  }

  .card {
    padding: 1.25rem;
  }

  .uploader {
    padding: 2.5rem 1.5rem;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}
