@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&family=Work+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --theme-font-head: "Montserrat", system-ui, -apple-system, sans-serif;
  --theme-font: "Work Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Light mode — white panels, clear contrast */
  --theme-bg: #eef0f5;
  --theme-bg-start: #f4f5f9;
  --theme-bg-end: #e8eaf0;
  --theme-panel: #ffffff;
  --theme-panel-soft: #f4f5f9;
  --theme-line: #dde1ea;
  --theme-line-strong: #c5cad6;
  --theme-ink: #0f172a;
  --theme-muted: #475569;
  --theme-accent: #2563eb;
  --theme-accent-strong: #1d4ed8;
  --theme-accent-soft: rgba(37, 99, 235, 0.08);
  --theme-success: #059669;
  --theme-success-soft: rgba(5, 150, 105, 0.08);
  --theme-warning: #d97706;
  --theme-warning-soft: rgba(217, 119, 6, 0.08);
  --theme-danger: #dc2626;
  --theme-danger-soft: rgba(220, 38, 38, 0.08);
  --theme-shadow: 0 16px 48px rgba(15, 23, 42, 0.10);
  --theme-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --theme-radius-lg: 18px;
  --theme-radius-md: 14px;
  --theme-radius-sm: 10px;
  --theme-radius-pill: 999px;
}

html[data-theme="light"] {
  color-scheme: light;
  --theme-bg: #eef0f5;
  --theme-bg-start: #f4f5f9;
  --theme-bg-end: #e8eaf0;
  --theme-panel: #ffffff;
  --theme-panel-soft: #f4f5f9;
  --theme-line: #dde1ea;
  --theme-line-strong: #c5cad6;
  --theme-ink: #0f172a;
  --theme-muted: #475569;
  --theme-accent: #2563eb;
  --theme-accent-strong: #1d4ed8;
  --theme-accent-soft: rgba(37, 99, 235, 0.08);
  --theme-success: #059669;
  --theme-success-soft: rgba(5, 150, 105, 0.08);
  --theme-warning: #d97706;
  --theme-warning-soft: rgba(217, 119, 6, 0.08);
  --theme-danger: #dc2626;
  --theme-danger-soft: rgba(220, 38, 38, 0.08);
  --theme-shadow: 0 16px 48px rgba(15, 23, 42, 0.10);
  --theme-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg: #1e2126;
  --theme-bg-start: #22252b;
  --theme-bg-end: #1a1d22;
  --theme-panel: #282c33;
  --theme-panel-soft: #2e323a;
  --theme-line: rgba(160, 168, 180, 0.14);
  --theme-line-strong: rgba(160, 168, 180, 0.24);
  --theme-ink: #edf0f4;
  --theme-muted: #8a96a4;
  --theme-accent: #3b82f6;
  --theme-accent-strong: #60a5fa;
  --theme-accent-soft: rgba(59, 130, 246, 0.12);
  --theme-success: #22c48a;
  --theme-success-soft: rgba(34, 196, 138, 0.12);
  --theme-warning: #e0a030;
  --theme-warning-soft: rgba(224, 160, 48, 0.12);
  --theme-danger: #f06060;
  --theme-danger-soft: rgba(240, 96, 96, 0.12);
  --theme-shadow: 0 16px 48px rgba(0, 0, 0, 0.40);
  --theme-shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);
}

html {
  background: linear-gradient(160deg, var(--theme-bg-start) 0%, var(--theme-bg-end) 100%);
  min-height: 100%;
}

body {
  font-family: var(--theme-font);
  color: var(--theme-ink);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--theme-font-head);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --theme-bg: #1e2126;
    --theme-bg-start: #22252b;
    --theme-bg-end: #1a1d22;
    --theme-panel: #282c33;
    --theme-panel-soft: #2e323a;
    --theme-line: rgba(160, 168, 180, 0.14);
    --theme-line-strong: rgba(160, 168, 180, 0.24);
    --theme-ink: #edf0f4;
    --theme-muted: #8a96a4;
    --theme-accent: #3b82f6;
    --theme-accent-strong: #60a5fa;
    --theme-accent-soft: rgba(59, 130, 246, 0.12);
    --theme-success: #22c48a;
    --theme-success-soft: rgba(34, 196, 138, 0.12);
    --theme-warning: #e0a030;
    --theme-warning-soft: rgba(224, 160, 48, 0.12);
    --theme-danger: #f06060;
    --theme-danger-soft: rgba(240, 96, 96, 0.12);
    --theme-shadow: 0 16px 48px rgba(0, 0, 0, 0.40);
    --theme-shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);
  }

  html {
    background: var(--theme-bg-start);
  }
}

.theme-toggle {
  position: fixed;
  top: max(12px, calc(env(safe-area-inset-top, 0px) + 12px));
  right: max(14px, calc(env(safe-area-inset-right, 0px) + 14px));
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--theme-line-strong);
  border-radius: 999px;
  background: var(--theme-panel);
  color: var(--theme-muted);
  font: 700 10px/1 var(--theme-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: var(--theme-shadow-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--theme-accent);
  color: var(--theme-ink);
  box-shadow: var(--theme-shadow);
}

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

.theme-toggle-icon {
  font-size: 12px;
  line-height: 1;
}

.theme-toggle-inline {
  position: relative;
  top: auto;
  right: auto;
  z-index: auto;
  box-shadow: none;
}

html[data-theme="dark"] .theme-toggle {
  background: var(--theme-panel);
  color: var(--theme-muted);
  border-color: var(--theme-line-strong);
  box-shadow: var(--theme-shadow-soft);
}

html[data-theme="dark"] .theme-toggle-inline {
  box-shadow: none;
}

@media (max-width: 720px) {
  .theme-toggle {
    min-height: 34px;
    padding: 0 11px;
  }
}

@media (max-width: 560px) {
  .theme-toggle {
    gap: 5px;
    min-height: 32px;
    padding: 0 9px;
  }

  .theme-toggle-label {
    display: none;
  }
}
