/* ========== Touhou / Hakurei Theme ========== */

:root {
    --primary: #c91634;
    --primary-dark: #7e0f22;
    --primary-soft: #f2d8d6;
    --vermillion: #e1462d;
    --paper: #fff8ea;
    --paper-deep: #f0dcc0;
    --gold: #e6b85c;
    --ink: #211713;
    --ink-soft: #65524a;
    --night: #1f1719;
    --cedar: #233a31;
    --sky: #3f6c8f;
    --success: #4e9a62;
    --warning: #d99a32;
    --error: #c83f3f;
    --info: #4d8fb5;
    --bg-card: rgba(255, 248, 234, 0.9);
    --bg-card-hover: rgba(255, 252, 244, 0.96);
    --text: var(--ink);
    --text-muted: var(--ink-soft);
    --border: rgba(126, 15, 34, 0.22);
    --border-strong: rgba(201, 22, 52, 0.48);
    --radius: 8px;
    --shadow: 0 18px 44px rgba(54, 22, 18, 0.18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
    line-height: 1.6;
    background:
        linear-gradient(rgba(255, 248, 234, 0.9), rgba(255, 248, 234, 0.86)),
        url("../images/gensokyo gate.png") center / cover fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(126, 15, 34, 0.07) 1px, transparent 1px),
        linear-gradient(rgba(126, 15, 34, 0.04) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, transparent 0, black 160px, black 100%);
}

.ambient-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient-mark {
    position: absolute;
    top: -12vh;
    left: var(--x);
    display: grid;
    place-items: center;
    opacity: 0;
    animation: ambientFall var(--duration) linear infinite;
    animation-delay: var(--delay);
    transform: translate3d(0, -12vh, 0);
}

.ambient-mark.charm {
    width: 22px;
    height: 42px;
    color: rgba(126, 15, 34, 0.44);
    background: rgba(255, 248, 234, 0.5);
    border: 1px solid rgba(126, 15, 34, 0.18);
    border-top: 4px solid rgba(201, 22, 52, 0.42);
    border-radius: 2px;
    font-size: 0.72rem;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(54, 22, 18, 0.08);
}

.ambient-mark.petal {
    width: 13px;
    height: 18px;
    background: rgba(255, 198, 205, 0.58);
    border-radius: 70% 30% 70% 30%;
    box-shadow: 0 0 12px rgba(255, 248, 234, 0.36);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ========== Navigation ========== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 24px;
    background: rgba(255, 248, 234, 0.86);
    border-bottom: 1px solid rgba(126, 15, 34, 0.18);
    box-shadow: 0 8px 24px rgba(54, 22, 18, 0.12);
    backdrop-filter: blur(16px);
}

.motion-ready .navbar {
    animation: shrineDrop 0.72s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
    font-size: 1.12rem;
    font-weight: 800;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--paper);
    font-size: 1.15rem;
    background: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    box-shadow: 0 5px 16px rgba(201, 22, 52, 0.28);
}

.motion-ready .brand-icon {
    animation: sealPulse 3.8s ease-in-out infinite;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--ink-soft);
    background: transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active,
.nav-link.router-link-active {
    color: var(--primary-dark);
    background: rgba(201, 22, 52, 0.08);
    border-color: rgba(201, 22, 52, 0.22);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 700;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-size: 0.94rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(100deg, transparent 18%, rgba(255, 248, 234, 0.42) 46%, transparent 72%);
    transform: translateX(-120%);
    transition: opacity 0.2s ease;
}

.btn {
    position: relative;
    overflow: hidden;
}

.btn:hover::after {
    opacity: 1;
    animation: buttonGleam 0.75s ease;
}

.btn-primary {
    color: var(--paper);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 10px 22px rgba(201, 22, 52, 0.28);
}

.btn-primary:hover {
    color: var(--paper);
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(201, 22, 52, 0.36);
}

.btn-secondary {
    color: var(--primary-dark);
    background: rgba(255, 248, 234, 0.74);
    border-color: rgba(126, 15, 34, 0.26);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    background: var(--paper);
    border-color: rgba(201, 22, 52, 0.42);
}

.btn-success {
    color: #fff;
    background: var(--success);
}

.btn-danger {
    color: #fff;
    background: var(--error);
}

.btn-sm {
    min-height: 34px;
    padding: 7px 14px;
    font-size: 0.84rem;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

/* ========== Home ========== */
.home-shell {
    background: var(--paper);
}

.home-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 86svh;
    overflow: hidden;
    isolation: isolate;
}

.home-hero-image {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 52% 50%;
    transform: translateY(var(--hero-shift, 0)) scale(1.04);
    animation: heroBreath 16s ease-in-out infinite alternate;
    will-change: transform;
}

.home-hero-shade {
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        linear-gradient(90deg, rgba(35, 18, 12, 0.72), rgba(35, 18, 12, 0.24) 48%, rgba(35, 18, 12, 0.08)),
        linear-gradient(0deg, rgba(35, 18, 12, 0.7), transparent 42%);
}

.home-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background:
        radial-gradient(circle at 72% 44%, rgba(255, 248, 234, 0.18), transparent 34%),
        repeating-conic-gradient(from 18deg at 72% 47%, rgba(255, 248, 234, 0.055) 0deg 2deg, transparent 2deg 18deg);
    opacity: 0.28;
    animation: spellRotate 34s linear infinite;
    mask-image: radial-gradient(circle at 72% 47%, #000 0 36%, transparent 66%);
}

.home-hero-content {
    position: relative;
    z-index: 3;
    width: min(760px, calc(100% - 48px));
    margin: 0 0 clamp(56px, 9vh, 104px) clamp(24px, 7vw, 112px);
    padding-top: 120px;
    color: var(--paper);
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}

.home-kicker,
.page-kicker,
.section-kicker {
    color: var(--gold);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.home-hero h1 {
    margin: 8px 0 16px;
    font-size: clamp(2.6rem, 7vw, 5.4rem);
    line-height: 1.04;
    font-weight: 900;
    animation: titleArrival 1.1s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.home-copy {
    max-width: 660px;
    color: rgba(255, 248, 234, 0.9);
    font-size: 1.1rem;
    animation: softRise 1.1s 0.12s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.home-prayer {
    max-width: 620px;
    margin-top: 14px;
    padding-left: 14px;
    color: rgba(255, 248, 234, 0.86);
    font-size: 0.98rem;
    font-weight: 700;
    border-left: 3px solid rgba(230, 184, 92, 0.8);
    animation: softRise 1.1s 0.22s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 28px;
}

.welcome-band {
    padding: 38px 24px 64px;
    background:
        linear-gradient(180deg, #fff8ea 0%, #f7ead5 100%);
    border-top: 4px solid var(--primary);
}

.welcome-inner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    width: min(1180px, 100%);
    margin: 0 auto;
}

.welcome-note {
    position: relative;
    min-height: 190px;
    padding: 24px 24px 22px;
    border: 1px solid rgba(126, 15, 34, 0.2);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 234, 0.86)),
        repeating-linear-gradient(90deg, rgba(126, 15, 34, 0.05) 0 1px, transparent 1px 14px);
    box-shadow: 0 14px 34px rgba(54, 22, 18, 0.1);
    transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.welcome-note::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent, rgba(230, 184, 92, 0.12), transparent);
    opacity: 0;
    transform: translateX(-40%);
}

.welcome-note:hover {
    transform: translateY(-5px);
    border-color: rgba(201, 22, 52, 0.34);
    box-shadow: 0 22px 42px rgba(54, 22, 18, 0.14);
}

.welcome-note:hover::after {
    opacity: 1;
    animation: paperSweep 0.9s ease;
}

.note-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 14px;
    color: var(--paper);
    font-weight: 900;
    background: var(--primary);
    border-radius: 50%;
}

.welcome-note h2 {
    margin-bottom: 8px;
    color: var(--primary-dark);
    font-size: 1.16rem;
}

.welcome-note p {
    color: var(--ink-soft);
    font-size: 0.96rem;
}

.devotion-section {
    position: relative;
    padding: 76px 24px 96px;
    background:
        radial-gradient(circle at 12% 8%, rgba(201, 22, 52, 0.16), transparent 34%),
        radial-gradient(circle at 88% 18%, rgba(63, 108, 143, 0.18), transparent 32%),
        linear-gradient(180deg, #f7ead5 0%, #fff8ea 34%, #f1d9c6 100%);
}

.devotion-section::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(126, 15, 34, 0.07) 1px, transparent 1px),
        linear-gradient(rgba(126, 15, 34, 0.04) 1px, transparent 1px);
    background-size: 46px 46px;
}

.devotion-intro {
    position: relative;
    z-index: 1;
    width: min(900px, 100%);
    margin: 0 auto 42px;
    text-align: center;
}

.devotion-intro h2 {
    margin: 8px 0 10px;
    color: var(--primary-dark);
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.16;
    font-weight: 900;
}

.devotion-intro p:last-child {
    color: var(--ink-soft);
    font-size: 1rem;
}

.devotion-item {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    min-height: 96svh;
    width: min(1120px, 100%);
    margin: 0 auto;
}

.devotion-panel {
    position: sticky;
    top: 82px;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(270px, 42%) minmax(0, 1fr);
    align-items: center;
    gap: clamp(24px, 5vw, 64px);
    width: 100%;
    min-height: min(720px, calc(100svh - 120px));
    padding: clamp(18px, 4vw, 44px);
    border: 0;
    border-radius: 0;
    background: transparent;
}

.devotion-panel::before {
    content: "";
    position: absolute;
    inset: 12% 0 10%;
    z-index: -1;
    pointer-events: none;
    border-top: 1px solid rgba(126, 15, 34, 0.18);
    border-bottom: 1px solid rgba(126, 15, 34, 0.13);
    background:
        linear-gradient(90deg, rgba(126, 15, 34, 0.72) 0 10px, rgba(255, 248, 234, 0.16) 10px 11px, transparent 11px 100%),
        linear-gradient(112deg, rgba(255, 248, 234, 0.1), rgba(201, 22, 52, 0.1) 42%, rgba(63, 108, 143, 0.09));
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.devotion-panel.reverse {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 42%);
}

.devotion-panel.reverse::before {
    background:
        linear-gradient(270deg, rgba(126, 15, 34, 0.72) 0 10px, rgba(255, 248, 234, 0.16) 10px 11px, transparent 11px 100%),
        linear-gradient(248deg, rgba(255, 248, 234, 0.1), rgba(201, 22, 52, 0.1) 42%, rgba(63, 108, 143, 0.09));
}

.devotion-panel.reverse img {
    order: 2;
}

.devotion-panel img {
    width: min(100%, 460px);
    max-height: calc(100svh - 166px);
    justify-self: center;
    object-fit: contain;
    object-position: center bottom;
    filter:
        drop-shadow(0 28px 26px rgba(54, 22, 18, 0.24))
        drop-shadow(0 0 18px rgba(255, 248, 234, 0.38));
    animation: girlFloat 5.8s ease-in-out infinite;
}

.devotion-copy {
    position: relative;
    align-self: center;
    padding: clamp(20px, 4vw, 40px);
    border-left: 2px solid rgba(126, 15, 34, 0.52);
    background:
        linear-gradient(90deg, rgba(255, 248, 234, 0.62), rgba(255, 248, 234, 0.22) 72%, transparent),
        repeating-linear-gradient(0deg, rgba(126, 15, 34, 0.04) 0 1px, transparent 1px 20px);
    box-shadow: 0 18px 38px rgba(54, 22, 18, 0.08);
    backdrop-filter: blur(6px);
}

.devotion-panel.reverse .devotion-copy {
    border-left: 0;
    border-right: 2px solid rgba(126, 15, 34, 0.52);
    background:
        linear-gradient(270deg, rgba(255, 248, 234, 0.62), rgba(255, 248, 234, 0.22) 72%, transparent),
        repeating-linear-gradient(0deg, rgba(126, 15, 34, 0.04) 0 1px, transparent 1px 20px);
}

.devotion-copy::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 22px;
    bottom: 22px;
    width: 3px;
    background: linear-gradient(180deg, rgba(201, 22, 52, 0.92), rgba(209, 170, 83, 0.92));
    border-radius: 999px;
}

.devotion-panel.reverse .devotion-copy::before {
    right: -8px;
    left: auto;
}

.devotion-name {
    margin-bottom: 14px;
    color: var(--primary-dark);
    font-size: clamp(1.45rem, 4vw, 2.4rem);
    line-height: 1.2;
    font-weight: 900;
}

.devotion-copy blockquote {
    color: var(--ink);
    font-size: clamp(1.08rem, 2.4vw, 1.55rem);
    line-height: 1.8;
    font-weight: 700;
}

.motion-reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.72s ease, transform 0.72s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.motion-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.motion-ready .status-card.is-visible {
    animation: cardWake 0.78s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.motion-ready .devotion-panel.is-visible .devotion-copy::before {
    animation: shrineLine 1.2s ease both;
}

@keyframes shrineDrop {
    from {
        opacity: 0;
        transform: translateY(-18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sealPulse {
    0%,
    100% {
        box-shadow: 0 5px 16px rgba(201, 22, 52, 0.28);
        transform: rotate(0deg);
    }
    50% {
        box-shadow: 0 5px 24px rgba(230, 184, 92, 0.38);
        transform: rotate(-4deg);
    }
}

@keyframes buttonGleam {
    from {
        transform: translateX(-120%);
    }
    to {
        transform: translateX(120%);
    }
}

@keyframes heroBreath {
    from {
        transform: translateY(var(--hero-shift, 0)) scale(1.04);
    }
    to {
        transform: translateY(calc(var(--hero-shift, 0) - 12px)) scale(1.08);
    }
}

@keyframes spellRotate {
    from {
        transform: rotate(0deg) scale(1);
    }
    to {
        transform: rotate(360deg) scale(1.04);
    }
}

@keyframes titleArrival {
    from {
        opacity: 0;
        transform: translateY(28px);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes softRise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes paperSweep {
    from {
        transform: translateX(-70%);
    }
    to {
        transform: translateX(70%);
    }
}

@keyframes girlFloat {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}

@keyframes cardWake {
    from {
        filter: saturate(0.8);
    }
    55% {
        filter: saturate(1.22);
    }
    to {
        filter: saturate(1);
    }
}

@keyframes shrineLine {
    from {
        transform: scaleY(0);
        transform-origin: top;
    }
    to {
        transform: scaleY(1);
        transform-origin: top;
    }
}

@keyframes ambientFall {
    0% {
        opacity: 0;
        transform: translate3d(0, -12vh, 0) rotate(0deg);
    }
    10% {
        opacity: 0.82;
    }
    90% {
        opacity: 0.66;
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--drift), 112vh, 0) rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }

    .ambient-layer,
    .home-hero::after {
        display: none !important;
    }

    .motion-reveal {
        opacity: 1;
        transform: none;
    }
}

/* ========== Page Layout ========== */
.page-container {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 96px 24px 48px;
}

.shrine-page {
    min-height: 100vh;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 24px 0 14px;
    border-bottom: 1px solid rgba(126, 15, 34, 0.22);
}

.page-title {
    margin-top: 4px;
    color: var(--primary-dark);
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 900;
}

.page-subtitle {
    max-width: 680px;
    margin-top: 8px;
    color: var(--text-muted);
}

.seal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 92px;
    min-width: 92px;
    height: 92px;
    color: var(--primary-dark);
    font-weight: 900;
    border: 3px double rgba(201, 22, 52, 0.5);
    border-radius: 50%;
    background: rgba(255, 248, 234, 0.72);
    transform: rotate(-8deg);
}

/* ========== Cards / Forms ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.card-title {
    color: var(--primary-dark);
    font-size: 1.28rem;
    font-weight: 900;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 7px;
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 800;
}

.form-input {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(126, 15, 34, 0.24);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-input:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(201, 22, 52, 0.13);
}

.form-input::placeholder {
    color: rgba(101, 82, 74, 0.62);
}

.inline-field {
    display: flex;
    gap: 8px;
}

/* ========== Modal / Toast ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(31, 23, 25, 0.64);
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(255, 252, 244, 0.98), rgba(255, 248, 234, 0.96));
    border: 1px solid rgba(201, 22, 52, 0.32);
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(22, 10, 8, 0.36);
    animation: modalIn 0.22s ease-out;
}

.wide-modal {
    max-width: 640px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(126, 15, 34, 0.18);
}

.modal-title {
    color: var(--primary-dark);
    font-size: 1.1rem;
    font-weight: 900;
}

.modal-close {
    width: 34px;
    height: 34px;
    color: var(--primary-dark);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: rgba(201, 22, 52, 0.08);
    border-color: rgba(201, 22, 52, 0.18);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px 20px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    max-width: 320px;
    padding: 12px 16px;
    color: #fff;
    font-weight: 800;
    word-break: break-word;
    border-radius: var(--radius);
    box-shadow: 0 16px 38px rgba(22, 10, 8, 0.22);
    animation: toastIn 0.24s ease-out;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(32px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== Dashboard ========== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.status-card {
    position: relative;
    overflow: hidden;
    min-height: 164px;
    padding: 20px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.status-card::after {
    content: "";
    position: absolute;
    right: -28px;
    bottom: -34px;
    width: 116px;
    height: 116px;
    border: 3px double rgba(201, 22, 52, 0.12);
    border-radius: 50%;
}

.status-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 20%, rgba(230, 184, 92, 0.14) 48%, transparent 72%);
    opacity: 0;
    transform: translateX(-60%);
}

.status-card:hover {
    transform: translateY(-4px);
    border-color: rgba(201, 22, 52, 0.32);
    box-shadow: 0 22px 42px rgba(54, 22, 18, 0.15);
}

.status-card:hover::before {
    opacity: 1;
    animation: paperSweep 0.85s ease;
}

.status-label {
    color: var(--primary-dark);
    font-size: 0.86rem;
    font-weight: 900;
}

.status-value {
    margin: 9px 0;
    color: var(--ink);
    font-size: 2.1rem;
    font-weight: 900;
}

.status-value.compact {
    font-size: 1.14rem;
    line-height: 1.35;
}

.status-detail {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.status-bar-bg {
    width: 100%;
    height: 9px;
    margin-top: 12px;
    overflow: hidden;
    background: rgba(126, 15, 34, 0.12);
    border-radius: 999px;
}

.status-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

.status-bar-fill.low { background: var(--success); }
.status-bar-fill.medium { background: var(--warning); }
.status-bar-fill.high { background: var(--error); }

.apps-panel {
    position: relative;
    overflow: hidden;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(255, 248, 234, 0.86), rgba(250, 229, 205, 0.72)),
        repeating-linear-gradient(90deg, rgba(126, 15, 34, 0.045) 0 1px, transparent 1px 28px);
    border: 1px solid rgba(126, 15, 34, 0.2);
}

.apps-panel::before {
    content: "";
    position: absolute;
    inset: 12px;
    pointer-events: none;
    border: 1px solid rgba(201, 22, 52, 0.12);
}

.apps-panel::after {
    content: "博丽";
    position: absolute;
    right: 22px;
    bottom: 16px;
    color: rgba(126, 15, 34, 0.12);
    font-size: 3rem;
    font-weight: 900;
    writing-mode: vertical-rl;
}

.apps-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.shrine-title {
    color: var(--primary-dark);
    font-size: clamp(1.45rem, 3vw, 2rem);
    letter-spacing: 0;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.shrine-action {
    gap: 8px;
    min-height: 38px;
    padding-inline: 12px 16px;
}

.action-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--paper);
    background: rgba(126, 15, 34, 0.88);
    border: 1px solid rgba(255, 248, 234, 0.58);
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1;
    box-shadow: inset 0 0 0 2px rgba(255, 248, 234, 0.14);
}

.btn-primary .action-mark {
    color: var(--primary-dark);
    background: rgba(255, 248, 234, 0.92);
}

.apps-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.app-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 176px;
    gap: 12px;
    padding: 18px;
    overflow: hidden;
    cursor: pointer;
    background:
        linear-gradient(180deg, rgba(255, 248, 234, 0.72), rgba(255, 241, 218, 0.52)),
        repeating-linear-gradient(0deg, rgba(126, 15, 34, 0.04) 0 1px, transparent 1px 18px);
    border: 1px solid rgba(126, 15, 34, 0.2);
    border-left: 4px solid rgba(201, 22, 52, 0.76);
    border-radius: 4px;
    box-shadow: 0 12px 28px rgba(54, 22, 18, 0.08);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.app-card::before {
    content: "";
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 10px;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(230, 184, 92, 0.72), transparent);
    opacity: 0.65;
}

.app-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(120deg, transparent 18%, rgba(255, 248, 234, 0.32) 46%, transparent 70%);
    opacity: 0;
    transform: translateX(-80%);
}

.app-card:hover {
    transform: translateY(-2px);
    background:
        linear-gradient(180deg, rgba(255, 248, 234, 0.9), rgba(255, 241, 218, 0.68)),
        repeating-linear-gradient(0deg, rgba(126, 15, 34, 0.045) 0 1px, transparent 1px 18px);
    border-color: rgba(201, 22, 52, 0.4);
    box-shadow: 0 18px 36px rgba(54, 22, 18, 0.12);
}

.app-card:hover::after {
    opacity: 1;
    animation: paperSweep 0.9s ease;
}

.app-card.auto-discovered:not(.confirmed) {
    border-color: rgba(63, 108, 143, 0.52);
    border-left-color: rgba(63, 108, 143, 0.78);
    background:
        linear-gradient(180deg, rgba(240, 249, 255, 0.74), rgba(255, 248, 234, 0.52)),
        repeating-linear-gradient(0deg, rgba(63, 108, 143, 0.05) 0 1px, transparent 1px 18px);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 74px;
}

.app-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    color: var(--paper);
    background:
        radial-gradient(circle at 50% 44%, rgba(255, 248, 234, 0.22), transparent 54%),
        var(--primary);
    border: 2px solid rgba(255, 248, 234, 0.7);
    border-radius: 4px;
    object-fit: cover;
    font-size: 1.3rem;
    box-shadow: 0 8px 18px rgba(126, 15, 34, 0.22);
}

.app-name {
    color: var(--ink);
    font-size: 1.04rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.app-desc {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid rgba(126, 15, 34, 0.12);
}

.app-tag {
    color: var(--info);
    font-size: 0.75rem;
    font-weight: 900;
}

.app-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 7px var(--success); }
.status-dot.offline { background: var(--error); }
.status-dot.unknown { background: var(--ink-soft); }
.status-dot.error { background: var(--warning); }

.app-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.app-card:hover .app-actions,
.app-card:focus-within .app-actions {
    opacity: 1;
}

.app-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    color: var(--primary-dark);
    background: rgba(255, 248, 234, 0.82);
    border: 1px solid rgba(126, 15, 34, 0.24);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 900;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.app-action-btn:hover {
    color: var(--paper);
    background: var(--primary);
    transform: translateY(-1px);
}

.app-action-btn.danger:hover {
    background: var(--primary-dark);
}

.prayer-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    background:
        radial-gradient(circle at 50% 48%, rgba(255, 248, 234, 0.72), rgba(255, 248, 234, 0.2) 34%, rgba(31, 23, 25, 0.62) 100%),
        rgba(31, 23, 25, 0.28);
    backdrop-filter: blur(5px);
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.prayer-overlay.active {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.prayer-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: min(420px, 92vw);
    min-height: min(520px, 76svh);
}

.prayer-ring {
    position: absolute;
    width: min(330px, 74vw);
    aspect-ratio: 1;
    border: 2px solid rgba(201, 22, 52, 0.42);
    border-radius: 50%;
    box-shadow:
        inset 0 0 0 10px rgba(255, 248, 234, 0.1),
        0 0 48px rgba(255, 248, 234, 0.42);
    animation: prayerPulse 1.5s ease-in-out infinite;
}

.prayer-ring::before,
.prayer-ring::after {
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px dashed rgba(126, 15, 34, 0.32);
    border-radius: 50%;
}

.prayer-ring::after {
    inset: 42px;
    border-style: solid;
    opacity: 0.45;
}

.prayer-girl {
    position: relative;
    z-index: 1;
    width: min(260px, 62vw);
    max-height: min(390px, 58svh);
    object-fit: contain;
    filter:
        drop-shadow(0 24px 28px rgba(22, 10, 8, 0.32))
        drop-shadow(0 0 18px rgba(255, 248, 234, 0.48));
    animation: prayerFloat 1.5s ease-in-out infinite;
}

.prayer-copy {
    position: absolute;
    left: 50%;
    bottom: 16px;
    z-index: 2;
    min-width: min(320px, 78vw);
    padding: 12px 18px;
    color: var(--paper);
    text-align: center;
    background: rgba(126, 15, 34, 0.78);
    border: 1px solid rgba(255, 248, 234, 0.42);
    border-radius: 4px;
    box-shadow: 0 18px 34px rgba(22, 10, 8, 0.24);
    transform: translateX(-50%);
}

.prayer-copy p {
    margin-bottom: 2px;
    font-size: 1.1rem;
    font-weight: 900;
}

.prayer-copy span {
    color: rgba(255, 248, 234, 0.82);
    font-size: 0.82rem;
}

@keyframes prayerPulse {
    0%,
    100% {
        transform: scale(0.96) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.03) rotate(8deg);
        opacity: 1;
    }
}

@keyframes prayerFloat {
    0%,
    100% {
        transform: translateY(4px);
    }
    50% {
        transform: translateY(-8px);
    }
}

.discover-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.discover-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(126, 15, 34, 0.2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.discover-item:hover,
.discover-item.selected {
    background: rgba(201, 22, 52, 0.08);
    border-color: rgba(201, 22, 52, 0.46);
}

.discover-item-info {
    flex: 1;
    min-width: 0;
}

.discover-item-name {
    margin-bottom: 2px;
    color: var(--ink);
    font-weight: 900;
}

.discover-item-url {
    color: var(--text-muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discover-item-check {
    color: var(--primary);
    font-weight: 900;
}

/* ========== Settings / Empty ========== */
.settings-section {
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    padding: 22px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.settings-section::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 20%, rgba(230, 184, 92, 0.12) 48%, transparent 72%);
    opacity: 0;
    transform: translateX(-70%);
}

.settings-section:hover {
    transform: translateY(-3px);
    border-color: rgba(201, 22, 52, 0.3);
    box-shadow: 0 22px 42px rgba(54, 22, 18, 0.14);
}

.settings-section:hover::after {
    opacity: 1;
    animation: paperSweep 0.85s ease;
}

.settings-section-title {
    margin-bottom: 18px;
    padding-bottom: 10px;
    color: var(--primary-dark);
    font-size: 1.1rem;
    font-weight: 900;
    border-bottom: 1px solid rgba(126, 15, 34, 0.16);
}

.settings-form {
    max-width: 520px;
}

.empty-state {
    padding: 52px 18px;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 14px;
    color: rgba(126, 15, 34, 0.72);
    font-size: 1.4rem;
    font-weight: 900;
    border: 2px solid rgba(126, 15, 34, 0.18);
    border-radius: 50%;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 248, 234, 0.4);
}

::-webkit-scrollbar-thumb {
    background: rgba(126, 15, 34, 0.25);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(126, 15, 34, 0.4);
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
    .welcome-inner {
        grid-template-columns: 1fr;
    }

    .devotion-panel,
    .devotion-panel.reverse {
        grid-template-columns: 1fr;
        gap: 12px;
        min-height: auto;
    }

    .devotion-panel::before,
    .devotion-panel.reverse::before {
        inset: 8% -12px 18%;
        background:
            linear-gradient(90deg, rgba(126, 15, 34, 0.58) 0 8px, rgba(255, 248, 234, 0.12) 8px 9px, transparent 9px 100%),
            linear-gradient(112deg, rgba(255, 248, 234, 0.08), rgba(201, 22, 52, 0.1) 46%, rgba(63, 108, 143, 0.08));
    }

    .devotion-panel.reverse img {
        order: 0;
    }

    .devotion-panel img {
        max-height: 48svh;
    }

    .devotion-panel.reverse .devotion-copy {
        border-right: 0;
        border-left: 2px solid rgba(126, 15, 34, 0.52);
        background:
            linear-gradient(90deg, rgba(255, 248, 234, 0.62), rgba(255, 248, 234, 0.22) 72%, transparent),
            repeating-linear-gradient(0deg, rgba(126, 15, 34, 0.04) 0 1px, transparent 1px 20px);
    }

    .devotion-panel.reverse .devotion-copy::before {
        right: auto;
        left: -8px;
    }

    .page-heading {
        align-items: flex-start;
    }

    .seal-badge {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar {
        height: 60px;
        padding: 0 12px;
    }

    .navbar-brand span:last-child {
        display: none;
    }

    .navbar-nav {
        gap: 4px;
    }

    .nav-link {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 0.84rem;
    }

    .navbar-actions {
        gap: 8px;
    }

    .btn {
        min-height: 40px;
        padding: 9px 15px;
    }

    .btn-sm {
        min-height: 32px;
        padding: 6px 10px;
    }

    .home-hero {
        min-height: 84svh;
    }

    .home-hero-image {
        object-position: 58% 50%;
    }

    .home-hero-content {
        width: calc(100% - 32px);
        margin: 0 16px 46px;
    }

    .home-copy {
        font-size: 1rem;
    }

    .home-prayer {
        font-size: 0.92rem;
    }

    .welcome-band {
        padding: 28px 14px 44px;
    }

    .devotion-section {
        padding: 48px 14px 64px;
    }

    .devotion-intro {
        margin-bottom: 20px;
    }

    .devotion-item {
        min-height: 92svh;
    }

    .devotion-panel {
        top: 70px;
        padding: 16px;
    }

    .devotion-copy {
        padding: 12px 12px 16px 18px;
    }

    .devotion-copy::before {
        top: 14px;
        bottom: 18px;
    }

    .page-container {
        padding: 82px 12px 36px;
    }

    .page-heading {
        margin-bottom: 18px;
        padding-top: 16px;
    }

    .page-title {
        font-size: 1.55rem;
    }

    .apps-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .inline-field {
        flex-direction: column;
    }

    .apps-grid,
    .status-grid {
        grid-template-columns: 1fr;
    }

    .modal-footer {
        flex-wrap: wrap;
    }
}
