/* Living Cosmic — premium cosmic UI */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --ink: #eaf0ff; --dim: #9fb0e0; --gold: #e8c888; --violet: #8f7fe8;
    --panel: rgba(13, 17, 38, .82); --line: rgba(165, 185, 245, .18);
    --accent: #7fa0ff;
}
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: #05060f;
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-app-region: no-drag;
}
body.transparent { background: transparent; }
#app { position: relative; width: 100vw; height: 100vh; }

#bgimg {
    position: absolute; inset: -4%; background-size: cover; background-position: center;
    display: none; transition: filter .3s;
}
#bg { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* ---------- top bar ---------- */
#topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(5,7,18,.75), rgba(5,7,18,0));
    pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-orb {
    width: 15px; height: 15px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffe9b0, #e8a94a 55%, #7a4a10);
    box-shadow: 0 0 14px 3px rgba(255, 205, 110, .45);
}
.brand-t { font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.brand-t b { color: var(--ink); font-weight: 600; }

.sky-toggle {
    display: flex; border: 1px solid var(--line); border-radius: 20px;
    overflow: hidden; background: rgba(10, 13, 30, .55); backdrop-filter: blur(8px);
}
.sky-toggle button {
    border: 0; background: transparent; color: var(--dim); font: 600 11.5px 'Segoe UI';
    padding: 7px 14px; cursor: pointer; letter-spacing: .06em;
}
.sky-toggle button.on { background: linear-gradient(135deg, #6a7fd8, #4a5fb0); color: #fff; }

.topbtns { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(12, 15, 32, .6); color: #ccd8f8;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; backdrop-filter: blur(8px);
    transition: transform .15s, background .2s, box-shadow .2s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#btnMoments svg path { fill: currentColor; stroke: none; }
.icon-btn:hover { background: rgba(44, 55, 100, .8); transform: scale(1.07); box-shadow: 0 0 16px rgba(127,160,255,.35); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 17px; }

/* ---------- left rail ---------- */
#rail {
    position: fixed; left: 10px; top: 50%; transform: translateY(-50%); z-index: 25;
    display: flex; flex-direction: column; gap: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
    padding: 8px 6px; backdrop-filter: blur(10px);
    box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
#rail button {
    width: 56px; padding: 8px 2px 6px; border: 0; border-radius: 12px; cursor: pointer;
    background: transparent; color: var(--dim);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    transition: background .2s, color .2s;
}
#rail .g { font-size: 17px; line-height: 1; font-family: Georgia, serif; }
#rail i { font-style: normal; font-size: 8px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
#rail button:hover { background: rgba(80, 100, 180, .25); color: var(--ink); }
#rail button.on { background: linear-gradient(160deg, rgba(110,130,220,.4), rgba(70,85,170,.35)); color: #fff; box-shadow: inset 0 0 0 1px rgba(160,180,255,.35), 0 0 14px rgba(110,140,255,.25); }

/* ---------- drawers ---------- */
#inspector, #moments {
    position: fixed; top: 60px; right: 10px; bottom: 96px; z-index: 26;
    width: 300px; max-width: calc(100vw - 90px);
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
    backdrop-filter: blur(12px); box-shadow: 0 12px 40px rgba(0,0,0,.5);
    transform: translateX(340px); transition: transform .3s cubic-bezier(.2,.8,.2,1);
    display: flex; flex-direction: column; overflow: hidden;
}
#inspector.open, #moments.open { transform: translateX(0); }
.ins-head {
    display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px;
    border-bottom: 1px solid var(--line);
}
.ins-glyph { font-size: 26px; font-family: Georgia, serif; filter: drop-shadow(0 0 8px currentColor); }
.ins-head b { font-size: 15px; letter-spacing: .04em; }
.ins-vedic { font-size: 11px; color: var(--dim); }
.ins-head .icon-btn { margin-left: auto; }
#insBody { flex: 1; overflow-y: auto; padding: 12px 14px; }
.ins-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed rgba(165,185,245,.1); }
.ins-row span:first-child { color: var(--dim); }
.ins-row b { font-weight: 500; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; padding: 2px 8px; border-radius: 10px; }
.badge.dir { background: rgba(110,200,140,.2); color: #9fe0b8; }
.badge.ret { background: rgba(255,120,110,.2); color: #ff9a92; }
.badge.sta { background: rgba(255,205,110,.2); color: #ffd27a; }
.ins-planets { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; padding: 8px 10px; border-top: 1px solid var(--line); }
.ins-planets button { border: 0; background: transparent; color: var(--dim); font-size: 15px; font-family: Georgia, serif; padding: 6px 0; cursor: pointer; border-radius: 8px; }
.ins-planets button:hover { background: rgba(90,110,200,.25); }
.ins-planets button.on { color: #fff; background: rgba(90,110,200,.3); }
.ins-actions { display: flex; gap: 8px; padding: 10px 12px 14px; }

#momList { flex: 1; overflow-y: auto; padding: 8px 12px; }
.mom {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-bottom: 6px;
    background: rgba(60,75,140,.18); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.mom:hover { background: rgba(80,100,190,.3); }
.mom .ic { font-size: 18px; }
.mom .inf { flex: 1; min-width: 0; }
.mom .lb { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mom .dt { font-size: 11px; color: var(--dim); }
.mom .del { border: 0; background: none; color: var(--dim); font-size: 15px; cursor: pointer; padding: 4px; }

/* ---------- bottom dock ---------- */
#dock {
    position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 30;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
    background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
    padding: 9px 14px; backdrop-filter: blur(12px);
    box-shadow: 0 10px 34px rgba(0,0,0,.5);
    max-width: calc(100vw - 20px);
}
.dt {
    border: 0; background: transparent; color: var(--ink); cursor: pointer; text-align: left;
    display: flex; flex-direction: column; line-height: 1.15; padding: 2px 6px; border-radius: 10px;
}
.dt:hover { background: rgba(90,110,200,.18); }
#dtBig { font-size: 14.5px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
#dtSmall { font-size: 10px; color: var(--dim); letter-spacing: .06em; text-transform: uppercase; }
.units { display: flex; gap: 3px; background: rgba(8,10,26,.6); border-radius: 12px; padding: 3px; }
.units button {
    border: 0; background: transparent; color: var(--dim); font: 600 11px 'Segoe UI';
    padding: 6px 9px; border-radius: 9px; cursor: pointer;
}
.units button.on { background: rgba(110,140,255,.35); color: #fff; }
.steppers { display: flex; align-items: center; gap: 6px; }
.stbtn, .speed {
    border: 1px solid var(--line); background: rgba(20,26,55,.6); color: var(--ink);
    border-radius: 12px; cursor: pointer; font-size: 17px; padding: 7px 13px;
    transition: background .15s, transform .1s;
}
.stbtn:hover { background: rgba(80,100,190,.4); }
.stbtn:active { transform: scale(.94); }
.speed { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 9px 11px; min-width: 74px; }
.play {
    width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
    background: linear-gradient(135deg, #8f7fe8, #4a5fb0); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 18px rgba(140,130,255,.45); transition: transform .15s, box-shadow .2s;
}
.play:hover { transform: scale(1.08); box-shadow: 0 0 26px rgba(140,130,255,.65); }
.play svg { width: 20px; height: 20px; fill: currentColor; }
.play.playing svg path { d: path('M6 4h4v16H6Zm8 0h4v16h-4Z'); }
.quick { display: flex; gap: 6px; }
.chip {
    border: 1px solid var(--line); background: rgba(20,26,55,.55); color: var(--dim);
    font: 700 10.5px 'Segoe UI'; letter-spacing: .08em; padding: 8px 11px; border-radius: 12px; cursor: pointer;
}
.chip:hover { color: #fff; background: rgba(80,100,190,.4); }

/* ---------- sheets ---------- */
#sheetWrap {
    position: fixed; inset: 0; z-index: 40; display: none;
    align-items: flex-end; justify-content: center;
    background: rgba(3,5,14,.6); backdrop-filter: blur(4px);
}
#sheetWrap.open { display: flex; }
.sheet {
    display: none; width: 100%; max-width: 430px; max-height: 82vh; overflow-y: auto;
    background: #10152e; border: 1px solid var(--line); border-bottom: 0;
    border-radius: 20px 20px 0 0; padding: 16px 18px 28px;
    animation: rise .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet.open { display: block; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; margin-bottom: 6px; }
.lbl { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--dim); margin: 14px 0 7px; }
.sheet input, .sheet select {
    width: 100%; background: #0a0e22; color: var(--ink);
    border: 1px solid var(--line); border-radius: 11px;
    padding: 10px 12px; font: 14px 'Segoe UI'; margin-bottom: 8px;
    color-scheme: dark;
}
.sheet input:focus, .sheet select:focus { outline: none; border-color: rgba(140,160,255,.6); }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; min-width: 0; }
.btn {
    display: block; width: 100%; margin-top: 8px; padding: 12px;
    border: 0; border-radius: 14px; cursor: pointer;
    background: linear-gradient(135deg, #7d8fe0, #4a5fb0); color: #fff;
    font: 600 13.5px 'Segoe UI'; letter-spacing: .05em;
    transition: transform .12s, filter .2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn.ghost { background: rgba(60,75,140,.25); border: 1px solid var(--line); color: var(--ink); }
.btn.ghost.on { border-color: var(--accent); color: #fff; box-shadow: 0 0 12px rgba(127,160,255,.25); }
.btn.danger { color: #ff9a92; }
.bgrow { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin-bottom: 8px; }
.bgsel {
    border: 1px solid var(--line); border-radius: 12px; padding: 18px 4px 8px; cursor: pointer;
    color: var(--dim); font: 600 10.5px 'Segoe UI'; letter-spacing: .05em; position: relative;
    background: rgba(10,14,32,.7);
}
.bgsel::before { content: ''; position: absolute; top: 5px; left: 8px; right: 8px; height: 8px; border-radius: 4px; }
.bgsel[data-bg="cosmic"]::before { background: linear-gradient(90deg, #2b1d5e, #583a8f, #1d3a6e); }
.bgsel[data-bg="aurora"]::before { background: linear-gradient(90deg, #0d4a3f, #26706a, #40348f); }
.bgsel[data-bg="image"]::before { background: linear-gradient(90deg, #6b5426, #8f7b3a, #3a5a6e); }
.bgsel[data-bg="glass"]::before { background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.45)); }
.bgsel[data-snd="off"]::before { background: linear-gradient(90deg, #333a52, #4a5170); }
.bgsel[data-snd="deep"]::before { background: linear-gradient(90deg, #1a2b5e, #3a2b6e); }
.bgsel[data-snd="temple"]::before { background: linear-gradient(90deg, #6e4a1d, #8f6b2b); }
.bgsel[data-snd="wind"]::before { background: linear-gradient(90deg, #1d5e5a, #2b7a8f); }
.bgsel[data-snd="custom"]::before { background: linear-gradient(90deg, #5e1d4a, #8f2b5e); }
.bgsel.on { border-color: var(--accent); color: #fff; box-shadow: 0 0 12px rgba(127,160,255,.3); }
.sliders label { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); }
.sliders input { flex: 1; margin: 0; padding: 0; }
.emojirow { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.emojirow button { border: 1px solid var(--line); background: rgba(10,14,32,.7); border-radius: 10px; font-size: 17px; padding: 7px 9px; cursor: pointer; }
.emojirow button.on { border-color: var(--gold); box-shadow: 0 0 10px rgba(232,200,136,.35); }

/* ---------- hint / status ---------- */
#hint {
    position: fixed; top: 62px; left: 50%; transform: translate(-50%, -10px); z-index: 35;
    font-size: 12.5px; color: #dce6ff; background: rgba(12,16,34,.9);
    padding: 8px 16px; border-radius: 20px; border: 1px solid rgba(165,185,245,.3);
    opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s;
    max-width: 88vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#statusline {
    position: fixed; left: 14px; bottom: 12px; z-index: 8;
    font-size: 11px; letter-spacing: .05em; color: rgba(190,205,245,.5);
    text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    #rail { left: 6px; gap: 3px; padding: 5px 4px; }
    #rail button { width: 46px; }
    #rail i { display: none; }
    #inspector, #moments { top: 56px; right: 6px; bottom: 132px; width: min(320px, calc(100vw - 60px)); }
    #dock { gap: 6px; padding: 8px 10px; bottom: 6px; }
    .quick .chip { padding: 8px 8px; }
    #dtBig { font-size: 12.5px; }
    .brand-t { display: none; }
    .sky-toggle button { padding: 6px 10px; }
}
/* live-wallpaper window mode (#live) — pure sky, no chrome */
body.wpchrome #topbar, body.wpchrome #rail, body.wpchrome #dock, body.wpchrome #moments,
body.wpchrome #inspector, body.wpchrome #detail, body.wpchrome #sheetWrap,
body.wpchrome #statusline, body.wpchrome #hint { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .sheet { animation: none; }
}
