/* ═══════════════════════════════════════════════════════════════════════
   Blüte · shared/glass.css  —  Botanical Study Desk & Wide-Screen System
   ────────────────────────────────────────────────────────────────────────
   Loaded AFTER each app's inline <style>, unifying all 8 Blüten + the Hub
   onto one coherent Japanese botanical stationery aesthetic and scaling
   gracefully from mobile up to 2860×1880 high-DPI wide displays:

   1) UNIFIED PAPER & INK. Every page shares the same warm paper canvas
      (#fbf7f9 in Light, #151219 in Dark) and high-contrast plum-charcoal
      ink (--text / --text-2 / --text-3), eliminating muddy tinted text
      or clashing background blobs.
   2) BOTANICAL ACCENTS PER BLOOM. Each flower (<body data-aurora="…">)
      sets a purposeful botanical accent (--accent, --accent-deep,
      --accent-soft, --accent-text) used for badges, active tabs, buttons,
      progress bars, and the top navigation bar's active indicator.
   3) CRISP ARCHITECTURAL CARDS. Solid, tactile paper cards with fine
      1.5px borders and subtle layered elevation instead of washed-out
      heavy blur or noisy grain.
   4) FLUID WIDE-SCREEN SCALING. Proportional root font scaling and
      multi-column Bento layouts that utilize wide screen real estate.
═══════════════════════════════════════════════════════════════════════ */

/* ── 1 · Base Root Typography (Respects Native OS/Browser DPI Scaling) ── */
html {
  font-size: 16px;
  background: var(--bg, #fbf7f9);
  overflow-x: clip;
  max-width: 100%;
}
body {
  overflow-x: clip;
  max-width: 100%;
}

/* ── 2 · Unified Surface & High-Contrast Ink Across All Apps ───────── */
:root,
body,
body[data-aurora] {
  --bg:           #fbf7f9;
  --card:         #ffffff;
  --card-soft:    #f6f1f4;
  --border:       #e5d8e0;
  --border-soft:  #efe6ec;

  --text:         #2b1d28;
  --text-2:       #5c4554;
  --text-3:       #88707f;

  --mint:         #5bbd96;   --mint-bg:    #e6f6ef;   --mint-tx:    #1b6647;
  --red:          #e6859d;   --red-bg:     #fcebef;   --red-tx:     #b03250;
  --gold:         #e3b660;   --gold-bg:    #fdf5e2;   --gold-tx:     #8a5a0b;
  --lav:          #b290e8;   --lav-bg:     #f2ebfc;   --lav-tx:     #56348f;
  --sun:          #e0a243;   --sun-bg:     #fdf3e1;   --sun-tx:     #8a5306;
  --sky:          #78b4e8;   --sky-bg:     #e8f3fc;   --sky-tx:     #22588a;
  --ipo:          #586bd1;   --ipo-bg:     #ebedfa;   --ipo-tx:     #2f40a1;
  --klee:         #2e8b57;   --klee-bg:    #e3f4ea;   --klee-tx:    #1b5e38;
  --lilie:        #6259c7;   --lilie-bg:   #eceafa;   --lilie-tx:   #3c3399;
  --glocke:       #3b82c4;   --glocke-bg:  #e5f1fc;   --glocke-tx:  #1d5791;

  --sha-sm:       0 1px 3px rgba(43, 29, 40, 0.05), 0 4px 12px rgba(43, 29, 40, 0.04);
  --sha-md:       0 2px 6px rgba(43, 29, 40, 0.06), 0 10px 24px -4px rgba(43, 29, 40, 0.08);
  --sha-lg:       0 4px 12px rgba(43, 29, 40, 0.08), 0 18px 36px -6px rgba(43, 29, 40, 0.12);
  --shadow-sm:    var(--sha-sm);
  --shadow-md:    var(--sha-md);
  --shadow-lg:    var(--sha-lg);
  --sha:          var(--sha-md);
}

/* ── Per-Bloom Botanical Accent Palettes (Light Mode) ──────────────── */
body[data-aurora="sakura"] {            /* 桜 Kirschblüte — Sakura Rose */
  --accent:       #e0538c;
  --accent-deep:  #c43872;
  --accent-soft:  #fde8f1;
  --accent-text:  #b02a61;
  --border:       #ead4df;
  --bloom-wash:   rgba(224, 83, 140, 0.06);
}
body[data-aurora="fuji"] {              /* 藤 Glyzinie — Wisteria Violet */
  --accent:       #7c5ce0;
  --accent-deep:  #6040c4;
  --accent-soft:  #efeafd;
  --accent-text:  #5234b0;
  --pink-100:     #efeafd;
  --pink-150:     #e2d8fb;
  --pink-200:     #cbbaf7;
  --pink-300:     #ab94f0;
  --border:       #dfd8ec;
  --border-soft:  #ece7f5;
  --bloom-wash:   rgba(124, 92, 224, 0.06);
}
body[data-aurora="klee"] {              /* 🍀 Klee — Botanical Clover Emerald */
  --accent:       #2e8b57;
  --accent-deep:  #216e43;
  --accent-soft:  #e3f4ea;
  --accent-text:  #1b5e38;
  --border:       #d2e5da;
  --border-soft:  #e5f0ea;
  --bloom-wash:   rgba(46, 139, 87, 0.06);
}
body[data-aurora="doushi"] {            /* 動 Winde — Morning Glory Indigo */
  --accent:       #4f64c9;
  --accent-deep:  #3b4fb0;
  --accent-soft:  #eaedfc;
  --accent-text:  #31439c;
  --border:       #d6dcf0;
  --border-soft:  #e7ebf7;
  --bloom-wash:   rgba(79, 100, 201, 0.06);
}
body[data-aurora="glocke"] {            /* 文 Glockenblume — Bellflower Blue */
  --accent:       #3b82c4;
  --accent-deep:  #2564a1;
  --accent-soft:  #e5f1fc;
  --accent-text:  #1d5791;
  --border:       #cfe0f0;
  --border-soft:  #e2edf7;
  --bloom-wash:   rgba(59, 130, 196, 0.06);
}
body[data-aurora="lilie"] {             /* 級 Lilie — Iris Slate-Violet */
  --accent:       #6258c4;
  --accent-deep:  #4c42ad;
  --accent-soft:  #eceafa;
  --accent-text:  #3f3599;
  --border:       #dbd8f0;
  --border-soft:  #eae8f7;
  --bloom-wash:   rgba(98, 88, 196, 0.06);
}
body[data-aurora="toki"] {              /* 時 Sonnenblume — Marigold Amber */
  --accent:       #d67d22;
  --accent-deep:  #b8630f;
  --accent-soft:  #fef1e1;
  --accent-text:  #994e06;
  --pink-200:     #f5cfa6;
  --border:       #eadbc8;
  --border-soft:  #f4ece0;
  --bloom-wash:   rgba(214, 125, 34, 0.06);
}
body[data-aurora="koe"] {               /* 声 Lavendel — Lavender Orchid */
  --accent:       #8856c9;
  --accent-deep:  #6d3dad;
  --accent-soft:  #f2eafc;
  --accent-text:  #5d2f99;
  --pink-150:     #e5d4f7;
  --pink-200:     #d4bbf2;
  --border:       #e1d6ed;
  --border-soft:  #eee7f6;
  --bloom-wash:   rgba(136, 86, 201, 0.06);
}
body[data-aurora="water"] {             /* 💧 Gießkanne — Garden Teal */
  --accent:       #288575;
  --accent-deep:  #1c695b;
  --accent-soft:  #e2f4f0;
  --accent-text:  #17594d;
  --border:       #d0e4e0;
  --border-soft:  #e4f0ee;
  --bloom-wash:   rgba(40, 133, 117, 0.06);
}

/* ── Explicit Dark Mode Tokens & Per-Bloom Accents ─────────────────── */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] body[data-aurora] {
  --bg:           #151219;
  --card:         #1f1a25;
  --card-soft:    #272130;
  --border:       #3d3247;
  --border-soft:  #31283a;
  --pink-50:      #241b29;
  --pink-100:     #2e2234;
  --pink-150:     #3a2940;
  --pink-200:     #543652;
  --pink-300:     #73466d;
  --vio-100:      #242238;
  --vio-150:      #2e2b47;
  --vio-200:      #413c63;

  --text:         #f6eef4;
  --text-2:       #cbb8c6;
  --text-3:       #b39fad;

  --accent:       #f06ea4;
  --accent-deep:  #e0538c;
  --accent-soft:  #382030;
  --accent-text:  #ff9ec7;

  --mint:         #3d9c77;   --mint-bg:    #193028;   --mint-tx:    #7ce8c2;
  --red:          #c75b73;   --red-bg:     #381e28;   --red-tx:     #ff9db2;
  --gold:         #b88b3b;   --gold-bg:    #332818;   --gold-tx:     #ffd88a;
  --lav:          #8465bd;   --lav-bg:     #282038;   --lav-tx:     #d9c2ff;
  --sun:          #b8862d;   --sun-bg:     #332717;   --sun-tx:     #ffd98a;
  --sky:          #4a7eb0;   --sky-bg:     #1b2b3a;   --sky-tx:     #9fd0ff;
  --ipo:          #5f70c9;   --ipo-bg:     #202540;   --ipo-tx:     #b5c2ff;
  --klee:         #3b9666;   --klee-bg:    #193024;   --klee-tx:    #85e8b4;
  --lilie:        #6d65c9;   --lilie-bg:   #22213d;   --lilie-tx:   #c4bfff;
  --glocke:       #66aae6;   --glocke-bg:  #1a2b3d;   --glocke-tx:  #a3d4ff;

  --sha-sm:       0 2px 8px rgba(0, 0, 0, 0.32);
  --sha-md:       0 8px 22px rgba(0, 0, 0, 0.44);
  --sha-lg:       0 14px 36px rgba(0, 0, 0, 0.56);
  --bloom-wash:   rgba(240, 110, 164, 0.06);
  color: var(--text);
  background: var(--bg);
}

html[data-theme="dark"] body[data-aurora="fuji"] {
  --accent: #9d82f2; --accent-deep: #7c5ce0; --accent-soft: #2a2240; --accent-text: #cfc0ff;
  --bloom-wash: rgba(157, 130, 242, 0.07);
}
html[data-theme="dark"] body[data-aurora="klee"] {
  --accent: #46ad75; --accent-deep: #2e8b57; --accent-soft: #1b3326; --accent-text: #88ebb6;
  --bloom-wash: rgba(70, 173, 117, 0.07);
}
html[data-theme="dark"] body[data-aurora="doushi"] {
  --accent: #7388eb; --accent-deep: #5569cf; --accent-soft: #202642; --accent-text: #b8c5ff;
  --bloom-wash: rgba(115, 136, 235, 0.07);
}
html[data-theme="dark"] body[data-aurora="glocke"] {
  --accent: #66aae6; --accent-deep: #3b82c4; --accent-soft: #1a2b3d; --accent-text: #a3d4ff;
  --bloom-wash: rgba(102, 170, 230, 0.07);
}
html[data-theme="dark"] body[data-aurora="lilie"] {
  --accent: #857ce8; --accent-deep: #665cc4; --accent-soft: #242240; --accent-text: #c6c2ff;
  --bloom-wash: rgba(133, 124, 232, 0.07);
}
html[data-theme="dark"] body[data-aurora="toki"] {
  --accent: #e89b42; --accent-deep: #c97b22; --accent-soft: #362818; --accent-text: #ffd296;
  --bloom-wash: rgba(232, 155, 66, 0.07);
}
html[data-theme="dark"] body[data-aurora="koe"] {
  --accent: #a87be6; --accent-deep: #8856c9; --accent-soft: #2c213d; --accent-text: #dfc7ff;
  --bloom-wash: rgba(168, 123, 230, 0.07);
}
html[data-theme="dark"] body[data-aurora="water"] {
  --accent: #42ab99; --accent-deep: #288575; --accent-soft: #19332f; --accent-text: #8ae8d8;
  --bloom-wash: rgba(66, 171, 153, 0.07);
}

/* ── 3 · Calm Botanical Stationery Canvas (No Floating Blobs/Noise) ── */
body {
  background: var(--bg) !important;
  color: var(--text);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  animation: none !important;
  transform: none !important;
  background:
    radial-gradient(90% 38% at 50% 0%, var(--bloom-wash, rgba(224, 83, 140, 0.06)) 0%, transparent 100%),
    var(--bg);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
  mix-blend-mode: normal;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── 4 · Crisp Architectural Cards (No Washed-Out Blur) ────────────── */
.card, .panel, .savebar, .bloom, .today, .bed, .quest-board, .q, .q-card, .result {
  background: var(--card);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-color: var(--border);
  box-shadow: var(--sha-sm);
}

.hero {
  color: var(--text);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .savebar,
html[data-theme="dark"] .bloom,
html[data-theme="dark"] .today,
html[data-theme="dark"] .bed,
html[data-theme="dark"] .quest-board,
html[data-theme="dark"] .q,
html[data-theme="dark"] .q-card,
html[data-theme="dark"] .result {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--sha-sm);
}

html[data-theme="dark"] header.top .hero,
html[data-theme="dark"] .wrap > .hero,
html[data-theme="dark"] .hero {
  background: linear-gradient(160deg, var(--card) 0%, var(--card-soft) 100%);
  border-color: var(--border);
}

.bloom:hover {
  box-shadow: var(--sha-md);
}

/* ── 5 · Responsive Layout Scaling (320px Mobile → 21:9 Ultrawide → 4K) ── */
/* Full-bleed flush sticky navbar even on apps that set padding on body */
body:has(> .blüte-nav) {
  padding: 0 !important;
}
body:has(> .blüte-nav) > .wrap,
body:has(> .blüte-nav) > #app {
  padding: clamp(12px, 2vw, 24px) clamp(12px, 2.5vw, 32px) 56px;
}
body:has(> .blüte-nav) > .pane {
  padding-left: clamp(12px, 2.5vw, 24px);
  padding-right: clamp(12px, 2.5vw, 24px);
}

.wrap,
.pane {
  max-width: min(1480px, 95vw) !important;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Keep focused active quiz/drill panes comfortable yet spacious on wide screens */
#screen-drill .pane,
#screen-results .pane,
#screen-quiz .pane,
#screen-summary .pane,
#game .pane,
#results .pane,
body[data-aurora="water"] .pane {
  max-width: min(920px, 94vw) !important;
}

/* Ultrawide (21:9 / 2560px–3440px) */
@media (min-width: 1921px) {
  html {
    font-size: clamp(16px, 0.72vw + 2px, 20px);
  }
  .wrap,
  .pane,
  .blüte-nav-inner {
    max-width: min(1920px, 90vw) !important;
  }
  #screen-drill .pane,
  #screen-results .pane,
  #screen-quiz .pane,
  #screen-summary .pane,
  #game .pane,
  #results .pane,
  body[data-aurora="water"] .pane {
    max-width: min(1080px, 86vw) !important;
  }
}

/* 4K / Super-Ultrawide (2800px–3840px+) */
@media (min-width: 2800px) {
  html {
    font-size: clamp(18px, 0.65vw + 1px, 24px);
  }
  .wrap,
  .pane,
  .blüte-nav-inner {
    max-width: min(2440px, 88vw) !important;
  }
  #screen-drill .pane,
  #screen-results .pane,
  #screen-quiz .pane,
  #screen-summary .pane,
  #game .pane,
  #results .pane,
  body[data-aurora="water"] .pane {
    max-width: min(1240px, 82vw) !important;
  }
}

/* Prevent flex/select collisions & unify pill/badge radii across all views */
:root {
  --r-pill:     11px;
  --r-seg:      14px;
  --r-seg-item: 10px;
  --r-badge:    8px;
}
.audio-strip > *,
.audio-bar-wrap > *,
.tabs > *,
.pill-row > * {
  min-width: 0;
}
select {
  max-width: 100%;
}
.tag,
.chip,
.filter-tag,
.furi-pill,
.quiz-chip,
.rad-pill,
.rad-act,
.srs-cmp-chip,
.blüte-audio-btn,
.blüte-audio-sel {
  border-radius: var(--r-pill, 11px);
}

@media (min-width: 1020px) {
  .choices {
    gap: 14px;
  }
  .choice {
    padding: 16px 18px;
    font-size: 1rem;
  }

  /* 桜 Kirschblüte (#menu setup screen): 2-column Bento layout */
  body[data-aurora="sakura"] #menu .pane {
    max-width: min(1280px, 92vw) !important;
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 18px;
    align-items: start;
  }
  body[data-aurora="sakura"] #menu .pane > .hero,
  body[data-aurora="sakura"] #menu .pane > .sp-btn,
  body[data-aurora="sakura"] #menu .pane > #best-scores,
  body[data-aurora="sakura"] #menu .pane > .foot {
    grid-column: 1 / -1;
  }
  body[data-aurora="sakura"] #menu .pane > .card + .card {
    margin-top: 0;
  }

  /* 時 Sonnenblume (#view-ref reference dashboard): multi-column reference grid */
  body[data-aurora="toki"] #view-ref.view.active {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 18px;
    align-items: start;
  }
  body[data-aurora="toki"] #view-ref.view.active > .chips,
  body[data-aurora="toki"] #view-ref.view.active > .foot {
    grid-column: 1 / -1;
  }
  body[data-aurora="toki"] #view-ref.view.active > .card + .card {
    margin-top: 0;
  }

  /* 声 Lavendel (#live pitch + resonance side-by-side & 2-col exercise grid) */
  body[data-aurora="koe"] #live.view.active {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 18px;
    align-items: start;
  }
  body[data-aurora="koe"] #live.view.active > .card + .card {
    margin-top: 0;
  }
  body[data-aurora="koe"] #exList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 12px;
  }
  body[data-aurora="koe"] #exList .ex + .ex {
    margin-top: 0;
  }
}

/* ── Accessible Keyboard Focus & Narrow-Viewport Toolbar Polish (T17) ─ */
button:focus-visible,
.tab:focus-visible,
.filter-tag:focus-visible,
.tag:focus-visible,
.chip:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  body:has(> .blüte-nav) > .wrap,
  body:has(> .blüte-nav) > #app {
    padding: 10px 12px 48px;
  }
  .tabs,
  .audio-strip,
  .filter-row,
  .vocab-filter,
  .pill-row,
  .chips {
    gap: 6px;
    flex-wrap: wrap;
  }
  .audio-strip {
    flex-direction: column;
    align-items: stretch;
  }
  .audio-strip > * {
    width: 100%;
    min-width: 0 !important;
  }
  .tab,
  .filter-tag,
  .tag,
  .chip {
    padding: 6px 10px;
    font-size: 0.78rem;
  }
}

/* Landscape short phones (e.g. 844×390) */
@media (max-height: 500px) and (orientation: landscape) {
  body:has(> .blüte-nav) > .wrap,
  body:has(> .blüte-nav) > #app {
    padding-top: 8px;
    padding-bottom: 28px;
  }
}
