*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.seo-site-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --color-primary: #c0392b;
  --color-primary-dark: #962d22;
  --color-secondary: #2c3e50;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-danger: #e74c3c;
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #2c3e50;
  --color-text-muted: #7f8c8d;
  --color-border: #dfe6e9;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --font-size-base: 16px;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Tools page top bar */
.tools-topbar {
  background: var(--color-primary);
  color: #fff;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tools-topbar h1 {
  font-size: 1.125rem;
  margin: 0;
}

.back-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0.95;
}

.back-link:hover {
  text-decoration: underline;
}


/* Tab Navigation */
.tab-nav {
  display: flex;
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  padding: 0.875rem 0.5rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* Main Content */
main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

#panel-alerts.active,
#panel-history.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.panel-header h2 {
  font-size: var(--font-size-lg);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
}

.list-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.5rem 0 0.4rem;
}

.list-heading {
  font-size: 1rem;
  margin: 0;
}

.area-filter-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff5f5;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  padding: 0.375rem 0.5rem 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: var(--color-primary-dark);
  font-weight: 600;
}

.area-filter-banner[hidden] {
  display: none;
}

/* Earthquake Map */
.map-wrapper {
  position: relative;
  margin-bottom: 0.75rem;
}

.earthquake-map {
  width: 100%;
  height: 380px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1;
}

.map-reset-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 0.375rem 0.625rem;
  border: none;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-reset-btn:hover {
  background: var(--color-bg);
}

.map-reset-btn:active {
  transform: scale(0.97);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-fault {
  width: 14px;
  height: 4px;
  display: inline-block;
  background: #c0392b;
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.25);
}

.legend-plate {
  width: 14px;
  height: 0;
  display: inline-block;
  border-top: 3px solid #0d47a1;
  border-radius: 1px;
}

.map-popup-source {
  margin-top: 0.35rem !important;
  font-size: 0.6875rem !important;
  opacity: 0.75;
}

.geo-info-popup .leaflet-popup-content {
  margin: 0.65rem 0.85rem;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.fault-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  user-select: none;
}

.fault-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #c0392b;
}

.map-popup {
  font-size: 0.8125rem;
  line-height: 1.5;
}

.map-popup p {
  margin: 0.125rem 0;
  font-size: 0.75rem;
}

.eq-marker {
  background: transparent;
  border: none;
}

.eq-highlight-marker {
  background: transparent;
  border: none;
}

.eq-pin {
  position: relative;
  width: 36px;
  height: 48px;
}

.eq-pin-pulse {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 50%;
  background: rgba(192, 57, 43, 0.3);
  animation: eq-pulse 1.5s ease-out infinite;
}

.eq-pin-head {
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  background: var(--color-primary);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.eq-pin-arrow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 0;
  height: 0;
  margin-left: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--color-primary);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

@keyframes eq-pulse {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.eq-list-item {
  cursor: pointer;
  transition: transform 0.1s;
}

.eq-list-item:hover,
.eq-list-item:focus,
.eq-list-item.selected {
  transform: translateX(2px);
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.eq-list-item.selected {
  border-left-width: 6px;
  background: #fff5f5;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  align-items: flex-end;
  background: var(--color-surface);
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.5rem;
}

.period-presets {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  width: 100%;
  margin-bottom: 0;
}

.intensity-presets {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
  margin-bottom: 0;
}

.preset-label {
  flex: 0 0 auto;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-right: 0.1rem;
}

.period-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  gap: 0.25rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #fff;
  color: var(--color-text);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.intensity-btn {
  display: inline-flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  gap: 0.2rem;
  justify-content: center;
  padding: 0.3rem 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.period-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.period-btn.active {
  border-color: #1f4e79;
  background: #1f4e79;
  color: #fff;
}

/* 期間ボタンの色分け */
.period-btn[data-period="today"] {
  border-color: #27ae60;
  background: #eafaf1;
  color: #1e8449;
}
.period-btn[data-period="today"] .period-count {
  background: #27ae60;
  color: #fff;
}
.period-btn[data-period="today"]:hover { background: #d5f5e3; }
.period-btn[data-period="today"].active {
  background: #27ae60;
  border-color: #1e8449;
  color: #fff;
}

.period-btn[data-period="24h"] {
  border-color: #2980b9;
  background: #ebf5fb;
  color: #1a5276;
}
.period-btn[data-period="24h"] .period-count {
  background: #2980b9;
  color: #fff;
}
.period-btn[data-period="24h"]:hover { background: #d4e6f1; }
.period-btn[data-period="24h"].active {
  background: #2980b9;
  border-color: #1a5276;
  color: #fff;
}

.period-btn[data-period="7d"] {
  border-color: #8e44ad;
  background: #f5eef8;
  color: #6c3483;
}
.period-btn[data-period="7d"] .period-count {
  background: #8e44ad;
  color: #fff;
}
.period-btn[data-period="7d"]:hover { background: #e8daef; }
.period-btn[data-period="7d"].active {
  background: #8e44ad;
  border-color: #6c3483;
  color: #fff;
}

.period-btn[data-period="30d"] {
  border-color: #16a085;
  background: #e8f8f5;
  color: #0e6655;
}
.period-btn[data-period="30d"] .period-count {
  background: #16a085;
  color: #fff;
}
.period-btn[data-period="30d"]:hover { background: #d1f2eb; }
.period-btn[data-period="30d"].active {
  background: #16a085;
  border-color: #0e6655;
  color: #fff;
}

/* 震度ボタンの色分け（地図マーカーと同系統） */
.intensity-btn[data-scale="1"] {
  border-color: #7f8c8d;
  background: #f0f3f4;
  color: #566573;
}
.intensity-btn[data-scale="1"] .period-count {
  background: #95a5a6;
  color: #fff;
}
.intensity-btn[data-scale="1"]:hover { background: #e5e8e8; }
.intensity-btn[data-scale="1"].active {
  background: #95a5a6;
  border-color: #7f8c8d;
  color: #fff;
}

.intensity-btn[data-scale="2"] {
  border-color: #2980b9;
  background: #ebf5fb;
  color: #1a5276;
}
.intensity-btn[data-scale="2"] .period-count {
  background: #3498db;
  color: #fff;
}
.intensity-btn[data-scale="2"]:hover { background: #d6eaf8; }
.intensity-btn[data-scale="2"].active {
  background: #3498db;
  border-color: #2471a3;
  color: #fff;
}

.intensity-btn[data-scale="3"] {
  border-color: #d4ac0d;
  background: #fef9e7;
  color: #7d6608;
}
.intensity-btn[data-scale="3"] .period-count {
  background: #f1c40f;
  color: #3d3200;
}
.intensity-btn[data-scale="3"]:hover { background: #fcf3cf; }
.intensity-btn[data-scale="3"].active {
  background: #f1c40f;
  border-color: #d4ac0d;
  color: #3d3200;
}
.intensity-btn[data-scale="3"].active .period-count {
  background: rgba(0, 0, 0, 0.18);
  color: #3d3200;
}

.intensity-btn[data-scale="4"] {
  border-color: #d68910;
  background: #fef5e7;
  color: #9a7b0a;
}
.intensity-btn[data-scale="4"] .period-count {
  background: #f39c12;
  color: #fff;
}
.intensity-btn[data-scale="4"]:hover { background: #fdebd0; }
.intensity-btn[data-scale="4"].active {
  background: #f39c12;
  border-color: #d68910;
  color: #fff;
}

.intensity-btn[data-scale="5"] {
  border-color: #ca6f1e;
  background: #fdf2e9;
  color: #a04000;
}
.intensity-btn[data-scale="5"] .period-count {
  background: #e67e22;
  color: #fff;
}
.intensity-btn[data-scale="5"]:hover { background: #fae5d3; }
.intensity-btn[data-scale="5"].active {
  background: #e67e22;
  border-color: #ca6f1e;
  color: #fff;
}

.intensity-btn[data-scale="6"] {
  border-color: #922b21;
  background: #fdedec;
  color: #922b21;
}
.intensity-btn[data-scale="6"] .period-count {
  background: #c0392b;
  color: #fff;
}
.intensity-btn[data-scale="6"]:hover { background: #f5b7b1; }
.intensity-btn[data-scale="6"].active {
  background: #c0392b;
  border-color: #922b21;
  color: #fff;
}

.intensity-btn[data-scale="7"] {
  border-color: #5d0000;
  background: #f9ebea;
  color: #7b0000;
}
.intensity-btn[data-scale="7"] .period-count {
  background: #7b0000;
  color: #fff;
}
.intensity-btn[data-scale="7"]:hover { background: #f5c6c4; }
.intensity-btn[data-scale="7"].active {
  background: #7b0000;
  border-color: #5d0000;
  color: #fff;
}

.period-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  padding: 0.05rem 0.25rem;
  border-radius: 999px;
  background: #eef2f6;
  color: #1f4e79;
  font-size: 0.625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.period-btn.active .period-count,
.intensity-btn.active .period-count {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.intensity-btn[data-scale="3"].active .period-count {
  background: rgba(0, 0, 0, 0.18);
  color: #3d3200;
}

.filter-result-count {
  width: 100%;
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: #1f4e79;
}

.list-result-count {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--color-text-muted);
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.625rem;
  color: var(--color-text-muted);
  gap: 0.1rem;
}

.filter-bar select,
.filter-bar input[type="date"] {
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  max-width: 100%;
}

/* Import Progress */
.import-progress {
  background: var(--color-surface);
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

.import-progress-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.import-progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s;
}

.import-message {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.section-desc {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.meta-text {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-secondary);
  color: #fff;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.progress-badge {
  background: var(--color-primary);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
}

/* Alerts */
.alerts-container {
  margin-bottom: 1.5rem;
}

.alert-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--color-warning);
}

.alert-card.severe {
  border-left-color: var(--color-danger);
}

.alert-card.info {
  border-left-color: #3498db;
}

.alert-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.alert-card .time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.alert-card .detail {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.loading,
.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem 1rem;
}

.cached-notice {
  background: #fff3cd;
  color: #856404;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Emergency Numbers */
.emergency-numbers h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.emergency-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  text-decoration: none;
  color: var(--color-text);
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.emergency-card:active {
  transform: scale(0.97);
}

.emergency-card .number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.emergency-card .label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Checklist */
.checklist {
  list-style: none;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0;
  box-shadow: var(--shadow);
  gap: 0.45rem 0.6rem;
  min-width: 0;
}

.checklist-item.checked {
  opacity: 0.6;
}

.checklist-item.checked .item-label {
  text-decoration: line-through;
}

.checklist-item input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.checklist-stamp {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  user-select: none;
}

.checklist-stamp[data-category="食料・水"] {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.checklist-stamp[data-category="照明"] {
  background: #fef9c3;
  border-color: #fde047;
}

.checklist-stamp[data-category="情報"] {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

.checklist-stamp[data-category="医療"] {
  background: #ffe4e6;
  border-color: #fda4af;
}

.checklist-stamp[data-category="防寒"] {
  background: #e0f2fe;
  border-color: #93c5fd;
}

.checklist-stamp[data-category="衣類"] {
  background: #f3e8ff;
  border-color: #d8b4fe;
}

.checklist-stamp[data-category="衛生"] {
  background: #dcfce7;
  border-color: #86efac;
}

.checklist-stamp[data-category="その他"],
.checklist-stamp[data-category="カスタム"] {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.checklist-item.checked .checklist-stamp {
  filter: grayscale(0.35);
  opacity: 0.85;
}

.item-label {
  flex: 1;
  font-size: 0.9375rem;
}

.item-category {
  font-size: 0.625rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.checklist-shop-link {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #bf0000;
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0.55rem;
  border: 1px solid #bf0000;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.checklist-shop-link:hover {
  background: #bf0000;
  color: #fff;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.125rem;
  padding: 0.25rem;
  line-height: 1;
}

.add-item-form {
  display: flex;
  gap: 0.5rem;
}

.add-item-form input {
  flex: 1;
}

/* Forms */
input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"] {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  width: 100%;
}

input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Affiliate goods */
#panel-goods .panel-header,
#panel-checklist .panel-header,
#panel-contacts .panel-header {
  justify-content: center;
  text-align: center;
  margin-bottom: 0.9rem;
}

#panel-checklist .panel-header {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

#panel-goods .panel-header h2,
#panel-checklist .panel-header h2,
#panel-contacts .panel-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#panel-goods .section-desc,
#panel-checklist .section-desc,
#panel-contacts .section-desc {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 0.55rem;
}

#panel-goods .affiliate-disclaimer {
  text-align: center;
  font-size: 0.8rem;
  margin: 0 0 1.4rem;
}

.affiliate-disclaimer {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: -0.35rem 0 1rem;
  line-height: 1.5;
}

.affiliate-loading {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  padding: 1.25rem 0;
  text-align: center;
}

.affiliate-products {
  display: flex;
  flex-direction: column;
  gap: 1.85rem;
}

.affiliate-group-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--color-border);
  text-align: center;
}

.affiliate-group-title::before {
  display: none;
}

.affiliate-group-stamp {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.35rem;
  border-width: 2.5px;
}

.affiliate-slot-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 0.3rem;
  text-align: center;
}

.affiliate-slot-stamp {
  width: 2.45rem;
  height: 2.45rem;
  font-size: 1.25rem;
  border-width: 2.5px;
}

.affiliate-slots {
  display: flex;
  flex-direction: column;
  gap: 1.85rem;
}

.affiliate-slot-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  text-align: center;
}

.affiliate-slot-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.affiliate-slot-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.5;
}

.affiliate-slot-loading {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.affiliate-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
  align-items: stretch;
}

.affiliate-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 0.8rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.affiliate-product-card:hover {
  border-color: #bf0000;
  box-shadow: 0 10px 24px rgba(191, 0, 0, 0.14);
  transform: translateY(-3px);
}

.affiliate-product-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 150px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.affiliate-product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.affiliate-product-card:hover .affiliate-product-image {
  transform: scale(1.04);
}

.affiliate-product-image.placeholder {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.affiliate-rank {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 1;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  background: #64748b;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  letter-spacing: 0.02em;
}

.affiliate-rank-1 { background: #d97706; }
.affiliate-rank-2 { background: #6b7280; }
.affiliate-rank-3 { background: #a16207; }

.affiliate-product-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.affiliate-product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-text);
}

.affiliate-product-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
}

.affiliate-stars {
  color: #f59e0b;
  letter-spacing: 0.02em;
}

.affiliate-rating-value {
  font-weight: 700;
  color: var(--color-text);
}

.affiliate-product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.affiliate-product-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: #bf0000;
}

.affiliate-product-review {
  color: var(--color-text-muted);
}

.affiliate-more-link {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #bf0000;
  text-decoration: none;
  white-space: nowrap;
}

.affiliate-more-link:hover {
  text-decoration: underline;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.affiliate-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.affiliate-card:hover {
  border-color: #bf0000;
  transform: translateY(-1px);
}

.affiliate-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text);
}

.affiliate-card-desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.affiliate-product-foot .affiliate-card-cta {
  margin-top: 0;
  align-self: center;
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
}

.affiliate-card-cta {
  margin-top: auto;
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: #bf0000;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}

/* Contacts List */
.contacts-list {
  list-style: none;
}

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}

.contact-info .name {
  font-weight: 600;
}

.contact-info .phone {
  font-size: 0.875rem;
}

.contact-info .phone a {
  color: var(--color-primary);
  text-decoration: none;
}

.contact-info .relation {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Usage guides (modal) */
.guide-open-btn {
  white-space: nowrap;
}

.btn-ghost {
  background: #fff;
  color: var(--color-secondary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

dialog.guide-modal {
  inset: 0;
  margin: auto;
  width: min(480px, calc(100vw - 2rem));
  max-height: 80vh;
  overflow: auto;
  padding: 1rem 1.15rem 1.25rem;
  border: none;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
  color: var(--color-text);
}

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

.guide-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.guide-modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}

.guide-modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.guide-modal-close:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}

.usage-guide-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.7;
}

.usage-guide-list li {
  margin-bottom: 0.45rem;
}

.usage-guide-list li:last-child {
  margin-bottom: 0;
}

/* App footer */
.app-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  background: #fff;
  padding: 0.45rem 0.75rem;
}

.app-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.75rem;
}

.app-footer-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 600;
}

.app-footer-links a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.footer-links a {
  color: var(--color-primary);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (min-width: 480px) {
  .checklist {
    grid-template-columns: 1fr 1fr;
  }

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

  .contact-form {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .contact-form input {
    flex: 1;
    min-width: 120px;
  }
}

/* Tablet / Desktop */
@media (min-width: 900px) {
  .checklist {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .tab-nav {
    justify-content: center;
    gap: 0.25rem;
  }

  .tab-btn {
    flex: 0 1 auto;
    min-width: 8rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
  }

  main {
    max-width: none;
    width: 100%;
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #panel-alerts.active,
  #panel-history.active {
    flex: 1;
    min-height: 0;
  }

  .alerts-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
    gap: 1rem;
    flex: 1;
    min-height: 0;
    align-items: stretch;
  }

  .alerts-map-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
  }

  .alerts-map-pane .map-wrapper {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
  }

  .alerts-map-pane .earthquake-map {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .alerts-side-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    max-height: none;
    height: 100%;
    overflow: hidden;
  }

  .alerts-side-pane .filter-bar {
    flex-shrink: 0;
  }

  .alerts-side-pane .list-heading-row {
    flex-shrink: 0;
  }

  .alerts-side-pane .alerts-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 0;
    padding-right: 0.25rem;
  }

  #panel-checklist.active,
  #panel-contacts.active {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }

  #panel-goods.active {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .footer {
    padding: 1rem 1.5rem;
  }
}

@media (min-width: 1200px) {
  main {
    padding: 1.25rem 2rem 1.5rem;
  }

  .alerts-workspace {
    grid-template-columns: minmax(0, 1.8fr) minmax(360px, 0.85fr);
    gap: 1.25rem;
  }

  .alerts-map-pane .map-wrapper,
  .alerts-map-pane .earthquake-map {
    min-height: 0;
  }

  .alerts-side-pane {
    max-height: none;
  }

  .earthquake-map {
    border-radius: 10px;
  }
}

@media (min-width: 1600px) {
  .alerts-workspace {
    grid-template-columns: minmax(0, 2fr) minmax(400px, 0.75fr);
  }
}
