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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #5ba8d4;
  color: #1a1a1a;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ── Header ── */
header {
  background: #5ba8d4;
  border-bottom: 1px solid #4a96c0;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 16px;
}

/* ── Brand lockup ── */
.header-brand {
  position: relative;
  width: 100%;
  overflow: hidden;
  /* height set by JS */
}

.brand-icon,
.brand-text {
  position: absolute;
  object-fit: contain;
  /* all sizing + position set by JS */
  will-change: transform, width, height, top, left;
}

.header-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

h1 { font-size: 22px; font-weight: 700; color: #111; }
.header-subtitle { font-size: 12px; color: #9ca3af; font-style: italic; }
.header-desc { font-size: 13px; color: #6b7280; line-height: 1.4; }

.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  flex-shrink: 0;
}
.icon-btn:active { background: #f3f4f6; }

/* ── Settings Panel ── */
.settings-panel {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.settings-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.settings-panel h3 { font-size: 14px; font-weight: 700; color: #1e40af; margin-bottom: 0; }
.bull-btn { background: none; border: none; font-size: 26px; cursor: pointer; line-height: 1; padding: 2px; }
.bull-btn:active { transform: scale(1.3); }
.settings-label { font-size: 12px; font-weight: 600; color: #1e40af; margin-bottom: 8px; }

.strictness-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.strictness-btn {
  padding: 8px 6px;
  border: 2px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.strictness-btn strong { font-size: 12px; color: #1e40af; }
.strictness-btn span { font-size: 10px; color: #3b82f6; }
.strictness-btn.active { border-color: #2563eb; background: #dbeafe; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1px;
}
@media (min-width: 500px) {
  .tabs { justify-content: center; }
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: #fff; }

/* ── Main ── */
main { padding: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 600px; margin: 0 auto; }
.tab-content { display: flex; flex-direction: column; gap: 14px; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}
.card h2 { font-size: 15px; font-weight: 700; color: #111; margin-bottom: 4px; }
.card h3 { font-size: 14px; font-weight: 700; color: #111; margin-bottom: 6px; }
.card-desc { font-size: 12px; color: #6b7280; margin-bottom: 12px; line-height: 1.4; }
.card-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.subtle { font-weight: 400; color: #6b7280; }

/* ── Inputs ── */
input[type="text"], input[type="url"], input.mono, input.color-usage {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  color: #5ba8d4 !important;
  -webkit-text-fill-color: #5ba8d4 !important;
  -webkit-appearance: none;
}
input[type="text"]:focus, input[type="url"]:focus, input.mono:focus, input.color-usage:focus {
  border-color: #5ba8d4;
  box-shadow: 0 0 0 3px rgba(91,168,212,0.2);
}
input::placeholder { color: #a0c8e0; -webkit-text-fill-color: #a0c8e0; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 8px; }

/* ── Input Combined Card ── */
.input-combined { padding: 0; overflow: hidden; }
.input-section { padding: 16px; }
.input-section-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.input-section-header h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.input-section-header p { font-size: 12px; color: #6b7280; }
.input-divider { height: 1px; background: #e5e7eb; margin: 0; }
.input-icon { font-size: 24px; }

.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; }

/* ── Buttons ── */
.btn-stack { display: flex; flex-direction: column; gap: 8px; }

.btn-primary {
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { background: #1d4ed8; }

.btn-primary-sm {
  padding: 7px 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  padding: 10px 14px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: #dbeafe; }

.file-label {
  display: block;
  cursor: pointer;
}

.status-banner {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.status-banner.analyzing {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
  color: #1e40af;
}
.status-banner.done {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #166534;
}
.status-banner.error {
  background: #fef2f2;
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.18);
  color: #991b1b;
}
.status-banner .status-action {
  margin-left: auto;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.status-banner.error .status-action { background: #dc2626; color: #fff; }
.status-banner.analyzing .status-action { background: #2563eb; color: #fff; }

.selected-file {
  font-size: 12px;
  color: #374151;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.selected-file::before { content: '✓'; color: #16a34a; font-weight: 700; }

.btn-ghost {
  padding: 8px 12px;
  background: none;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost-sm {
  padding: 6px 10px;
  background: none;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-full { width: 100%; margin-top: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.btn-accept {
  width: 100%;
  padding: 14px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-accept:active { background: #15803d; }

/* ── Loading ── */
.loading-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 18px 16px;
  color: #1e40af;
  font-size: 15px;
  font-weight: 600;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Harmony Warnings ── */
.warnings-box {
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid;
  margin-bottom: 12px;
}
.warnings-box.moderate { background: #fefce8; border-color: #facc15; }
.warnings-box.strict { background: #fef2f2; border-color: #f87171; }
.warnings-box .warn-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.warnings-box.moderate .warn-title { color: #713f12; }
.warnings-box.strict .warn-title { color: #7f1d1d; }
.warn-item { font-size: 12px; margin-bottom: 8px; }
.warnings-box.moderate .warn-item { color: #713f12; }
.warnings-box.strict .warn-item { color: #7f1d1d; }
.warn-toggle { font-size: 11px; color: #92400e; text-decoration: underline; cursor: pointer; background: none; border: none; padding: 0; margin-top: 2px; }
.swap-suggestions { background: rgba(0,0,0,0.05); border-radius: 6px; padding: 8px; margin-top: 6px; font-size: 11px; }
.swap-item { display: flex; align-items: center; gap: 6px; margin-top: 4px; cursor: pointer; }
.swap-swatch { width: 20px; height: 20px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.2); flex-shrink: 0; }

/* ── Color Editor ── */
.color-row {
  border: 2px solid #d1e9f7;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fafdff;
}
.color-row-main { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
input[type="color"] {
  width: 48px;
  height: 48px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
  flex-shrink: 0;
}
.color-fields { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.color-fields input { font-size: 13px; padding: 7px 10px; }
.color-usage-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.color-usage-row label { font-size: 11px; color: #9ca3af; white-space: nowrap; }
.color-usage { flex: 1; font-size: 12px; font-family: monospace; padding: 6px 8px; }
.color-row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.btn-autofix {
  padding: 5px 10px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-autofix:active { background: #dcfce7; }
.btn-remove {
  padding: 5px 10px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.harmony-mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.harmony-chip {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
}
.harmony-chip.ok { background: #dcfce7; color: #166534; }
.harmony-chip.warn { background: #fefce8; color: #713f12; }
.harmony-chip.err { background: #fef2f2; color: #7f1d1d; }
.harmony-chip strong { display: block; font-size: 10px; }

/* ── Accept / Expansion ── */
.expansion-header { display: flex; align-items: flex-start; gap: 12px; }
.check-icon { font-size: 20px; color: #2563eb; flex-shrink: 0; margin-top: 2px; }

/* ── Preview ── */
.palette-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 400px) { .palette-grid { grid-template-columns: repeat(3, 1fr); } }

.palette-swatch { text-align: center; }
.swatch-box { width: 100%; height: 60px; border-radius: 8px; border: 1px solid #e5e7eb; margin-bottom: 6px; }
.swatch-name { font-size: 12px; font-weight: 600; color: #111; }
.swatch-hex { font-size: 11px; color: #6b7280; font-family: monospace; }
.swatch-usage { font-size: 10px; color: #9ca3af; }
.swatch-wcag { font-size: 10px; margin-top: 4px; font-weight: 600; }

/* Expanded palette */
.mode-section { margin-bottom: 16px; }
.mode-label { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #374151; }
.dark-section .mode-label { color: #d1d5db; }
.dark-section { background: #1f2937; border-radius: 10px; padding: 12px; margin-top: 12px; }

.palette-row {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.palette-row-label { padding: 6px 10px; background: #f9fafb; font-size: 12px; font-weight: 600; color: #374151; }
.dark-section .palette-row { border-color: #374151; }
.dark-section .palette-row-label { background: #374151; color: #e5e7eb; }
.shade-strip { display: flex; height: 40px; }
.shade-cell { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; }

/* Live preview */
.preview-hero { border-radius: 10px; padding: 28px 16px; text-align: center; margin-bottom: 12px; }
.preview-hero h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.preview-hero p { font-size: 13px; opacity: 0.85; }
.preview-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.preview-btn { padding: 12px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; color: #fff; cursor: default; }
.preview-cards { display: flex; flex-direction: column; gap: 8px; }
.preview-card { padding: 12px; border-radius: 8px; border: 2px solid; }
.preview-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.preview-card-text { font-size: 12px; margin-bottom: 8px; }
.contrast-badge { font-size: 11px; padding: 3px 8px; border-radius: 12px; display: inline-block; }
.contrast-badge.pass { background: #dcfce7; color: #166534; }
.contrast-badge.fail { background: #fef2f2; color: #991b1b; }

/* Palette ready banner — top of preview tab */
.palette-ready-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #0d1f18;
  border: 2px solid #43d9ad;
  box-shadow: 0 0 18px rgba(67,217,173,0.25);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.palette-ready-icon {
  font-size: 22px;
  color: #43d9ad;
  font-weight: 800;
  flex-shrink: 0;
}
.palette-ready-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.palette-ready-text strong {
  color: #43d9ad;
  font-size: 14px;
}
.palette-ready-text span {
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.4;
}
.palette-ready-cta {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
  padding: 8px 14px;
}

/* ── Export ── */
.format-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.format-btn {
  padding: 10px 6px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.format-btn strong { font-size: 13px; color: #111; }
.format-btn span { font-size: 10px; color: #6b7280; }
.format-btn.active { border-color: #2563eb; background: #eff6ff; }

.export-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
pre#export-preview {
  background: #111827;
  color: #f9fafb;
  padding: 14px;
  border-radius: 8px;
  font-size: 11px;
  font-family: monospace;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.next-steps h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.next-steps ul { padding-left: 16px; font-size: 12px; color: #374151; line-height: 1.8; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.modal-icon { font-size: 32px; color: #16a34a; margin-bottom: 12px; }
.modal-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-box p { font-size: 14px; color: #4b5563; line-height: 1.5; margin-bottom: 20px; }
.modal-btns { display: flex; flex-direction: column; gap: 10px; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: #6b7280; margin-bottom: 16px; }
