/* ─── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-secondary: #f1f3f5;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --accent: #228be6;
  --accent-hover: #1c7ed6;
  --gps-bg: #fff5f5;
  --gps-border: #ffa8a8;
  --gps-text: #c92a2a;
  --gps-title: #e03131;
  --section-camera: #1971c2;
  --section-shooting: #2f9e44;
  --section-datetime: #e67700;
  --section-gps: #c92a2a;
  --section-image: #7048e8;
  --section-other: #495057;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.15s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-secondary: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --gps-bg: #2d1515;
  --gps-border: #7a2020;
  --gps-text: #ff8080;
  --gps-title: #ff6b6b;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
    'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.header-brand h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.icon-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ─── Landing / Drop zone ───────────────────────────────────────────────────── */
#landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.drop-zone-wrapper {
  width: 100%;
  max-width: 560px;
}

#drop-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  user-select: none;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-card));
  transform: scale(1.01);
}

.drop-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

#drop-zone-text {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

#supported-formats {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: 99px;
}

.privacy-note {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.privacy-note svg {
  flex-shrink: 0;
}

/* ─── Result area ───────────────────────────────────────────────────────────── */
#result-area {
  display: none;
}

.result-top {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

#image-preview {
  display: none;
  max-width: 200px;
  max-height: 200px;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
  background: var(--bg-secondary);
  box-shadow: var(--shadow);
}

.result-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: flex-end;
  min-width: 180px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.action-btn:hover { transform: translateY(-1px); }
.action-btn:active { transform: translateY(0); }

#strip-btn {
  background: var(--accent);
  color: #fff;
  display: none;
}
#strip-btn:hover { background: var(--accent-hover); }

#new-image-btn {
  display: none;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-color: var(--border);
}
#new-image-btn:hover { background: var(--border); color: var(--text); }

#strip-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── GPS Warning ───────────────────────────────────────────────────────────── */
#gps-warning {
  display: none;
  background: var(--gps-bg);
  border: 1.5px solid var(--gps-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
  align-items: flex-start;
}

.gps-warning-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.gps-warning-body { flex: 1; }

.gps-warning-title {
  font-weight: 700;
  color: var(--gps-title);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.gps-warning-text {
  font-size: 0.82rem;
  color: var(--gps-text);
  line-height: 1.5;
}

#map-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--gps-title);
  text-decoration: none;
  font-weight: 600;
}
#map-link:hover { text-decoration: underline; }

/* ─── No EXIF message ───────────────────────────────────────────────────────── */
#no-exif {
  display: none;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.no-exif-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.no-exif-msg { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
.no-exif-hint { font-size: 0.82rem; }

/* ─── Tag sections ──────────────────────────────────────────────────────────── */
#results { display: none; }

.tag-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.section-title::-webkit-details-marker { display: none; }
.section-title::marker { display: none; }

.section-title::before {
  content: '▼';
  font-size: 0.65rem;
  transition: transform var(--transition);
  color: var(--text-muted);
}

details:not([open]) .section-title::before {
  transform: rotate(-90deg);
}

.section-title::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  order: -1;
}

.section-camera { color: var(--section-camera); }
.section-camera::after { background: var(--section-camera); }
.section-shooting { color: var(--section-shooting); }
.section-shooting::after { background: var(--section-shooting); }
.section-datetime { color: var(--section-datetime); }
.section-datetime::after { background: var(--section-datetime); }
.section-gps { color: var(--section-gps); }
.section-gps::after { background: var(--section-gps); }
.section-image { color: var(--section-image); }
.section-image::after { background: var(--section-image); }
.section-other { color: var(--section-other); }
.section-other::after { background: var(--section-other); }

.gps-badge {
  margin-left: auto;
  background: var(--gps-bg);
  color: var(--gps-title);
  border: 1px solid var(--gps-border);
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ─── Tag table ─────────────────────────────────────────────────────────────── */
.tag-table {
  width: 100%;
  border-collapse: collapse;
}

.tag-table tr:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.tag-table td {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  vertical-align: top;
}

.tag-label {
  color: var(--text-muted);
  white-space: nowrap;
  width: 40%;
  max-width: 200px;
  font-size: 0.8rem;
}

.tag-value {
  color: var(--text);
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

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

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .header { flex-wrap: wrap; gap: 0.5rem; }
  .result-top { flex-direction: column; align-items: center; }
  #image-preview { max-width: 100%; max-height: 160px; width: 100%; }
  .result-actions { width: 100%; }
  .tag-label { width: 44%; font-size: 0.75rem; }
  .action-btn { width: 100%; justify-content: center; }
}
