/* ── App Background ── */
.cadenze-bg {
  background:
    radial-gradient(circle at 50% -10%, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.08) 35%, transparent 60%),
    radial-gradient(circle at 50% 105%, rgba(120,150,255,0.20) 0%, rgba(120,150,255,0.07) 38%, transparent 65%),
    linear-gradient(120deg, transparent 30%, rgba(255,250,242,0.05) 45%, transparent 60%),
    linear-gradient(90deg, transparent 0%, rgba(255,252,247,0.06) 45%, rgba(255,252,247,0.06) 55%, transparent 100%),
    linear-gradient(180deg, var(--bg-base-top) 0%, var(--bg-base-mid) 45%, var(--bg-base-bottom) 100%);
  min-height: 100vh;
}

/* ── Grain Texture (shared pseudo-element) ── */
.cadenze-panel::after,
.cadenze-button::after,
.cadenze-tile::after,
.cadenze-theory::after,
.cadenze-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 150px 150px;
  border-radius: inherit;
}

/* ── Card center radial glow ── */
.cadenze-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.15) 0%, transparent 60%);
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

/* ── Panel Surface ── */
.cadenze-panel {
  background: linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%);
  border-radius: var(--panel-radius);
  border: 1px solid rgba(255,255,255,0.07);
  border-top: 1px solid rgba(255,255,255,0.15);
  border-bottom: 4px solid rgba(0,0,0,0.6);
  box-shadow:
    0 6px 24px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
}

/* ── Quick Start Button ── */
.cadenze-button {
  border-radius: var(--button-radius);
  border: 1px solid var(--button-stroke);
  box-shadow:
    0 8px 12px rgba(0,0,0,0.60),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -2px 4px rgba(0,0,0,0.35);
  position: relative;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* Convex dome highlight */
.cadenze-button::before {
  content: '';
  position: absolute;
  inset: 0;
  bottom: 60%;
  background: linear-gradient(180deg, rgba(255,255,255,0.10) 0%, transparent 100%);
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

.cadenze-button:active {
  transform: translateY(2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.60), inset 0 2px 8px rgba(0,0,0,0.40);
}

.cadenze-button--green { background: linear-gradient(180deg, var(--accent-green-top) 0%, var(--accent-green-bottom) 100%); }
.cadenze-button--amber { background: linear-gradient(180deg, var(--accent-amber-top) 0%, var(--accent-amber-bottom) 100%); }
.cadenze-button--teal  { background: linear-gradient(180deg, var(--accent-teal-top) 0%, var(--accent-teal-bottom) 100%); }

/* ── Stat Tile ── */
.cadenze-tile {
  background: linear-gradient(180deg, var(--tile-top) 0%, var(--tile-bottom) 100%);
  border-radius: var(--tile-radius);
  border: 1px solid var(--tile-stroke);
  box-shadow:
    var(--tile-shadow),
    inset 0 1px 0 rgba(255,255,255,0.12);
  position: relative;
}

/* ── Theory Card ── */
.cadenze-theory {
  background: linear-gradient(135deg, var(--theory-top) 0%, var(--theory-bottom) 100%);
  border-radius: var(--theory-radius);
  border: 1.5px solid var(--theory-stroke);
  box-shadow:
    inset 0 2px 6px rgba(139,105,20,0.20),
    inset 0 3px 12px rgba(255,255,255,0.12);
  position: relative;
}

/* ── Mini Tool Card ── */
.cadenze-card {
  border-radius: var(--card-radius);
  border: 1px solid var(--card-stroke);
  box-shadow:
    var(--card-shadow),
    inset 0 2px 6px rgba(255,255,255,0.14),
    0 8px 16px rgba(0,0,0,0.50);
  position: relative;
}

/* ═══════════════════════════════════════════════
   Integration for index.html
   Maps cadenze visual system onto existing app classes
   ═══════════════════════════════════════════════ */

/* ── 1. Body Background ── */
body {
  background:
    radial-gradient(circle at 50% -10%, rgba(255,255,255,0.20) 0%, transparent 60%),
    radial-gradient(circle at 50% 105%, rgba(120,150,255,0.20) 0%, transparent 65%),
    linear-gradient(180deg, #3a3430 0%, #26252a 45%, #14161a 100%);
}

/* ── Cards as panels ── */
.cd {
  background: linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%);
  border-radius: var(--panel-radius);
  border: 1px solid var(--panel-stroke);
  border-bottom: 1px solid var(--panel-stroke);
  border-top: 1px solid var(--panel-stroke);
  box-shadow:
    0 16px 24px rgba(0,0,0,0.80),
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -2px 8px rgba(0,0,0,0.30);
}

/* Grain on cards */
.cd::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 150px 150px;
  border-radius: inherit;
}

/* Override the panel-tint ::before for home cards */
.cd::before {
  background: none;
}

/* ── Section headers ── */
.ct {
  color: var(--text-primary);
}

/* ── 6. Bottom nav ── */
.bn {
  background: linear-gradient(180deg, rgba(34,34,40,1) 0%, rgba(26,26,30,1) 100%);
  border-top: 1px solid rgba(255,255,255,0.03);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.3);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.bn-cats button {
  color: rgba(255,255,255,0.35);
}

.bn-cats button.on {
  color: var(--nav-active);
}

/* Active tab amber underline */
.bn-cats button.on::after {
  background: #c4892a;
}

/* AI tab — visually prominent */
.bn-cats button[data-cat="ai"] {
  position: relative;
}

.bn-cats button[data-cat="ai"] svg {
  width: 26px;
  height: 26px;
}


/* AI tab glow */
.bn-cats button[data-cat="ai"]::before {
  content: '';
  position: absolute;
  width: 100px;
  height: 50px;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(155,148,245,0.90) 0%, rgba(155,148,245,0.33) 35%, rgba(155,148,245,0.09) 60%, transparent 100%);
  pointer-events: none;
  filter: blur(16px);
  z-index: -1;
}

/* ── 2. Quick Start tiles ── */
#homeQuick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }


/* ── 3. Recent Tools cards ── */
#homeRecent { display: flex; flex-direction: row; gap: 8px; overflow: visible; width: 100%; }
#homeRecent button { flex: 1; min-width: 0; max-width: 25%; }

#homeRecent .tool-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px 8px;
  text-align: center;
  border-radius: var(--card-radius, 12px);
  border: 1px solid var(--card-stroke, rgba(255,255,255,0.15));
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc, #78e8e0) 35%, rgba(40,40,50,1)) 0%, color-mix(in srgb, var(--pc, #78e8e0) 15%, rgba(20,20,28,1)) 100%);
  box-shadow: 0 6px 10px rgba(0,0,0,0.50), inset 0 2px 6px rgba(255,255,255,0.14);
  position: relative;
}

#homeRecent .tool-btn span {
  font-size: 6.5px;
  font-weight: 500;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  line-height: 1.3;
  white-space: nowrap;
}

#homeRecent .tool-btn svg {
  margin-bottom: 6px;
}

/* ── 4. Theory card — dark text on gold ── */
#fotdCard {
  background: linear-gradient(135deg, #e2d9bd 0%, #b6a27a 100%);
  border-radius: 16px;
  padding: 16px;
}

#fotdCard .theory-label,
#fotdCard #fotdLabel {
  color: #7a4a10;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#fotdCard .theory-title,
#fotdCard #fotdText {
  color: #1a0f00;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}

#fotdCard .theory-body,
#fotdCard #fotdDetail {
  color: #2a1800;
  font-size: 13px;
  line-height: 1.5;
}

/* ── 5. Stats tiles ── */
#homeStatsGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#homeStatsGrid .stat-box {
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.45);
}

#homeStatsGrid .stat-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

#homeStatsGrid .stat-label {
  font-size: 9px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Stats tiles (sunken) — fallback for .cd children ── */

/* ── Noise grain overlay on body ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  background-repeat: repeat;
}

/* ── Screen light source ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at 100% 0%, rgba(255,255,255,0.08) 0%, transparent 60%);
}
