/* ===== TT Home V3 Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Noto+Sans+SC:wght@300;400;500&family=Caveat:wght@400;500&display=swap');

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

/* ===== Theme Variables ===== */
:root {
    /* Light mode (default) */
    --bg-primary: #EDF2F7;
    --bg-gradient: linear-gradient(160deg, #E8F0F8 0%, #EDE8F0 35%, #E8F0F0 65%, #F2F0E8 100%);
    --glass-bg: rgba(255,255,255,0.42);
    --glass-bg-strong: rgba(255,255,255,0.62);
    --glass-border: rgba(255,255,255,0.45);
    --glass-blur: 20px;
    --glass-shadow: 0 8px 32px rgba(100,140,180,0.08);

    --accent: #6BA4C8;
    --accent-soft: #8BBDD9;
    --accent-glow: rgba(107,164,200,0.15);
    --warm: #E8C4A0;
    --warm-soft: #F0D4B4;
    --blush: #D4A0A0;
    --blush-soft: #E0B8B8;
    --mint: #A0C8B8;

    --text: #2A3A4A;
    --text-soft: #6A7A8A;
    --text-muted: #9AABB8;
    --text-on-accent: #FFFFFF;

    --card-radius: 20px;
    --btn-radius: 14px;
    --input-radius: 12px;

    --nav-height: 72px;
    --nav-bg: rgba(255,255,255,0.72);

    --period-color: #F2B5B5;
    --period-bg: rgba(242,181,181,0.15);

    --font-display: 'Cormorant Garamond', serif;
    --font-body: 'Noto Sans SC', sans-serif;
    --font-hand: 'Caveat', cursive;

    --particle-color-1: rgba(107,164,200,0.4);
    --particle-color-2: rgba(212,160,160,0.35);
    --particle-color-3: rgba(232,196,160,0.3);
}

/* Dark mode: Obsidian + Amber + Blush */
[data-theme="dark"] {
    --bg-primary: #0E1117;
    --bg-gradient: linear-gradient(160deg, #0E1117 0%, #141820 35%, #121418 65%, #161418 100%);
    --glass-bg: rgba(255,255,255,0.05);
    --glass-bg-strong: rgba(255,255,255,0.09);
    --glass-border: rgba(255,255,255,0.08);
    --glass-blur: 24px;
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.3);

    --accent: #7AB0D4;
    --accent-soft: #5A98C0;
    --accent-glow: rgba(122,176,212,0.1);
    --warm: #D4A870;
    --warm-soft: #C09860;
    --blush: #C48888;
    --blush-soft: #A07070;

    --text: #E0E8F0;
    --text-soft: #8A9AAA;
    --text-muted: #5A6A7A;

    --nav-bg: rgba(14,17,23,0.85);

    --particle-color-1: rgba(212,168,112,0.25);
    --particle-color-2: rgba(196,136,136,0.2);
    --particle-color-3: rgba(122,176,212,0.15);
}

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text);
    background: var(--bg-gradient);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: calc(var(--nav-height) + 16px);
    transition: background 0.5s, color 0.3s;
}

/* ===== Noise Texture ===== */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 128px;
    pointer-events: none;
    z-index: 9998;
}

[data-theme="dark"] body::after { opacity: 0.04; }

/* ===== Glass Card ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    transition: background 0.3s, border-color 0.3s;
}

.glass-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
}

/* ===== Typography ===== */
.font-display {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.font-hand {
    font-family: var(--font-hand);
    font-weight: 400;
}

.page-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--text);
    text-align: center;
    padding: 20px 0 4px;
}

.page-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--btn-radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.25s;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: var(--text-on-accent);
    box-shadow: 0 4px 16px rgba(107,164,200,0.2);
}
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text);
}

.btn-small {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 10px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 12px;
    border: none;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    color: var(--text-soft);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:active { transform: scale(0.9); }

/* ===== Inputs ===== */
.input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(107,164,200,0.15);
    border-radius: var(--input-radius);
    background: rgba(255,255,255,0.5);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: all 0.25s;
}
.input:focus {
    border-color: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
[data-theme="dark"] .input {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .input:focus {
    border-color: var(--accent);
}

textarea.input { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ===== Bottom Navigation ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 9999;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    letter-spacing: 0.5px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    padding: 8px 12px;
}

.nav-item.active { color: var(--accent); }

.nav-icon {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.2s;
}

.nav-item.active .nav-icon { transform: scale(1.1); }

/* Chat center button - raised circle */
.nav-item.nav-chat {
    position: relative;
    margin-top: -22px;
}

.nav-chat-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(107,164,200,0.35),
        0 0 0 4px var(--bg-primary);
    transition: all 0.3s;
}

.nav-chat-circle .nav-icon {
    color: white;
    font-size: 22px;
    filter: none;
}

.nav-item.nav-chat.active .nav-chat-circle {
    box-shadow:
        0 6px 24px rgba(107,164,200,0.45),
        0 0 0 4px var(--bg-primary);
    transform: scale(1.05);
}

.nav-item.nav-chat .nav-label {
    margin-top: 4px;
}

.nav-label { font-size: 10px; letter-spacing: 0.5px; }

/* ===== Floating Particles ===== */
.particle-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px 28px;
    color: var(--text);
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s;
    text-align: center;
    max-width: 80vw;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    padding: 20px;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    padding: 28px 24px;
    width: min(400px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.15);
    transform: translateY(10px);
    transition: transform 0.3s;
}
.modal-overlay.show .modal { transform: translateY(0); }

.modal-title {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

/* ===== Action Menu ===== */
.action-menu {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.action-menu .btn-icon { width: 32px; height: 32px; font-size: 14px; }

/* ===== Cards Grid ===== */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px;
}

.card-item {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s;
}
.card-item:active { transform: scale(0.98); }

.card-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.card-item-info {
    padding: 10px 12px;
}

.card-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-item-sub {
    font-size: 11px;
    color: var(--text-soft);
}

/* ===== Tag ===== */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 11px;
    background: var(--accent-glow);
    color: var(--accent);
    letter-spacing: 0.5px;
}

/* ===== Loading Spinner ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 14px;
}
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* ===== Small Lamp + Flower ===== */
.always-home {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    font-size: 18px;
    opacity: 0.5;
    z-index: 100;
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(232,196,160,0.4));
    animation: lamp-glow 4s ease-in-out infinite;
}
@keyframes lamp-glow {
    0%,100% { filter: drop-shadow(0 0 6px rgba(232,196,160,0.3)); opacity:0.45; }
    50% { filter: drop-shadow(0 0 14px rgba(232,196,160,0.6)); opacity:0.65; }
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    margin: 20px 0 12px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text);
    letter-spacing: 1px;
}

.section-more {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== Tab Bar ===== */
.tab-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--glass-bg);
    border-radius: 14px;
    margin: 0 16px 16px;
}

.tab-item {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 11px;
    background: transparent;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.25s;
    text-align: center;
}

.tab-item.active {
    background: var(--glass-bg-strong);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ===== Period Colors in Calendar ===== */
.period-day {
    background: var(--period-bg) !important;
    color: var(--blush) !important;
    border-radius: 50%;
}

.period-predicted {
    border: 1.5px dashed var(--blush-soft) !important;
    border-radius: 50%;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity:0; transform:translateY(12px); }
    to { opacity:1; transform:translateY(0); }
}

@keyframes fadeIn {
    from { opacity:0; }
    to { opacity:1; }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

/* Staggered children */
.stagger > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* ===== Utility ===== */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-soft { color: var(--text-soft); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-small { font-size: 12px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
