:root {
  --bg: #0b0e13;
  --card: #121826;
  --muted: #8aa0b6;
  --text: #e6edf6;
  --accent: #6ea8fe; /* shade line */
  --sun: #ffb86b; /* sun line */
  --good: #22c55e; /* current time + vertical line */
  --border: #1f2a3b;
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --card: #ffffff;
  --muted: #6b7280;
  --text: #1f2937;
  --accent: #3b82f6;
  --sun: #f59e0b;
  --good: #10b981;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.headline {
  margin: 0;
  font-size: 28px;
}
.headline .zip-inline-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  font-weight: 500;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 2px 4px;
  border-radius: 4px;
}
.headline .zip-inline-wrapper:hover {
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .headline .zip-inline-wrapper:hover {
  background: rgba(0, 0, 0, 0.03);
}
.headline .zip-icon {
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.headline .zip-label-text {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: all 0.2s ease;
}
.headline .zip-inline-wrapper:hover .zip-label-text {
  color: var(--accent);
  text-decoration-style: solid;
}
.headline .sub {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
}

.theme-btn {
  background: #141b2a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.theme-btn:hover {
  background: #1a2332;
}

[data-theme="light"] .theme-btn {
  background: #f3f4f6;
  border-color: var(--border);
}

[data-theme="light"] .theme-btn:hover {
  background: #e5e7eb;
}

.unit-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.unit-btn {
  background: #141b2a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}
[data-theme="light"] .unit-btn {
  background: #f3f4f6;
  border-color: var(--border);
}
.unit-btn.active {
  background: var(--good);
  border-color: var(--good);
  color: #05130a;
}
.unit-btn:focus-visible {
  outline: 2px solid #fff2;
}

/* Cards row now holds combined card */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 10px 0 8px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
}
.card-title {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.card-temp {
  font-size: 28px;
  font-weight: 700;
}
.card-temp--now {
  color: var(--good);
}
.card--shade {
  background: rgba(110, 168, 254, 0.08);
  border-color: rgba(110, 168, 254, 0.3);
}
[data-theme="light"] .card--shade {
  background: rgba(110, 168, 254, 0.12);
  border-color: rgba(110, 168, 254, 0.4);
}
.card--shade .card-temp {
  color: var(--accent);
}
.card--sun {
  background: rgba(255, 184, 107, 0.08);
  border-color: rgba(255, 184, 107, 0.3);
}
[data-theme="light"] .card--sun {
  background: rgba(255, 184, 107, 0.12);
  border-color: rgba(255, 184, 107, 0.4);
}
.card--sun .card-temp {
  color: var(--sun);
}
.card--sun .card-temp .time-ampm {
  font-size: 0.75em;
  opacity: 0.8;
}
.card--combined {
  background: var(--card);
  border: 1px solid var(--border);
}
.card-temps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 4px 0;
}
.card-temps:has(#sunTempWrapper[style*="display: none"]),
.card-temps.sun-hidden {
  grid-template-columns: 1fr;
}
.card-temp-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-temp-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-temp-sun {
  color: var(--sun);
}
.card-temp-shade {
  color: var(--accent);
}
.card-temp-combined {
  color: var(--sun);
}
.card-temp-combined {
  color: var(--sun);
}
.card-desc {
  display: block;
  line-height: 1.25;
  min-height: calc(2 * 1.25em); /* always two lines tall */
  margin-top: 0; /* keep text aligned at the top */
}
.now-time__sub {
  color: var(--muted);
  font-size: 12px;
}

/* Weather Summary */
.weather-summary {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 16px;
  margin: 10px 0 16px;
  padding: 16px;
}
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.summary-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--good);
  flex: 1;
}
.summary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.copy-summary-btn,
.export-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.copy-summary-btn:hover,
.export-btn:hover {
  background: #1a2332;
}
[data-theme="light"] .copy-summary-btn:hover,
[data-theme="light"] .export-btn:hover {
  background: #e5e7eb;
}
.summary-time-range {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
  font-weight: 500;
}
.summary-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.summary-text.loading {
  color: var(--muted);
  font-style: italic;
}

/* Chart */
.chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 10px 0 16px;
  padding: 12px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
.chart-wrap * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
/* Chart.js tooltip max-width and styling */
.chartjs-tooltip {
  max-width: min(90vw, 200px) !important;
}
.chartjs-tooltip-body {
  color: #ffffff !important;
}
.chartjs-tooltip-body-item {
  color: #ffffff !important;
}
.chartjs-tooltip-title {
  color: #ffffff !important;
}
/* Hide the color indicator square */
.chartjs-tooltip-body-item span {
  display: none !important;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.chart-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 1;
}
.zip-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}
.zip-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.chart-location-input {
  font-size: 17px;
  font-family: system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 700;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px 6px 28px; /* Left padding accounts for spinner space */
  width: calc(5ch + 52px); /* 5 characters + left padding (28px) + right padding (12px) + extra space for letter-spacing */
  text-align: center;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
  position: relative;
  vertical-align: middle;
  box-sizing: border-box;
  cursor: text;
}
.chart-location-input:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 168, 254, 0.15);
  background: var(--card);
}
.chart-location-input:focus {
  outline: none;
  border-color: var(--good);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}
.chart-location-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg);
}
.chart-location-input::placeholder {
  color: var(--muted);
  font-weight: 400;
  opacity: 0.6;
}
[data-theme="light"] .chart-location-input {
  background: #ffffff;
  border-color: #d1d5db;
}
[data-theme="light"] .chart-location-input:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}
[data-theme="light"] .chart-location-input:focus {
  background: #ffffff;
  border-color: var(--good);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}
[data-theme="light"] .chart-location-input:disabled {
  background: #f9fafb;
}
.zip-loading-spinner {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--good);
  border-radius: 50%;
  animation: spin-vertical 0.8s linear infinite;
  pointer-events: none;
}
.zip-clear-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.zip-clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
[data-theme="light"] .zip-clear-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}
@keyframes spin-vertical {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}
.chart-status {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
  min-height: 14px;
}
.chart-shading-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.toggle-subsection {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
}
.shading-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.shading-toggle-label:hover {
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .shading-toggle-label:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Toggle Switch Styling */
.shading-toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.toggle-switch::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shading-toggle-label input[type="checkbox"]:checked + .toggle-switch {
  background: var(--good);
}

.shading-toggle-label input[type="checkbox"]:checked + .toggle-switch::before {
  transform: translateX(16px);
}

.shading-toggle-label input[type="checkbox"]:focus-visible + .toggle-switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[data-theme="light"] .toggle-switch {
  background: #d1d5db;
}

[data-theme="light"] .toggle-switch::before {
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .shading-toggle-label input[type="checkbox"]:checked + .toggle-switch {
  background: var(--good);
}

/* Custom Checkbox Styling (for other checkboxes) */
input[type="checkbox"]:not(.shading-toggle-label input) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  position: relative;
  margin: 0;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

input[type="checkbox"]:not(.shading-toggle-label input):hover {
  border-color: var(--accent);
  background: rgba(110, 168, 254, 0.1);
}

input[type="checkbox"]:not(.shading-toggle-label input):checked {
  background: var(--good);
  border-color: var(--good);
}

input[type="checkbox"]:not(.shading-toggle-label input):checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #05130a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

input[type="checkbox"]:not(.shading-toggle-label input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[data-theme="light"] input[type="checkbox"]:not(.shading-toggle-label input) {
  background: #ffffff;
  border-color: var(--border);
}

[data-theme="light"] input[type="checkbox"]:not(.shading-toggle-label input):hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent);
}

[data-theme="light"] input[type="checkbox"]:not(.shading-toggle-label input):checked {
  background: var(--good);
  border-color: var(--good);
}

[data-theme="light"] input[type="checkbox"]:not(.shading-toggle-label input):checked::after {
  color: #ffffff;
}
.chart-title {
  font-weight: 600;
  color: var(--text);
}
.chart-status {
  color: var(--muted);
  font-size: 12px;
}
.time-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.preset-buttons-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.chart-nav-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  transition: all 0.2s;
  min-width: 36px;
  display: none;
  align-items: center;
  justify-content: center;
}
.chart-nav-btn:hover {
  background: #1a2332;
  border-color: var(--muted);
}
[data-theme="light"] .chart-nav-btn:hover {
  background: #e5e7eb;
  border-color: var(--muted);
}
.chart-nav-btn:active {
  transform: scale(0.95);
}
.preset-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}
.preset-btn:hover {
  background: #1a2332;
  border-color: var(--muted);
}
[data-theme="light"] .preset-btn:hover {
  background: #e5e7eb;
  border-color: var(--muted);
}
.preset-btn.active {
  background: var(--good);
  border-color: var(--good);
  color: #05130a;
}
.preset-btn.active:hover {
  background: #1ea548;
}
.preset-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}
.preset-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid var(--text);
  border-top-color: transparent;
  border-radius: 50%;
  animation: preset-loading 0.6s linear infinite;
}
[data-theme="light"] .preset-btn.loading::after {
  border-color: var(--text);
  border-top-color: transparent;
}
@keyframes preset-loading {
  to {
    transform: rotate(360deg);
  }
}
.preset-dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-arrow {
  font-size: 8px;
  margin-left: 4px;
  display: inline-block;
  transition: transform 0.2s;
}
.preset-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}
.preset-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 140px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: none;
}
.preset-dropdown-item {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: background 0.2s;
  border-radius: 0;
}
.preset-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .preset-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}
.preset-dropdown-item.active {
  background: rgba(34, 197, 94, 0.1);
  color: var(--good);
}
.chart-box {
  position: relative;
  height: 260px;
  max-height: 260px;
}
#vibeChart {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.tip-section {
  margin: 16px 0;
  padding: 0;
}
.tip-content {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.tip-content small {
  opacity: 0.8;
}
.desktop-only {
  display: inline;
}
@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }
}
.clear-highlight-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.clear-highlight-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 300px;
  font-size: 13px;
  line-height: 1.4;
}
.notification.error {
  border-color: #ef4444;
  background: #1a0f0f;
}
.notification.success {
  border-color: var(--good);
  background: #0a1a0f;
}

/* Error Message */
.error-message {
  background: rgba(239, 68, 68, 0.12);
  border: 1.5px solid #ef4444;
  border-radius: 14px;
  padding: 18px 40px 18px 18px;
  margin: 12px 0 16px;
  display: none;
  position: relative;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}
.error-message.show {
  display: block;
}
[data-theme="light"] .error-message {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}
.error-content {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.error-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0;
  margin-left: 42px; /* Align with text content (28px icon + 14px gap) */
}
.error-zip-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  flex: 1;
  min-width: 0;
}
.error-zip-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
}
.error-zip-input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
[data-theme="light"] .error-zip-input {
  background: #ffffff;
  border-color: rgba(239, 68, 68, 0.5);
}
.error-zip-submit-btn {
  background: #ef4444;
  border: 1.5px solid #ef4444;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  flex-shrink: 0;
}
.error-zip-submit-btn:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
.error-zip-submit-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.3);
}
.error-zip-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.error-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: absolute;
  top: 14px;
  right: 14px;
  transition: all 0.2s ease;
  opacity: 0.6;
}
.error-dismiss-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  opacity: 1;
}
.error-dismiss-btn:active {
  transform: scale(0.95);
}
.error-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.error-text {
  flex: 1;
  min-width: 0;
}
.error-title {
  font-weight: 600;
  color: #ef4444;
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.3;
}
.error-details {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.error-suggestion {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.error-action-btn {
  background: var(--card);
  border: 1.5px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.error-action-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}
.error-action-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.2);
}
[data-theme="light"] .error-action-btn {
  background: #ffffff;
  border-color: rgba(239, 68, 68, 0.5);
}
[data-theme="light"] .error-action-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.error-retry-btn {
  background: #ef4444;
  border: 1.5px solid #ef4444;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.error-retry-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
.error-retry-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.3);
}
/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.modal-content.modal-large {
  max-width: 900px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header .modal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
[data-theme="light"] .modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.modal-title {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.modal-message {
  margin: 0 0 20px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.modal-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}
.modal-btn:hover {
  background: #1a2332;
}
[data-theme="light"] .modal-btn:hover {
  background: #e5e7eb;
}
.modal-btn-primary {
  background: var(--good);
  border-color: var(--good);
  color: #05130a;
}
.modal-btn-primary:hover {
  background: #1ea548;
}
.shortcuts-list {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.shortcut-item kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  min-width: 32px;
  text-align: center;
  color: var(--text);
}
.shortcut-item span {
  color: var(--text);
  font-size: 14px;
}

/* Controls */
.controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 4px;
}
.controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  background: #213149;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}
[data-theme="light"] .btn {
  background: #e5e7eb;
  border-color: var(--border);
}
.btn-secondary {
  background: #1a2332;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
}
[data-theme="light"] .btn-secondary {
  background: #f3f4f6;
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #243041;
}
[data-theme="light"] .btn-secondary:hover {
  background: #e5e7eb;
}
.favorites-dropdown {
  position: relative;
  display: inline-block;
}
.favorites-list {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.favorites-list.show {
  display: block;
}
.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.favorite-item:last-child {
  border-bottom: none;
}
.favorite-item:hover {
  background: #1a2332;
}
[data-theme="light"] .favorite-item:hover {
  background: #f3f4f6;
}
.favorite-name {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  padding: 4px 0;
  font-size: 14px;
}
.favorite-name:hover {
  color: var(--accent);
}
.favorite-delete {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.favorite-delete:hover {
  background: rgba(239, 68, 68, 0.2);
}
.btn--sm {
  padding: 6px 10px;
  font-size: 13px;
}
.btn--ghost {
  background: transparent;
}
.status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.times {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Advanced */
.advanced-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 10px 0 16px;
  overflow: hidden;
}
.advanced {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-top: 12px;
}
.adv-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.2s ease;
}
.adv-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .adv-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}
.adv-label {
  font-weight: 600;
  flex: 1;
}
.adv-caret {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--muted);
  transition: transform 0.18s ease;
  transform-origin: 50% 45%;
  margin-left: auto;
  flex-shrink: 0;
}
.adv-toggle[aria-expanded="true"] .adv-caret {
  transform: rotate(180deg);
}
.adv-panel {
  padding: 24px;
  border-top: 1px solid var(--border);
}
.adv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.adv-col h4 {
  margin: 8px 0;
  color: var(--muted);
}
.adv-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.stat-item:last-child {
  border-bottom: none;
}
.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.stat-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  text-align: right;
}
.adv-status {
  font-size: 13px;
  color: var(--text);
  padding: 8px 0;
  margin-top: 4px;
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 6px;
}
input,
select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1523;
  color: var(--text);
  font-size: 14px;
}
[data-theme="light"] input,
[data-theme="light"] select {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
}
.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.w-5ch {
  width: 5ch;
}
.range-val {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.hint {
  color: var(--muted);
  font-size: 12px;
}
.zip-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.zip-input {
  flex: 1;
}

.formula {
  margin: 8px 0;
  background: #0f1523;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 12px;
  color: #cfe3ff;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}
[data-theme="light"] .formula {
  background: #f9fafb;
  border-color: var(--border);
  color: #1f2937;
}

/* Loading States & Skeletons */
.skeleton-text {
  background: linear-gradient(90deg, #1a2332 25%, #243041 50%, #1a2332 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
  color: transparent;
  user-select: none;
  display: inline-block;
  min-width: 2em;
}
.error-displayed .skeleton-text,
.error-displayed .skeleton-line {
  animation: none;
}
[data-theme="light"] .skeleton-text {
  background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.chart-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 20px;
  gap: 12px;
}
.skeleton-line {
  height: 2px;
  background: linear-gradient(90deg, #1a2332 25%, #243041 50%, #1a2332 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 2px;
  flex: 1;
  max-width: 100%;
}
[data-theme="light"] .skeleton-line {
  background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
  background-size: 200% 100%;
}
.skeleton-line:nth-child(2) {
  max-width: 85%;
}
.skeleton-line:nth-child(3) {
  max-width: 70%;
}
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--good);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 500px) {
  .cards {
    grid-template-columns: 1fr;
  }
  .adv-grid {
    grid-template-columns: 1fr;
  }
  .headline .zip-inline-wrapper {
    display: block;
    margin-left: 0;
    margin-top: 4px;
    font-size: 16px;
  }
  .headline {
    font-size: 24px;
  }
}
