/* ============================================================
   CSS CUSTOM PROPERTIES — Single Source of Truth
============================================================ */
:root {
  /* --- Depth Palette --- */
  --bg-void:      #0a0e1a;
  --bg-deep:      #080c18;
  --bg-panel:     #0f1528;
  --bg-raised:    #111d35;
  --bg-surface:   #162040;

  /* --- Borders --- */
  --border-dim:   rgba(74,158,255,0.07);
  --border-mid:   rgba(74,158,255,0.13);
  --border-hi:    rgba(74,158,255,0.22);

  /* --- Accent: CVelio Blue --- */
  --gold:         #4a9eff;
  --gold-dim:     #2564c2;
  --gold-muted:   rgba(74,158,255,0.12);
  --gold-glow:    rgba(74,158,255,0.25);

  /* --- Status Green --- */
  --green:        #3ddc84;
  --green-glow:   rgba(61,220,132,0.35);

  /* --- Typography --- */
  --text-bright:  #e8eaf0;
  --text-primary: #b8c2d4;
  --text-dim:     #8892a4;
  --text-muted:   #3a4a62;

  /* --- Fonts --- */
  --font-display: 'Playfair Display', serif;
  --font-ui:      'Raleway', sans-serif;
  --font-mono:    'DM Mono', monospace;

  /* --- Layout --- */
  --topbar-h:     52px;
  --sidebar-w:    272px;
  --gap:          10px;
  --r:            10px;
  --r-sm:         6px;

  /* ============================================================
     SHADOWS — The Core of Skeuomorphism
     Three archetypes: RAISED · INSET · FLOATING
  ============================================================ */

  --shadow-raised:
    0 1px 0   rgba(255,255,255,0.07) inset,
    0 -1px 0  rgba(0,0,0,0.45)       inset,
    0 1px 0   rgba(255,255,255,0.03),
    0 4px 10px rgba(0,0,0,0.55),
    0 1px 3px  rgba(0,0,0,0.80);

  --shadow-inset:
    0 2px 6px  rgba(0,0,0,0.70) inset,
    0 1px 2px  rgba(0,0,0,0.90) inset,
    0 1px 0    rgba(255,255,255,0.03);

  --shadow-panel:
    0 1px 0   rgba(255,255,255,0.06) inset,
    0 -1px 0  rgba(0,0,0,0.35)       inset,
    0 8px 30px rgba(0,0,0,0.65),
    0 2px 8px  rgba(0,0,0,0.85),
    0 1px 0    rgba(255,255,255,0.025);

  --shadow-pressed:
    0 1px 4px  rgba(0,0,0,0.80) inset,
    0 2px 8px  rgba(0,0,0,0.60) inset,
    0 1px 0    rgba(255,255,255,0.02);
}

/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: overlay;
  opacity: 0.55;
}

/* ============================================================
   TOP BAR
============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-dim);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 6px 24px rgba(0,0,0,0.6),
    0 1px 4px  rgba(0,0,0,0.8);
}

/* -- Logo -- */
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
}

.logo-mark {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: linear-gradient(145deg, #2a7fe8 0%, #1458b0 100%);
  box-shadow: var(--shadow-raised);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.logo-mark svg {
  width: 14px; height: 14px;
  fill: rgba(20,10,0,0.85);
}

.logo-wordmark {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-bright);
  line-height: 1;
}

.logo-wordmark em {
  font-style: normal;
  color: var(--gold);
}

/* -- Topbar Nav (About + Blog) -- */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.btn-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  background: var(--bg-deep);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-inset);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  user-select: none;
}

.btn-nav:hover {
  color: var(--gold);
  background: var(--bg-raised);
  border-color: var(--border-hi);
}

.btn-nav svg {
  width: 11px; height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* -- Nav credit link (sibling-tool cross-link) -- */
a.nav-credit,
a.nav-credit:link,
a.nav-credit:visited {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
  padding: 0 2px;
}
a.nav-credit:hover { color: var(--text-dim); }

/* -- Language Switcher -- */
.lang-toggle { position: relative; }

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--bg-deep);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-inset);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}

.lang-btn:hover { border-color: var(--border-hi); color: var(--text-primary); }

.lang-btn .arrow { font-size: 9px; opacity: 0.5; transition: transform 0.18s ease; }
.lang-btn.open .arrow { transform: rotate(180deg); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 90px;
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 400;
}

.lang-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.lang-option:hover { background: var(--bg-raised); color: var(--text-primary); }
.lang-option.active { color: var(--gold); background: var(--gold-muted); }

/* -- Theme Switcher -- */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  background: var(--bg-deep);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-inset);
}

.theme-btn {
  width: 26px; height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  opacity: 0.35;
  transition: background 0.15s, opacity 0.15s, color 0.15s;
}

.theme-btn svg {
  width: 11px; height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.theme-btn:hover { opacity: 0.65; background: rgba(255,255,255,0.04); }

.theme-btn.active {
  opacity: 1;
  background: var(--bg-deep);
  color: #4a9eff;
  box-shadow:
    0 2px 6px  rgba(0,0,0,0.70) inset,
    0 1px 2px  rgba(0,0,0,0.90) inset,
    0 0 8px    rgba(74,158,255,0.18) inset,
    0 0 1px    rgba(74,158,255,0.30) inset;
}

.theme-btn.active svg {
  filter: drop-shadow(0 0 4px rgba(74,158,255,0.70));
}

/* -- Privacy Badge — absolute center of topbar -- */
.privacy-badge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  background: var(--bg-deep);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  box-shadow: var(--shadow-inset);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  user-select: none;
}

.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(61,220,132,0.2), 0 0 8px var(--green-glow);
  animation: breathe 2.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes breathe {
  0%,100% { opacity: 1; box-shadow: 0 0 0 2px rgba(61,220,132,0.2), 0 0 8px var(--green-glow); }
  50%      { opacity: 0.35; box-shadow: 0 0 0 2px rgba(61,220,132,0.05), 0 0 4px transparent; }
}

/* ============================================================
   MAIN LAYOUT GRID
============================================================ */
.app-shell {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  grid-template-rows: 1fr auto;
  gap: var(--gap);
  padding: var(--gap);
}

/* ============================================================
   SIDEBAR COLUMNS
============================================================ */
.sidebar-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  grid-row: 1 / span 2; /* span both grid rows so panels stay full-height */
}

.sidebar-col .panel {
  flex: 1;
  min-height: 0;
}

/* ============================================================
   AD SLOTS
============================================================ */
.ad-slot {
  flex-shrink: 0;
  width: 100%;
  height: 250px;
  background: var(--bg-deep);
  border-radius: var(--r);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ad-slot::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(0,0,0,0.6);
  border-radius: var(--r) var(--r) 0 0;
  pointer-events: none;
}

.ad-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}

@media (max-width: 1023px) {
  .ad-slot {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 60px;
    z-index: 150;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .sidebar-col ~ .sidebar-col .ad-slot {
    display: none;
  }
}

/* ============================================================
   SHARED PANEL STYLES
============================================================ */
.panel {
  background: var(--bg-panel);
  border-radius: var(--r);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.09) 40%,
    rgba(255,255,255,0.09) 60%,
    transparent 100%
  );
  border-radius: 0 0 4px 4px;
  pointer-events: none;
}

.panel::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(0,0,0,0.6);
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 11px;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, transparent 100%);
}

.panel-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-inset);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--gold-dim);
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.module-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dim);
  background: var(--bg-void);
  border: 1px solid rgba(74,158,255,0.18);
  border-radius: 3px;
  padding: 2px 7px;
}

.panel-body {
  flex: 1;
  overflow-y: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


/* ============================================================
   WIDGETS
============================================================ */
.widget {
  background: var(--bg-deep);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-inset);
  padding: 10px 12px;
  position: relative;
}

.widget::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(0,0,0,0.6);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  pointer-events: none;
}

.w-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.w-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-bright);
  line-height: 1;
}

.w-value .w-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
}

.w-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 3px;
}

.w-info-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  background: none;
  border: none;
  padding: 2px;
  margin: 0;
  cursor: pointer;
  color: var(--gold-dim);
  line-height: 0;
  border-radius: 50%;
  transition: color 0.18s;
  z-index: 2;
}

.w-info-btn:hover,
.w-info-btn.is-open {
  color: var(--gold);
}

.w-tooltip {
  position: absolute;
  top: calc(100% + 7px);
  right: -4px;
  width: 210px;
  background: var(--bg-panel);
  border: 1px solid rgba(74, 158, 255, 0.18);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.65;
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  text-align: left;
  white-space: normal;
}

.w-info-btn:hover .w-tooltip,
.w-info-btn.is-open .w-tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.widget-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.widget-row .widget { padding: 9px 10px; }
.widget-row .w-value { font-size: 20px; }

.w-sep {
  height: 1px;
  background: rgba(255,255,255,0.04);
  margin: 8px 0;
}

.progress-track {
  height: 3px;
  background: var(--bg-void);
  border-radius: 2px;
  margin-top: 8px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  box-shadow: 0 0 6px var(--gold-glow);
  transition: width 0.3s ease;
}

.progress-fill.danger {
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  box-shadow: 0 0 6px rgba(231,76,60,0.4);
}

/* ============================================================
   LIMITS — Custom Dropdown
============================================================ */
.limit-select {
  position: relative;
}

.limit-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.limit-trigger:hover,
.limit-trigger.open {
  border-color: var(--border-hi);
  background: var(--bg-surface);
}

.limit-trigger-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-dim);
}

.limit-trigger-icon svg {
  width: 12px; height: 12px;
}

.limit-trigger-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.limit-trigger-cap {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--gold-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.limit-chevron {
  width: 8px; height: 5px;
  color: var(--text-dim);
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.limit-trigger.open .limit-chevron {
  transform: rotate(180deg);
}

.limit-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: rgba(28, 28, 38, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  box-shadow:
    0 -6px 28px rgba(0,0,0,0.72),
    0 -2px 8px  rgba(0,0,0,0.88),
    0 1px 0     rgba(255,255,255,0.05) inset;
  overflow: hidden;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity  0.18s ease,
    transform 0.18s ease;
}

.limit-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.limit-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  transition: background 0.1s;
}

.limit-option:last-child {
  border-bottom: none;
}

.limit-option:hover {
  background: var(--bg-surface);
}

.limit-option.selected {
  background: var(--bg-deep);
}

.limit-option.selected .limit-opt-name {
  color: #4a9eff;
}

.limit-opt-icon {
  display: flex;
  align-items: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

.limit-opt-icon svg {
  width: 12px; height: 12px;
}

.limit-opt-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.limit-opt-cap {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Custom limit input */
.limit-custom-wrap {
  display: none;
  margin-top: 7px;
}

.limit-custom-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-void);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-inset);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  outline: none;
  caret-color: #4a9eff;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.limit-custom-input::-webkit-outer-spin-button,
.limit-custom-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.limit-custom-input:focus {
  border-color: rgba(74,158,255,0.3);
}

.limit-custom-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
  font-style: italic;
}

.limit-counter {
  margin-top: 8px;
}

.kw-row {
  display: flex;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  gap: 8px;
}

.kw-row:last-child { border-bottom: none; }

.kw-word {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  min-width: 52px;
  font-style: italic;
}

.kw-bar-track {
  flex: 1;
  height: 2px;
  background: var(--bg-void);
  border-radius: 1px;
}

.kw-bar-fill {
  height: 100%;
  border-radius: 1px;
  background: #4a9eff;
}

.kw-pct {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  transition: background 0.1s, box-shadow 0.1s, transform 0.08s, color 0.1s;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.btn-default {
  background: var(--bg-raised);
  color: var(--text-dim);
  border-color: var(--border-mid);
  box-shadow: var(--shadow-raised);
}

.btn-default:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-hi);
}

.btn-default:active {
  background: var(--bg-deep);
  color: var(--text-dim);
  box-shadow: var(--shadow-pressed);
  border-color: var(--border-dim);
  transform: translateY(1px);
}

.btn-gold {
  background: linear-gradient(180deg, #1a6fd4 0%, #1458b0 100%);
  color: #e8eaf0;
  border-color: rgba(0,0,0,0.4);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.12) inset,
    0 -1px 0 rgba(0,0,0,0.4) inset,
    0 4px 10px rgba(0,0,0,0.6),
    0 1px 3px rgba(0,0,0,0.8);
  font-weight: 500;
}

.btn-gold:hover {
  background: linear-gradient(180deg, #2a7fe8 0%, #1a6fd4 100%);
}

.btn-gold:active {
  background: linear-gradient(180deg, #1458b0 0%, #1a6fd4 100%);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}

.btn-danger {
  background: var(--bg-raised);
  color: #c0392b;
  border-color: rgba(192,57,43,0.2);
  box-shadow: var(--shadow-raised);
}

.btn-danger:hover {
  background: rgba(192,57,43,0.12);
  border-color: rgba(192,57,43,0.35);
}

.btn-danger:active {
  background: var(--bg-deep);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
  justify-content: flex-start;
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.case-grid .btn {
  font-size: 9.5px;
  padding: 7px 8px;
  justify-content: center;
}

/* ============================================================
   CENTER COLUMN
============================================================ */
.center-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

/* ============================================================
   TEXTAREA PANEL
============================================================ */
.textarea-panel {
  flex: 1;
  background: var(--bg-panel);
  border-radius: var(--r);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.textarea-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.09) 40%,
    rgba(255,255,255,0.09) 60%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

.textarea-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-dim);
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
  flex-shrink: 0;
  position: relative;
}

.chrome-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chrome-counter {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Font-size picker — absolutely centered in the chrome bar */
.font-size-control {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px 5px;
  background: var(--bg-void);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-inset);
  user-select: none;
}

.fs-btn {
  height: 20px;
  min-width: 24px;
  padding: 0 4px;
  border: none;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  opacity: 0.45;
  transition: background 0.12s, opacity 0.12s, color 0.12s;
}

.fs-btn:hover {
  opacity: 0.9;
  background: rgba(255,255,255,0.05);
  color: #4a9eff;
}

.fs-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#undo-btn,
#redo-btn {
  font-size: 13px;
  color: #ffffff;
  opacity: 1;
  background: var(--bg-raised);
  border-radius: 3px;
  box-shadow:
    0 2px 5px rgba(0,0,0,0.70) inset,
    0 1px 2px rgba(0,0,0,0.90) inset,
    0 1px 0   rgba(255,255,255,0.06);
  transition: all 0.2s ease;
}

#undo-btn:hover:not(:disabled),
#redo-btn:hover:not(:disabled) {
  box-shadow:
    0 2px 5px rgba(0,0,0,0.70) inset,
    0 1px 2px rgba(0,0,0,0.90) inset,
    0 1px 0   rgba(255,255,255,0.16),
    0 0 10px  rgba(255,255,255,0.10);
}

#undo-btn:disabled,
#redo-btn:disabled {
  opacity: 0.25;
  filter: grayscale(1);
}

.fs-btn.active {
  opacity: 1;
  background: var(--bg-raised);
  color: #4a9eff;
  box-shadow:
    0 2px 5px  rgba(0,0,0,0.70) inset,
    0 1px 2px  rgba(0,0,0,0.90) inset,
    0 0 7px    rgba(74,158,255,0.14) inset;
}

.fs-divider {
  width: 1px;
  height: 11px;
  background: var(--border-mid);
  flex-shrink: 0;
  margin: 0 4px;
}

.fs-scale {
  font-family: var(--font-ui);
  color: var(--text-dim);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  display: flex;
  align-items: center;
}

.fs-scale-min {
  font-size: 8.5px;
  font-weight: 400;
  padding: 0 1px;
}

.fs-scale-max {
  font-size: 15px;
  font-weight: 600;
  padding: 0 1px;
}

.main-textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.78;
  padding: 20px 22px;
  caret-color: var(--gold);
  box-shadow:
    0 2px 8px  rgba(0,0,0,0.7) inset,
    0 1px 3px  rgba(0,0,0,0.9) inset;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-raised) transparent;
}

.main-textarea::-webkit-scrollbar             { width: 6px; }
.main-textarea::-webkit-scrollbar-track       { background: transparent; }
.main-textarea::-webkit-scrollbar-thumb       { background: var(--bg-raised); border-radius: 3px; }
.main-textarea::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.main-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.7;
}

.main-textarea:focus {
  box-shadow:
    0 2px 8px  rgba(0,0,0,0.7) inset,
    0 1px 3px  rgba(0,0,0,0.9) inset,
    0 0 0 1px  rgba(74,158,255,0.12) inset;
}

/* ============================================================
   STATUS BAR
============================================================ */
.status-bar {
  height: 34px;
  background: var(--bg-panel);
  border-radius: var(--r);
  border: 1px solid var(--border-dim);
  box-shadow: var(--shadow-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  flex-shrink: 0;
  position: relative;
  grid-column: 2; /* center column on desktop */
  grid-row: 2;    /* below the editor, above nothing */
}

.status-cluster {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.status-pill strong {
  font-weight: 500;
  color: var(--text-dim);
}

.status-sep {
  width: 1px;
  height: 13px;
  background: var(--border-dim);
}

.legal-links {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legal-link {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.legal-link:hover { color: var(--text-dim); }

.legal-sep {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.35;
  user-select: none;
}

.status-local {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
  opacity: 0.7;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* ============================================================
   EXPORT — Floppy button + dropup
============================================================ */
.export-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.export-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #2564c2;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  transition: color 0.15s, opacity 0.15s, filter 0.15s;
}

.export-btn:hover {
  color: #4a9eff;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(74, 158, 255, 0.45));
}

.export-btn svg {
  width: 15px; height: 15px;
}

.export-dropup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: 130px;
  background: rgba(28, 28, 38, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-sm);
  box-shadow:
    0 -6px 24px rgba(0,0,0,0.70),
    0 -2px 8px  rgba(0,0,0,0.85),
    0 1px 0     rgba(255,255,255,0.05) inset;
  overflow: hidden;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity   0.18s ease,
    transform 0.18s ease;
}

.export-dropup.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.export-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  transition: background 0.1s, color 0.1s;
}

.export-option:last-child {
  border-bottom: none;
}

.export-option:hover:not(.export-placeholder) {
  background: rgba(255,255,255,0.04);
  color: #4a9eff;
}

.export-option svg {
  width: 11px; height: 11px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.coming-soon {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
  margin-left: 4px;
}

.export-placeholder {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.38;
}

/* Gold blink on successful export */
@keyframes export-blink {
  0%   { color: #2564c2; opacity: 0.6; }
  35%  { color: #4a9eff; opacity: 1;   filter: drop-shadow(0 0 7px rgba(74,158,255,0.65)); }
  100% { color: #2564c2; opacity: 0.6; }
}

.export-btn.blink {
  animation: export-blink 0.65s ease forwards;
}

/* ============================================================
   CLEAR MODAL
============================================================ */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(6px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);   }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px) brightness(0.4);
  -webkit-backdrop-filter: blur(10px) brightness(0.4);
  animation: backdrop-in 0.2s ease forwards;
}

.modal-backdrop[aria-hidden="true"] {
  display: none;
}

.modal {
  position: relative;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: rgba(20, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 32px 28px 26px;
  box-shadow:
    0 0 0 1px rgba(74, 158, 255, 0.08),
    0 24px 60px rgba(0, 0, 0, 0.85),
    0 8px  20px rgba(0, 0, 0, 0.70),
    0 1px  0    rgba(255,255,255,0.06) inset;
  animation: modal-in 0.22s cubic-bezier(0.34, 1.28, 0.64, 1) forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.modal-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(192, 57, 43, 0.12);
  border: 1px solid rgba(192, 57, 43, 0.22);
  display: flex; align-items: center; justify-content: center;
  color: #e74c3c;
  margin-bottom: 4px;
}

.modal-icon svg {
  width: 20px; height: 20px;
}

.modal-heading {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.02em;
  margin: 0;
}

.modal-body {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  margin: 0;
  max-width: 300px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}

.modal-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.modal-btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-mid);
}

.modal-btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-color: var(--border-hi);
}

.modal-btn-danger {
  background: rgba(192, 57, 43, 0.15);
  color: #e05a4a;
  border-color: rgba(192, 57, 43, 0.30);
}

.modal-btn-danger:hover {
  background: rgba(192, 57, 43, 0.28);
  border-color: rgba(192, 57, 43, 0.50);
  color: #ff6b5b;
}

/* ── About modal ─────────────────────────────────────────── */
.modal--about {
  width: 480px;
  align-items: flex-start;
  text-align: left;
  gap: 0;
  padding: 36px 32px 28px;
}

.modal--about .modal-heading {
  text-align: center;
  width: 100%;
  font-size: 16px;
  letter-spacing: 0.04em;
  margin-bottom: 22px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  padding: 5px;
  cursor: pointer;
  color: var(--text-dim);
  line-height: 0;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.about-section {
  width: 100%;
  margin-bottom: 18px;
}

.about-section-title {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 0 0 6px;
  font-weight: 500;
}

.modal--about .modal-body {
  text-align: left;
  max-width: none;
}

.about-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  width: 100%;
  margin-top: 10px;
  line-height: 1.75;
}

/* ── Privacy Policy modal ────────────────────────────────── */
.modal--policy {
  max-height: min(82vh, 680px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

.modal--policy::-webkit-scrollbar        { width: 4px; }
.modal--policy::-webkit-scrollbar-track  { background: transparent; }
.modal--policy::-webkit-scrollbar-thumb  { background: var(--gold-dim); border-radius: 2px; }

.policy-intro {
  text-align: left;
  max-width: none;
  margin-bottom: 6px;
}

.policy-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.policy-list li {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  padding-left: 14px;
  position: relative;
}

.policy-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--gold-dim);
}

.policy-list li strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   ACTIVE STATE OVERRIDES
   script.js injects .w-value.active and .kw-bar-fill styles with
   gold colors; override here with CVelio blue using !important.
============================================================ */
.w-value.active {
  color: #4a9eff !important;
  text-shadow:
    0 0 12px rgba(74, 158, 255, 0.35),
    0 0 24px rgba(74, 158, 255, 0.12) !important;
}

.kw-bar-fill {
  box-shadow: 0 0 4px rgba(74, 158, 255, 0.35) !important;
}

[data-theme="light"] .w-value.active {
  color: #1458b0 !important;
  text-shadow:
    0 0 12px rgba(74, 158, 255, 0.18),
    0 0 24px rgba(74, 158, 255, 0.08) !important;
}

/* ============================================================
   THEME TRANSITION — applied to structural containers only
   (interactive elements keep their own fast hover transitions)
============================================================ */
html, body,
.topbar, .panel, .panel-header, .panel-icon, .panel-title, .module-badge,
.widget, .w-value, .w-label, .w-sub, .w-unit,
.textarea-panel, .textarea-chrome, .main-textarea,
.status-bar, .ad-slot,
.logo-wordmark, .logo-mark, .privacy-badge,
.progress-track, .progress-fill, .kw-bar-fill,
.limit-trigger, .limit-dropdown, .limit-option, .limit-custom-input,
.export-btn, .export-dropup, .export-option,
.modal-backdrop, .modal, .modal-heading, .modal-body,
.blog-widget, .blog-widget-title, .blog-widget-cat, .blog-widget-excerpt {
  transition:
    background-color 0.4s ease,
    background       0.4s ease,
    color            0.4s ease,
    border-color     0.35s ease,
    box-shadow       0.4s ease;
}

/* ============================================================
   LIGHT THEME — Icy Ivory  [data-theme="light"]
============================================================ */
[data-theme="light"] {
  /* Backgrounds — inverted depth: void is lightest, surface is densest white */
  --bg-void:    #F2F0E9;
  --bg-deep:    #ECEAE4;
  --bg-panel:   rgba(255, 255, 255, 0.55);
  --bg-raised:  rgba(255, 255, 255, 0.75);
  --bg-surface: rgba(255, 255, 255, 0.92);

  /* Borders */
  --border-dim: rgba(74, 158, 255, 0.07);
  --border-mid: rgba(74, 158, 255, 0.12);
  --border-hi:  rgba(74, 158, 255, 0.20);

  /* Accent → CVelio Blue (light-mode tones) */
  --gold:       #1458b0;
  --gold-dim:   #2564c2;
  --gold-muted: rgba(74, 158, 255, 0.10);
  --gold-glow:  rgba(74, 158, 255, 0.22);

  /* Status green — slightly more vibrant on light */
  --green:      #27ae60;
  --green-glow: rgba(39, 174, 96, 0.30);

  /* Typography */
  --text-bright:  #0d1c3a;
  --text-primary: #1a3a6b;
  --text-dim:     #2a5a9a;
  --text-muted:   #7090b4;

  /* Shadows — soft elevation for light surfaces */
  --shadow-raised:
    0 1px 0   rgba(255,255,255,0.90) inset,
    0 -1px 0  rgba(74,158,255,0.06)   inset,
    0 1px 0   rgba(255,255,255,0.50),
    0 2px 8px rgba(74,158,255,0.10),
    0 1px 3px rgba(74,158,255,0.07);

  --shadow-inset:
    0 2px 5px rgba(74,158,255,0.07) inset,
    0 1px 2px rgba(74,158,255,0.05) inset,
    0 1px 0   rgba(255,255,255,0.70);

  --shadow-panel:
    0 1px 0    rgba(255,255,255,0.90) inset,
    0 -1px 0   rgba(74,158,255,0.04)   inset,
    0 6px 24px rgba(74,158,255,0.10),
    0 2px 6px  rgba(74,158,255,0.07),
    0 1px 0    rgba(255,255,255,0.50);

  --shadow-pressed:
    0 1px 4px rgba(74,158,255,0.10) inset,
    0 2px 8px rgba(74,158,255,0.07) inset,
    0 1px 0   rgba(255,255,255,0.40);
}

/* Body */
[data-theme="light"] body {
  background: var(--bg-void);
}

[data-theme="light"] body::after {
  opacity: 0.18;
  mix-blend-mode: multiply;
}

/* Topbar — frosted ivory */
[data-theme="light"] .topbar {
  background: rgba(242, 240, 233, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Panels + editor + status bar — frosted glass */
[data-theme="light"] .panel,
[data-theme="light"] .textarea-panel,
[data-theme="light"] .status-bar {
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

/* Pure white editor surface */
[data-theme="light"] .main-textarea {
  background: #FFFFFF;
  box-shadow:
    0 2px 6px rgba(74,158,255,0.06) inset,
    0 1px 2px rgba(74,158,255,0.04) inset;
}

[data-theme="light"] .main-textarea:focus {
  box-shadow:
    0 2px 6px rgba(74,158,255,0.06) inset,
    0 1px 2px rgba(74,158,255,0.04) inset,
    0 0 0 1px rgba(74,158,255,0.12) inset;
}

/* Logo mark — CVelio blue gradient */
[data-theme="light"] .logo-mark {
  background: linear-gradient(145deg, #2a7fe8 0%, #1458b0 100%);
}

[data-theme="light"] .logo-mark svg {
  fill: rgba(255, 255, 255, 0.88);
}

/* Theme button active state — CVelio blue glow */
[data-theme="light"] .theme-btn.active {
  color: #1458b0;
  box-shadow:
    0 2px 5px rgba(74,158,255,0.15) inset,
    0 1px 2px rgba(74,158,255,0.10) inset;
}

[data-theme="light"] .theme-btn.active svg {
  filter: drop-shadow(0 0 3px rgba(74,158,255,0.40));
}

/* Active metric numbers — CVelio blue */
[data-theme="light"] .w-value.active {
  color: #1458b0 !important;
  text-shadow:
    0 0 12px rgba(74,158,255,0.18),
    0 0 24px rgba(74,158,255,0.08);
}

/* Copy button (btn-gold) — CVelio blue */
[data-theme="light"] .btn-gold {
  background: linear-gradient(180deg, #2a7fe8 0%, #1458b0 100%);
  color: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.18) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 2px 6px rgba(74,158,255,0.25),
    0 1px 2px rgba(74,158,255,0.15);
}

[data-theme="light"] .btn-gold:hover {
  background: linear-gradient(180deg, #3a8ff8 0%, #2a7fe8 100%);
}

[data-theme="light"] .btn-gold:active {
  background: linear-gradient(180deg, #1458b0 0%, #2a7fe8 100%);
  box-shadow: var(--shadow-pressed);
}

/* Keyword density bar — CVelio blue */
[data-theme="light"] .kw-bar-fill {
  background: #1458b0;
  box-shadow: 0 0 3px rgba(74,158,255,0.25);
}

/* Font size picker active — CVelio blue */
[data-theme="light"] .fs-btn.active {
  color: #1458b0;
  box-shadow:
    0 2px 5px rgba(74,158,255,0.15) inset,
    0 1px 2px rgba(74,158,255,0.10) inset;
}

[data-theme="light"] .fs-btn:hover {
  color: #1458b0;
}

[data-theme="light"] #undo-btn,
[data-theme="light"] #redo-btn {
  color: #1a3a6b;
  box-shadow:
    0 2px 5px rgba(74,158,255,0.10) inset,
    0 1px 2px rgba(74,158,255,0.07) inset,
    0 1px 0   rgba(255,255,255,0.80);
}

[data-theme="light"] #undo-btn:hover:not(:disabled),
[data-theme="light"] #redo-btn:hover:not(:disabled) {
  box-shadow:
    0 2px 5px rgba(74,158,255,0.10) inset,
    0 1px 2px rgba(74,158,255,0.07) inset,
    0 1px 0   rgba(255,255,255,0.95),
    0 2px 10px rgba(74,158,255,0.18);
}

/* Limits dropdown — ivory frosted glass */
[data-theme="light"] .limit-dropdown {
  background: rgba(240, 238, 232, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .limit-option.selected .limit-opt-name {
  color: #2C3E50;
}

/* Export flyout — ivory frosted glass */
[data-theme="light"] .export-dropup {
  background: rgba(240, 238, 232, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .export-option:hover:not(.export-placeholder) {
  background: rgba(74,158,255,0.05);
  color: #2C3E50;
}

/* Floppy disk — CVelio blue in light */
[data-theme="light"] .export-btn {
  color: #1458b0;
  opacity: 0.6;
}

[data-theme="light"] .export-btn:hover {
  color: #1a6fd4;
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(74,158,255,0.40));
}

/* Modal — light frosted glass, keep red warning */
[data-theme="light"] .modal-backdrop {
  background: rgba(180, 178, 172, 0.35);
  backdrop-filter: blur(10px) brightness(0.88);
  -webkit-backdrop-filter: blur(10px) brightness(0.88);
}

[data-theme="light"] .modal {
  background: rgba(245, 243, 238, 0.97);
  border-color: rgba(74, 158, 255, 0.12);
  box-shadow:
    0 0 0 1px rgba(74,158,255,0.05),
    0 24px 60px rgba(74,158,255,0.18),
    0 8px  20px rgba(74,158,255,0.10),
    0 1px  0   rgba(255,255,255,0.90) inset;
}

[data-theme="light"] .modal-heading { color: #1a252f; }
[data-theme="light"] .modal-body    { color: #4a6680; }

[data-theme="light"] .modal-btn-ghost {
  color: #4a6680;
  border-color: rgba(74,158,255,0.15);
}

[data-theme="light"] .modal-btn-ghost:hover {
  background: rgba(74,158,255,0.06);
  color: #2C3E50;
  border-color: rgba(74,158,255,0.25);
}

/* ============================================================
   RESERVED / PLACEHOLDER WIDGET
============================================================ */
.widget-reserved {
  flex: 1;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  opacity: 0.25;
}

.shimmer {
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--bg-raised) 0%,
    var(--bg-surface) 50%,
    var(--bg-raised) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.reserved-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   BLOG WIDGET — Phase III · Latest from Blog
   Aqua / Mavericks gloss  +  neomorfic shadow system
============================================================ */
.blog-widget {
  display: block;
  position: relative;
  padding: 13px 14px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-mid);
  background: linear-gradient(
    175deg,
    var(--bg-raised) 0%,
    var(--bg-deep)   100%
  );
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  cursor: pointer;
  /* Neomorfic: inner highlight strip + outer depth stack */
  box-shadow:
    0  1px 0   rgba(255,255,255,0.07) inset,
    0 -1px 0   rgba(0,0,0,0.45)       inset,
    0  4px 14px rgba(0,0,0,0.50),
    0  1px 4px  rgba(0,0,0,0.72),
    0  1px 0    rgba(255,255,255,0.03);
  transition:
    box-shadow 0.28s ease,
    transform  0.18s ease;
}

/* Aqua gloss — liquid highlight band across the top half */
.blog-widget::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52%;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.08) 0%,
    rgba(255,255,255,0.025) 55%,
    transparent 100%
  );
  border-radius: var(--r-sm) var(--r-sm) 60% 60% / var(--r-sm) var(--r-sm) 24px 24px;
  pointer-events: none;
  z-index: 1;
}

/* Physical bottom-edge depth line */
.blog-widget::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(0,0,0,0.55);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  pointer-events: none;
}

.blog-widget:hover {
  transform: translateY(-1px);
  box-shadow:
    0  1px 0   rgba(255,255,255,0.10) inset,
    0 -1px 0   rgba(0,0,0,0.45)       inset,
    0  6px 22px rgba(0,0,0,0.56),
    0  2px 8px  rgba(0,0,0,0.76),
    0  1px 0    rgba(255,255,255,0.04),
    0  0 0 1px  rgba(77,184,255,0.14);
}

.blog-widget:active {
  transform: translateY(0);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.65) inset,
    0 1px 2px rgba(0,0,0,0.82) inset,
    0 1px 0   rgba(255,255,255,0.03);
}

/* ── Header row ────────────────────────────────── */
.blog-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  position: relative;
  z-index: 2;
}

.blog-widget-eyebrow {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.blog-widget-arrow {
  width: 11px; height: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.22s ease, color 0.22s ease;
}

.blog-widget:hover .blog-widget-arrow {
  transform: translate(2px, -2px);
  color: #4db8ff;
}

/* ── Body content ──────────────────────────────── */
.blog-widget-body {
  position: relative;
  z-index: 2;
}

.blog-widget-cat {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4db8ff;
  background: rgba(77,184,255,0.10);
  border: 1px solid rgba(77,184,255,0.22);
  border-radius: 3px;
  padding: 2px 7px;
  margin-bottom: 7px;
}

/* Post title — receives the Aqua multi-layer glow on hover */
.blog-widget-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-bright);
  margin: 0 0 7px;
  letter-spacing: 0.01em;
  transition:
    color      0.28s ease,
    text-shadow 0.28s ease;
}

.blog-widget:hover .blog-widget-title {
  color: #7acfff;
  text-shadow:
    0 0  4px rgba(77,184,255,0.80),
    0 0 10px rgba(77,184,255,0.50),
    0 0 22px rgba(77,184,255,0.24),
    0 0 40px rgba(77,184,255,0.10);
}

.blog-widget-meta {
  margin-bottom: 8px;
}

.blog-widget-date {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.blog-widget-excerpt {
  font-family: var(--font-ui);
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--text-dim);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Loading skeleton ──────────────────────────── */
.blog-widget-loading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.blog-widget-loading[hidden],
.blog-widget-content[hidden],
.blog-widget-error[hidden] { display: none !important; }

.blog-shimmer-row {
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--bg-raised) 0%,
    var(--bg-surface) 50%,
    var(--bg-raised) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
}

/* ── Error fallback ────────────────────────────── */
.blog-widget-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  opacity: 0.55;
  text-align: center;
}

/* ── Light theme overrides ─────────────────────── */
[data-theme="light"] .blog-widget {
  background: linear-gradient(
    175deg,
    rgba(255,255,255,0.90) 0%,
    rgba(236,234,228,0.80) 100%
  );
  border-color: var(--border-mid);
  box-shadow:
    0  1px 0   rgba(255,255,255,0.95) inset,
    0 -1px 0   rgba(74,158,255,0.06)   inset,
    0  4px 14px rgba(74,158,255,0.10),
    0  1px 4px  rgba(74,158,255,0.07),
    0  1px 0    rgba(255,255,255,0.60);
}

[data-theme="light"] .blog-widget::before {
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.72) 0%,
    rgba(255,255,255,0.22) 55%,
    transparent 100%
  );
}

[data-theme="light"] .blog-widget::after {
  background: rgba(74,158,255,0.07);
}

[data-theme="light"] .blog-widget:hover {
  box-shadow:
    0  1px 0   rgba(255,255,255,0.95) inset,
    0 -1px 0   rgba(74,158,255,0.06)   inset,
    0  6px 22px rgba(74,158,255,0.13),
    0  2px 8px  rgba(74,158,255,0.10),
    0  1px 0    rgba(255,255,255,0.70),
    0  0 0 1px  rgba(0,122,255,0.16);
}

[data-theme="light"] .blog-widget:active {
  box-shadow:
    0 1px 4px rgba(74,158,255,0.10) inset,
    0 2px 8px rgba(74,158,255,0.07) inset,
    0 1px 0   rgba(255,255,255,0.60);
}

[data-theme="light"] .blog-widget:hover .blog-widget-title {
  color: #0057b8;
  text-shadow:
    0 0  4px rgba(0,122,255,0.45),
    0 0 10px rgba(0,122,255,0.25),
    0 0 22px rgba(0,122,255,0.12);
}

[data-theme="light"] .blog-widget:hover .blog-widget-arrow {
  color: #0066cc;
}

[data-theme="light"] .blog-widget-cat {
  color: #0057b8;
  background: rgba(0,122,255,0.07);
  border-color: rgba(0,122,255,0.18);
}

[data-theme="light"] .blog-shimmer-row {
  background: linear-gradient(
    90deg,
    rgba(74,158,255,0.06) 0%,
    rgba(74,158,255,0.12) 50%,
    rgba(74,158,255,0.06) 100%
  );
  background-size: 200% 100%;
}

/* ============================================================
   RESPONSIVE — TABLET & MOBILE
   900px: tablet  |  767px: mobile
============================================================ */

/* ── Tablet ≤ 900px ──────────────────────────────────────── */
@media (max-width: 900px) {

  /* Two-column layout: analytics + editor, drop right transform panel */
  .app-shell {
    grid-template-columns: 200px 1fr;
  }

  .app-shell > .sidebar-col:nth-child(3) {
    display: none;
  }

  /* Absolute-centered badge collides with nav at mid-widths */
  .privacy-badge {
    display: none;
  }
}

/* ── Tablet portrait 768px–900px ────────────────────────── */
@media (min-width: 768px) and (max-width: 900px) {

  /* Three-column layout retained; right sidebar narrower than desktop */
  .app-shell {
    grid-template-columns: 200px 1fr 220px;
  }

  .app-shell > .sidebar-col:nth-child(3) {
    display: flex;
  }
}

/* ── Mobile ≤ 767px ──────────────────────────────────────── */
@media (max-width: 767px) {

  /* ── Enable page scroll ──────────────────────────────────── */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* ── App shell: fixed grid → scrollable vertical column ─── */
  .app-shell {
    position: static;       /* lift fixed positioning */
    display: flex;
    flex-direction: column;
    margin-top: var(--topbar-h);
    padding: 15px 15px 100px; /* 60px ad-slot bar + 40px breathing room */
    height: auto;
    gap: 24px;
  }

  /* All direct children fill full available width */
  .app-shell > .sidebar-col,
  .app-shell > .center-col {
    width: 100%;
    min-height: 0;
  }

  /* Writing-first order — status-bar is now a direct app-shell
     sibling in the HTML, so all four items order cleanly.       */
  .app-shell > .center-col              { order: 1; width: 100%; }
  .app-shell > .sidebar-col:nth-child(1) { order: 2; }
  .app-shell > .sidebar-col:nth-child(3) { order: 3; display: flex; }
  .app-shell > .status-bar              { order: 4; width: 100%; }

  /* Reset desktop grid placement — flex context ignores these,
     but explicit resets keep intent readable.                    */
  .sidebar-col { grid-row: unset; }
  .status-bar  { grid-column: unset; grid-row: unset; }

  /* ── Panels: let content dictate height ──────────────────── */
  /* .panel has overflow:hidden but no fixed height, so it grows
     naturally once panel-body is released from flex-stretch.    */
  .sidebar-col .panel {
    flex: unset;
  }

  .panel-body {
    flex: unset;
    height: auto;
    overflow-y: visible;
  }

  /* ── Editor: dominant workspace ──────────────────────────── */
  .textarea-panel {
    flex: unset;
    height: auto;
    min-height: 50vh;
  }

  /* ── Topbar ──────────────────────────────────────────────── */
  :root {
    --topbar-h: 48px;
  }

  .topbar {
    padding: 0 12px;
  }

  .logo-mark {
    width: 26px;
    height: 26px;
  }

  .logo-wordmark {
    font-size: 16px;
  }

  /* Icon-only nav: hide labels, keep SVGs */
  .nav-label {
    display: none;
  }

  .btn-nav {
    padding: 7px 9px;
    gap: 0;
  }

  /* Hide Blog — About stays as a tappable icon */
  .topbar-nav .btn-nav:last-child {
    display: none;
  }

  /* ── Status bar ──────────────────────────────────────────── */
  .status-bar {
    height: auto;
    min-height: 38px;
    padding: 7px 12px;
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Absolute-centered stats cluster and local badge would overlap */
  .status-cluster,
  .status-local {
    display: none;
  }

  /* Larger touch targets for Privacy / Terms links */
  .legal-links {
    gap: 10px;
  }

  .legal-link {
    font-size: 10px;
    padding: 5px 3px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  /* ── Modals ──────────────────────────────────────────────── */
  .modal {
    width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) transparent;
  }

  .modal::-webkit-scrollbar        { width: 4px; }
  .modal::-webkit-scrollbar-track  { background: transparent; }
  .modal::-webkit-scrollbar-thumb  { background: var(--gold-dim); border-radius: 2px; }

  .modal--about {
    width: 92vw;
    padding: 28px 20px 22px;
  }

  /* Scale headings to prevent awkward wrapping */
  .modal-heading,
  .modal--about .modal-heading {
    font-size: 14px;
  }

  .modal-body {
    font-size: 10.5px;
  }

  .about-tagline {
    font-size: 12px;
  }
}
