/* START OF FILE style.css */

:root {
    /* Base Palette */
    --c-bg: #030303;
    --c-obsidian: rgba(20, 20, 24, 0.85);
    --c-obsidian-border: rgba(255, 255, 255, 0.08);
    --c-obsidian-highlight: rgba(255, 255, 255, 0.05);
    
    --c-text-main: #e8e8e8;
    --c-text-sec: #888888;
    
    /* Five Elements (Wu Xing) Palette - Refined */
    --c-wood: #66bb6a;   /* Growth, Spring */
    --c-fire: #ef6c00;   /* Action, Summer */
    --c-earth: #8d6e63;  /* Stability, Late Summer */
    --c-metal: #b0bec5;  /* Focus, Autumn */
    --c-water: #42a5f5;  /* Wisdom, Winter */

    --c-gold: var(--c-fire); 
    --c-gold-glow: rgba(239, 108, 0, 0.2);
    --c-water-glow: rgba(66, 165, 245, 0.3);

    /* Anki Colors */
    --c-anki-again: #e57373;
    --c-anki-hard: #fbc02d;
    --c-anki-good: #81c784;
    --c-anki-easy: #64b5f6;

    --nav-height: 80px;
    --nav-height-ios: 90px;
    
    --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-breath: cubic-bezier(0.45, 0, 0.55, 1);
    
    --font-serif: 'Zen Old Mincho', serif;
    --font-sans: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--c-bg);
    color: var(--c-text-main);
    font-family: var(--font-sans);
    height: 100vh; height: 100dvh; overflow: hidden;
    overscroll-behavior: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    user-select: none; -webkit-user-select: none;
}

/* Background Layers */
.ambient-bg { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
.fog-layer {
    position: absolute; inset: -50%;
    background: radial-gradient(circle at 50% 50%, rgba(30, 40, 50, 0.1), transparent 60%);
    animation: fogPulse 25s infinite ease-in-out;
}
@keyframes fogPulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 0.3; } }

.desktop-bg { display: none; position: fixed; inset: 0; z-index: -3; opacity: 0.1; background-size: cover; pointer-events: none; }

/* Layout & Container */
.app-container { width: 100%; height: 100%; position: relative; overflow: hidden; display: flex; flex-direction: column; }
@media (min-width: 768px) and (max-width: 1023px) {
    .app-container {
        max-width: 440px; height: 92vh; margin: 4vh auto;
        border: 1px solid var(--c-obsidian-border); border-radius: 40px;
        box-shadow: 0 40px 100px #000; background: #080808;
    }
}
@media (min-width: 1024px) {
    body {
        display: flex; align-items: center; justify-content: center;
        background: radial-gradient(circle at 50% 50%, #111, #000);
    }
    .desktop-bg { display: block; background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 50 Q 25 25 50 50 T 100 50' stroke='%23333' fill='none' stroke-width='0.5'/%3E%3C/svg%3E"); }
    .app-container {
        max-width: 1200px; height: 90vh; margin: auto;
        display: grid; grid-template-columns: 80px 1fr;
        border: 1px solid var(--c-obsidian-border); border-radius: 24px;
        background: rgba(8, 8, 8, 0.95); box-shadow: 0 0 150px rgba(0,0,0,0.8);
        overflow: hidden;
    }
    .bottom-nav {
        position: relative; inset: auto; width: 100%; height: 100%;
        flex-direction: column; justify-content: flex-start; padding-top: 40px; gap: 30px;
        border-right: 1px solid var(--c-obsidian-border); border-top: none; border-radius: 0;
        background: rgba(5,5,5,0.6);
    }
    .fab-wrapper { top: 0; margin: 20px 0; order: -1; } 
    .nav-label { display: none; }
    .view { position: relative; width: 100%; height: 100%; padding: 40px 60px; transform: none !important; opacity: 0; display: none; }
    .view.active { opacity: 1; display: block; animation: fadeIn 0.5s ease; }
    .kō-list { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-content: start; }
    .modal-backdrop { justify-content: center; align-items: center; }
    .modal-container { width: 500px; max-width: 500px; border-radius: 32px; box-shadow: 0 50px 100px rgba(0,0,0,0.8); transform: translateY(20px); }
    .garden-wrapper { height: 500px; }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Typography & Utils */
.serif-title { font-family: var(--font-serif); font-weight: 500; letter-spacing: 0.08em; }
.text-secondary { color: var(--c-text-sec); font-size: 0.85rem; line-height: 1.6; font-weight: 300; }
.small-text { font-size: 0.75rem; letter-spacing: 0.04em; }
.text-gold { color: var(--c-fire); }
.text-water { color: var(--c-water); }
.text-danger { color: #e57373; }
.text-shadow { text-shadow: 0 4px 12px rgba(0,0,0,0.6); }
.full-width { width: 100%; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.section-divider { border-bottom: 1px solid var(--c-obsidian-border); margin-bottom: 12px; padding-bottom: 4px; }
.flex-row { display: flex; align-items: center; gap: 12px; }
.justify-between { justify-content: space-between; }
.fade-in { animation: fadeIn 0.5s ease forwards; }
.w-label { display: inline-block; width: 80px; }

/* Components */
.glass-obsidian {
    background: var(--c-obsidian);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    border: 1px solid var(--c-obsidian-border);
    border-top: 1px solid var(--c-obsidian-highlight);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.button-primary {
    background: linear-gradient(135deg, var(--c-fire), #a6652e);
    color: #fff; border: none; padding: 16px 0; width: 100%; border-radius: 16px;
    font-weight: 600; font-size: 0.95rem; letter-spacing: 0.1em; cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: transform 0.2s, box-shadow 0.3s;
}
.button-primary:active { transform: scale(0.98); }

.button-outline {
    background: rgba(255,255,255,0.02); border: 1px solid var(--c-obsidian-border);
    color: var(--c-text-main); padding: 14px; border-radius: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.3s; width: 100%;
}
.button-outline:hover { border-color: var(--c-fire); color: var(--c-fire); }
.button-outline.text-danger:hover { border-color: #d64545; color: #d64545; background: rgba(214,69,69,0.1); }
.button-group-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.icon-btn { background: none; border: none; color: var(--c-text-sec); font-size: 1.1rem; cursor: pointer; transition: 0.3s; }
.glass-btn {
    background: rgba(255,255,255,0.03); border: 1px solid var(--c-obsidian-border);
    border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
    color: var(--c-text-main);
}
.small-btn { width: 40px; height: 40px; font-size: 0.9rem; }

/* Anki Buttons */
.anki-controls { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.anki-btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--c-obsidian-border);
    border-radius: 12px; padding: 10px 0; display: flex; flex-direction: column; align-items: center;
    cursor: pointer; transition: 0.3s; color: #ccc;
}
.anki-btn:active { transform: scale(0.95); }
.anki-label { font-size: 0.75rem; font-weight: 600; margin-bottom: 2px; }
.anki-time { font-size: 0.65rem; opacity: 0.7; }
.anki-btn.again { border-bottom: 2px solid var(--c-anki-again); }
.anki-btn.hard { border-bottom: 2px solid var(--c-anki-hard); }
.anki-btn.good { border-bottom: 2px solid var(--c-anki-good); }
.anki-btn.easy { border-bottom: 2px solid var(--c-anki-easy); }

/* AI Toast */
.ai-toast {
    position: fixed; bottom: 100px; right: 24px; width: 280px; z-index: 3000;
    animation: slideInToast 0.4s var(--ease-out-quint);
    border-left: 3px solid var(--c-fire);
}
.ai-toast.hidden { display: none; }
@keyframes slideInToast { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@media (min-width: 1024px) {
    .ai-toast { bottom: 40px; right: 40px; }
}

/* Views & Lists */
.view {
    position: absolute; inset: 0; padding: 20px 24px 120px 24px; overflow-y: auto; opacity: 0; pointer-events: none;
    transition: opacity 0.6s var(--ease-out-quint), transform 0.6s var(--ease-out-quint);
    transform: scale(0.96); scrollbar-width: none;
}
.view.active { opacity: 1; pointer-events: auto; transform: scale(1); z-index: 10; }
.view-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; padding-top: 60px; }

.kō-list { display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }

/* Modified Kō-Card */
.kō-card {
    width: 100%; height: 96px; background: linear-gradient(180deg, rgba(35,35,40,0.6), rgba(20,20,25,0.8));
    border: 1px solid var(--c-obsidian-border); border-radius: 20px; padding: 0 28px;
    display: flex; justify-content: space-between; align-items: center; cursor: pointer;
    transition: all 0.3s; position: relative; overflow: hidden;
    border-left: 3px solid transparent;
}
/* Elemental Task Styling */
.kō-card.deep { border-left-color: var(--c-fire); box-shadow: -5px 0 15px rgba(239, 108, 0, 0.05); }
.kō-card.calm { border-left-color: var(--c-water); box-shadow: -5px 0 15px rgba(66, 165, 245, 0.05); }

.kō-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.15); }
.kō-card.chain-active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c-wood); box-shadow: 2px 0 10px rgba(102, 187, 106, 0.4); }

/* Card Actions */
.card-actions { display: flex; align-items: center; gap: 16px; }
.card-play-btn { font-size: 1.2rem; padding: 10px; transition: 0.2s; }
.card-play-btn:hover { transform: scale(1.1); color: #fff; }
.edit-task-btn { padding: 10px; color: var(--c-text-sec); font-size: 1rem; opacity: 0.6; background: none; border: none; cursor: pointer; }
.edit-task-btn:hover { opacity: 1; color: var(--c-fire); }

.inventory-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.inv-item {
    background: rgba(255,255,255,0.02); border-radius: 12px; padding: 16px;
    display: flex; justify-content: space-between; align-items: center;
    border-left: 3px solid transparent; cursor: pointer; transition: 0.3s;
    position: relative; overflow: hidden;
}
.inv-item.deep { border-left-color: var(--c-fire); }
.inv-item.calm { border-left-color: var(--c-water); }

/* Mastery Visualization */
.inv-item[data-mastery="0"] { border-left-color: transparent; }
.inv-item[data-mastery="1"] { border-left-color: var(--c-metal); }
.inv-item[data-mastery="2"] { border-left-color: var(--c-water); }
.inv-item[data-mastery="3"] { border-left-color: var(--c-wood); }
.inv-item[data-mastery="4"] { border-left-color: var(--c-fire); box-shadow: 0 0 10px rgba(239, 108, 0, 0.1); }
.inv-item[data-mastery="5"] { border-left-color: var(--c-earth); border: 1px solid var(--c-earth); }

.card-decay::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='mold'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23mold)' opacity='0.4'/%3E%3C/svg%3E");
    opacity: 0.3; mix-blend-mode: overlay;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
    animation: moldPulse 10s infinite alternate;
}
@keyframes moldPulse { from { opacity: 0.2; } to { opacity: 0.4; } }
.decay-badge { background: #5a2e2e; color: #ffadad; padding: 2px 6px; border-radius: 4px; font-size: 0.6rem; margin-left: 8px; }

/* Garden */
.garden-wrapper { width: 100%; height: 400px; position: relative; border-radius: 32px; margin-bottom: 24px; overflow: hidden; background: #000; }
#garden-container { width: 100%; height: 100%; }
.garden-overlay-ui { position: absolute; bottom: 24px; left: 24px; right: 24px; display: flex; justify-content: space-between; pointer-events: none; }
.garden-edit-controls { position: absolute; top: 24px; left: 24px; z-index: 20; display: flex; align-items: center; }
.garden-edit-controls.active .glass-btn { border-color: var(--c-fire); color: var(--c-fire); background: rgba(207,168,127,0.1); }
.garden-stat .val { font-family: var(--font-serif); font-size: 2rem; display: block; text-align: right; text-shadow: 0 4px 10px #000; }

/* Renshi Canvas */
.renshi-map-container {
    width: 100%; height: calc(100vh - 280px); 
    position: relative; overflow: hidden; 
    border-radius: 24px;
}
#renshi-canvas { width: 100%; height: 100%; display: block; }
.renshi-overlay { position: absolute; bottom: 20px; right: 20px; opacity: 0.5; pointer-events: none; }

/* Nav & Overlays */
.bottom-nav {
    position: absolute; bottom: 24px; left: 20px; right: 20px; height: var(--nav-height);
    background: rgba(15,15,15,0.9); backdrop-filter: blur(20px);
    border: 1px solid var(--c-obsidian-border); border-radius: 40px;
    display: flex; justify-content: space-around; align-items: center; z-index: 100;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item { color: #555; display: flex; flex-direction: column; align-items: center; width: 60px; text-decoration: none; transition: 0.3s; }
.nav-item.active { color: var(--c-text-main); }
.nav-item.active i { color: var(--c-fire); text-shadow: 0 0 10px var(--c-gold-glow); }
.nav-label { font-size: 0.6rem; margin-top: 4px; opacity: 0; transform: translateY(5px); transition: 0.3s; }
.nav-item.active .nav-label { opacity: 1; transform: translateY(0); }
.fab-wrapper { position: relative; top: -35px; }
.fab-btn {
    width: 64px; height: 64px; border-radius: 50%; background: var(--c-text-main); color: #000;
    border: none; font-size: 1.4rem; box-shadow: 0 0 30px rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* Overlays */
.overlay-fullscreen {
    position: fixed; inset: 0; z-index: 2000; background: #000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.8s;
}
.overlay-fullscreen.active { opacity: 1; pointer-events: auto; }
.dynamic-gradient-bg { position: absolute; inset: 0; z-index: -1; background: #000; transition: background 1s ease; }
.focus-timer { font-size: 5rem; font-family: var(--font-serif); font-weight: 300; margin: 2rem 0; letter-spacing: 0.1em; }

/* Elemental Guide Grid */
.elemental-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.guide-card {
    background: rgba(255,255,255,0.03); border: 1px solid var(--c-obsidian-border);
    padding: 16px; border-radius: 16px; cursor: pointer; transition: 0.3s;
    display: flex; flex-direction: column; gap: 8px;
}
.guide-card i { font-size: 1.2rem; margin-bottom: 4px; }
.guide-card.el-wood { border-left: 2px solid var(--c-wood); }
.guide-card.el-fire { border-left: 2px solid var(--c-fire); }
.guide-card.el-earth { border-left: 2px solid var(--c-earth); }
.guide-card.el-metal { border-left: 2px solid var(--c-metal); }
.guide-card.el-water { border-left: 2px solid var(--c-water); }
.guide-card:active { transform: scale(0.98); background: rgba(255,255,255,0.06); }

/* Sleep Mode Visuals */
.overlay-fullscreen.mode-sleep .dynamic-gradient-bg { 
    background: #020202;
    background-image: radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px),
    radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 2px),
    radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    animation: starMove 200s linear infinite;
}
@keyframes starMove { from { transform: translateY(0); } to { transform: translateY(-550px); } }
.overlay-fullscreen.mode-sleep .focus-timer { color: #444; text-shadow: none; font-size: 3rem; }

.ritual-overlay {
    position: fixed; inset: 0; z-index: 2100; background: #020202;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 1s;
}
.ritual-overlay.active { opacity: 1; pointer-events: auto; }
.ritual-circle-container { position: relative; width: 300px; height: 300px; display: flex; align-items: center; justify-content: center; }
.ritual-circle {
    position: absolute; width: 100px; height: 100px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.1) 70%, transparent 100%);
    box-shadow: 0 0 40px rgba(255,255,255,0.3);
    opacity: 0.8; will-change: transform, opacity;
}
.ritual-text { font-family: var(--font-serif); font-size: 1.5rem; letter-spacing: 0.3em; margin-top: 40px; color: rgba(255,255,255,0.8); }

/* Inputs */
.input-wrapper-voice { position: relative; width: 100%; }
.voice-trigger { position: absolute; right: 0; top: 12px; color: var(--c-text-sec); cursor: pointer; padding: 10px; }
.pulse-input { border-bottom-color: var(--c-fire) !important; animation: pulseGlow 1.5s infinite; }
@keyframes pulseGlow { 0% { box-shadow: 0 5px 10px rgba(239, 108, 0, 0); } 50% { box-shadow: 0 5px 15px rgba(239, 108, 0, 0.3); } 100% { box-shadow: 0 5px 10px rgba(239, 108, 0, 0); } }
.input-clean { width: 100%; background: none; border: none; border-bottom: 1px solid #444; color: var(--c-text-main); font-size: 1.1rem; padding: 12px 30px 12px 0; outline: none; }
.toggle-wrapper { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-checkbox { appearance: none; width: 40px; height: 20px; background: #333; border-radius: 20px; position: relative; transition: 0.3s; }
.toggle-checkbox::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #777; border-radius: 50%; transition: 0.3s; }
.toggle-checkbox:checked { background: var(--c-fire); }
.toggle-checkbox:checked::after { transform: translateX(20px); background: #fff; }

/* Modal & Duration Config */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(15px); z-index: 999; opacity: 0; pointer-events: none; transition: 0.4s; display: flex; align-items: center; justify-content: center; }
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal-container { 
    width: 88%; max-width: 380px; 
    transform: scale(0.95) translateY(20px); transition: 0.4s var(--ease-elastic);
    position: relative;
}
.modal-backdrop.active .modal-container { transform: scale(1) translateY(0); }
.modal-header { 
    display: flex; justify-content: space-between; align-items: center; 
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    border-bottom: 1px solid var(--c-obsidian-border);
}
.modal-content-pad, .knead-content, .breath-config {
    padding: 24px;
}

.duration-config .button-group-row button { padding: 10px 0; border-radius: 12px; }

.memory-card-stage { perspective: 1000px; height: 340px; display: flex; justify-content: center; align-items: center; }
.memory-card { width: 220px; height: 320px; position: relative; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.4, 2, 0.5, 1); }
.memory-card.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; background: #080808; border: 4px solid #222; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.face.back { transform: rotateY(180deg); border-color: #5a2e2e; background: #1a0505; }
.hanafuda-inner { border: 1px solid rgba(255,255,255,0.1); width: 85%; height: 90%; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.card-text { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700; }

.reflection-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.reflect-btn { background: rgba(255,255,255,0.03); border: 1px solid var(--c-obsidian-border); color: var(--c-text-sec); border-radius: 12px; padding: 20px 0; font-family: var(--font-serif); cursor: pointer; transition: 0.3s; }
.reflect-btn:hover, .reflect-btn:active, .reflect-btn.selected { background: rgba(239, 108, 0, 0.1); border-color: var(--c-fire); color: var(--c-fire); }

.slider-group { margin-bottom: 16px; }
.slider-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: #888; margin-bottom: 6px; }
.range-slider { width: 100%; accent-color: var(--c-fire); }

/* History List */
.history-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.history-item { background: rgba(255,255,255,0.02); padding: 10px; border-radius: 8px; font-size: 0.75rem; border-left: 2px solid var(--c-text-sec); }
