:root {
    --radius: 8px;
    --radius-lg: 12px;
}

[data-theme="dark"], :root {
    --bg: #1f1633;
    --bg-deep: #150f23;
    --bg-card: rgba(255,255,255,0.06);
    --bg-hover: rgba(255,255,255,0.10);
    --text: #ffffff;
    --text-secondary: #e5e7eb;
    --text-tertiary: #9b9bb0;
    --accent: #c2ef4e;
    --purple: #6a5fc1;
    --muted: #79628c;
    --border: #362d59;
    --border-light: #584674;
    --shadow: rgba(0,0,0,0.3) 0px 10px 30px;
    --glass: rgba(255,255,255,0.08);
    --btn-today-text: var(--accent);
    --btn-today-hover-bg: var(--accent);
    --btn-today-hover-text: #1f1633;
    --today-bg: rgba(108,95,193,0.15);
    --today-border: var(--purple);
    --cal-today-num: var(--accent);
}

[data-theme="light"] {
    --bg: #f5f0eb;
    --bg-deep: #ede8e2;
    --bg-card: rgba(255,255,255,0.7);
    --bg-hover: rgba(0,0,0,0.04);
    --text: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-tertiary: #8a8a9a;
    --accent: #c96442;
    --purple: #6a5fc1;
    --muted: #e8e2dc;
    --border: #d6d0c8;
    --border-light: #c0b8b0;
    --shadow: rgba(0,0,0,0.08) 0px 4px 20px;
    --glass: rgba(255,255,255,0.6);
    --btn-today-text: var(--accent);
    --btn-today-hover-bg: var(--accent);
    --btn-today-hover-text: #ffffff;
    --today-bg: rgba(201,100,66,0.08);
    --today-border: var(--accent);
    --cal-today-num: var(--accent);
}

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

html { font-size: 16px; }

body {
    font-family: 'Rubik', -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ── Clock (fixed, below header) ── */

.clock-float {
    position: fixed;
    top: 60px;
    left: 16px;
    z-index: 100;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    border: 1px solid var(--border);
    min-width: 195px;
    line-height: 1.35;
}

.clock-float .clock-time {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Monaco', 'Menlo', monospace;
    letter-spacing: 0.5px;
}

.clock-float .clock-date {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
    letter-spacing: 0.3px;
}

.clock-float .clock-ganzhi {
    font-size: 12px;
    color: var(--accent);
    font-family: 'Rubik', sans-serif;
    margin-top: 2px;
    font-weight: 500;
}

.clock-float .clock-shichen {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'Rubik', sans-serif;
}

/* ── Header ── */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 48px;
}

.logo {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Rubik', sans-serif;
    letter-spacing: 0.3px;
}

.theme-btn {
    margin-left: auto;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
}
.theme-btn:hover {
    background: var(--bg-hover);
}

/* ── Main ── */



/* ── Hero ── */

.hero-xia {
    text-align: center;
    padding: 24px 0 12px;
    position: relative;
}

.hero-xia .xia-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.hero-xia .hero-main {
    font-family: 'Rubik', sans-serif;
    font-size: 56px;
    font-weight: 500;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.5px;
}

.hero-xia .hero-sub {
    font-size: 20px;
    color: var(--text-secondary);
    font-family: 'Rubik', sans-serif;
    margin-top: 8px;
    letter-spacing: 0.5px;
    font-weight: 400;
}

.cal-nav-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.cal-nav-toolbar .cal-nav-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: auto;
}

.cal-nav-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cal-nav-controls input {
    width: 82px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    font-family: 'Rubik', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    padding: 7px 8px;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.cal-nav-controls input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(106,95,193,0.15);
}

.cal-nav-unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-family: 'Rubik', sans-serif;
}

.cal-nav-controls select {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    font-family: 'Rubik', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    padding: 7px 28px 7px 10px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239b9bb0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.cal-nav-controls select:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(106,95,193,0.15);
}

.cal-nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    padding: 7px 10px;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
    font-family: 'Rubik', sans-serif;
}

.cal-nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.cal-today-btn {
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    margin-left: 4px;
    transition: background 0.15s, color 0.15s;
}

.cal-today-btn:hover {
    background: var(--accent);
    color: var(--dark-bg);
}

/* ── Calendar Nav ── */

.calendar-wrapper { margin-top: 8px; }

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.nav-title { display: flex; align-items: center; gap: 3px; }

.nav-title input {
    width: 72px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--glass);
    font-family: 'Rubik', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    padding: 3px 4px;
    outline: none;
    backdrop-filter: blur(8px);
}

.nav-title input:focus { border-color: var(--purple); }

.nav-title .nav-label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
}

.nav-title select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--glass);
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    color: var(--text);
    padding: 3px 6px;
    cursor: pointer;
    outline: none;
    backdrop-filter: blur(8px);
}

.nav-title select:focus { border-color: var(--purple); }

.nav-title .nav-xia-year {
    font-size: 11px;
    color: var(--accent);
    font-family: 'Rubik', sans-serif;
    margin-left: 8px;
    font-weight: 500;
}

.nav-today {
    border: 1px solid var(--muted);
    background: var(--glass);
    color: var(--text);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    backdrop-filter: blur(8px);
    transition: background 0.15s;
}

.nav-today:hover {
    background: var(--muted);
}

/* ── Calendar Grid ── */

.cal-grid {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-header {
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}

.cal-header span {
    padding: 7px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 5px 6px;
    min-height: 80px;
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}

.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell.cal-empty { min-height: 0; height: 0; padding: 0; border: none; cursor: default; }

.cal-cell:hover { background: var(--bg-hover); }

.cal-today {
    background: var(--today-bg);
    box-shadow: inset 0 0 0 2px var(--today-border);
}

.cal-past { background: transparent; }
.cal-future { background: transparent; }
.cal-festival { background: rgba(194,239,78,0.06); }

.cal-cell.cal-selected {
    background: rgba(108,95,193,0.25);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-day-lunar {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    font-family: 'Rubik', sans-serif;
    margin-bottom: 2px;
}

.cal-day-solar {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
    margin-bottom: 2px;
}

.cal-yiji-line {
    font-size: 9px;
    line-height: 1.4;
    margin-top: 1px;
    font-family: 'Rubik', sans-serif;
}

.cal-yiji-line .yi {
    display: block;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-yiji-line .ji {
    display: block;
    color: #ef4444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    padding: 0 5px;
    border-radius: 3px;
    margin-right: 2px;
    margin-top: 1px;
    line-height: 1.4;
}

.cal-tag-festival {
    background: rgba(251,191,36,0.15);
    color: #f59e0b;
}

.cal-tag-term {
    background: rgba(96,165,250,0.15);
    color: #60a5fa;
}

.cal-event {
    font-size: 9px;
    color: var(--text);
    cursor: pointer;
    background: var(--glass);
    border-radius: 4px;
    padding: 1px 4px;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s;
    font-family: 'Rubik', sans-serif;
}

.cal-event:hover { background: var(--bg-hover); color: var(--accent); }

.cal-festival-tag {
    font-size: 9px; color: var(--accent);
    font-weight: 500; margin-top: 1px;
    font-family: 'Rubik', sans-serif;
}

.cal-term {
    font-size: 9px; color: var(--purple);
    margin-top: 1px;
    font-family: 'Rubik', sans-serif;
}

/* ── Day Info Bar ── */

.day-info-bar {
    margin-top: 10px;
    padding: 10px 16px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 40px;
    font-family: 'Rubik', sans-serif;
}

.day-info-bar .info-lunar {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.day-info-bar .info-ganzhi {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.day-info-bar .info-solar {
    font-size: 12px;
    color: var(--text-tertiary);
}

.day-info-bar .info-yiji {
    font-size: 12px;
    color: var(--text-secondary);
}

.day-info-bar .info-yiji .yi { color: var(--accent); }
.day-info-bar .info-yiji .ji { color: var(--text-tertiary); }

.day-info-bar .info-empty {
    font-size: 12px;
    color: var(--text-tertiary);
    font-style: italic;
}

.cal-legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: 'Rubik', sans-serif;
}

.legend-item { display: flex; align-items: center; gap: 4px; }

.legend-dot {
    width: 7px; height: 7px; border-radius: 2px;
    display: inline-block;
}

.today-dot { background: var(--purple); }
.past-dot { background: var(--bg-hover); }
.future-dot { border: 1px solid var(--border); background: transparent; }

/* ── Drawer ── */

/* ── Error Pages ── */

.drawer {
    position: fixed; top: 0; right: 0; width: 100%; height: 100%;
    z-index: 1000; visibility: hidden; opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s;
}
.drawer.open { visibility: visible; opacity: 1; transition: visibility 0s, opacity 0.3s; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(20,20,19,0.5); }
.drawer-content {
    position: absolute; top: 0; right: 0; width: 420px; max-width: 92vw;
    height: 100%; background: var(--bg-deep);
    border-left: 1px solid var(--border);
    padding: 24px; overflow-y: auto;
    transform: translateX(100%); transition: transform 0.3s ease;
}
.drawer.open .drawer-content { transform: translateX(0); }
.drawer-close-btn {
    position: sticky; top: 0; float: right;
    background: none; border: none; color: var(--text-tertiary);
    font-size: 18px; cursor: pointer; padding: 4px 8px;
    z-index: 1;
}
.drawer-close-btn:hover { color: var(--text); }
.drawer-body h2 {
    font-size: 18px; font-weight: 500; color: var(--text);
    font-family: 'Rubik', sans-serif; margin-bottom: 2px;
}
.dr-weekday { font-size: 12px; color: var(--text-tertiary); display: block; margin-bottom: 12px; }
.dr-section { margin-bottom: 14px; }
.dr-section h3 {
    font-size: 11px; font-weight: 600; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 6px; padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    font-family: 'Rubik', sans-serif;
}
.dr-table { width: 100%; border-collapse: collapse; }
.dr-table td { padding: 3px 6px; font-size: 13px; color: var(--text-secondary); vertical-align: top; font-family: 'Rubik', sans-serif; }
.dr-table .dr-label { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; width: 1%; }
.dr-table-compact td { padding: 2px 6px; font-size: 12px; }
.dr-festival { color: #f59e0b; font-weight: 500; }
.dr-term { color: #60a5fa; font-weight: 500; }
.dr-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.dr-tag {
    font-size: 12px; padding: 2px 8px; border-radius: 4px;
    font-family: 'Rubik', sans-serif;
}
.dr-tag-yi { background: rgba(194,239,78,0.12); color: var(--accent); }
.dr-tag-ji { background: rgba(239,68,68,0.12); color: #ef4444; }
.dr-pengzu { font-size: 12px; color: var(--text-secondary); line-height: 1.5; font-family: 'Rubik', sans-serif; }
.dr-pending { font-size: 12px; color: var(--text-tertiary); font-style: italic; }

.error-section { display: flex; justify-content: center; align-items: center; min-height: 60vh; }

.error-card {
    text-align: center;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 400px;
    border: 1px solid var(--border);
}

.error-code {
    font-size: 56px; font-weight: 500;
    color: var(--accent);
    line-height: 1; margin-bottom: 10px;
    font-family: 'Rubik', sans-serif;
}

.error-message { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.error-description { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }

.error-link {
    display: inline-block;
    background: var(--muted); color: var(--text);
    padding: 8px 18px; border-radius: var(--radius);
    text-decoration: none; font-size: 13px; font-weight: 600;
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    border: 1px solid var(--border-light);
    box-shadow: rgba(0,0,0,0.1) 0px 1px 3px 0px inset;
}

.error-link:hover { background: var(--purple); }

.admin-link {
    display: inline-block;
    background: transparent;
    color: var(--accent);
    padding: 6px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Rubik', sans-serif;
    border: 1px solid var(--accent);
}

.admin-link:hover {
    background: var(--accent);
    color: var(--dark-bg);
}

/* ── Footer ── */

html, body { height: 100%; }

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.main-content {
    width: 100%;
    max-width: 920px;
    flex: 1;
    padding: 16px 20px 80px;
}

.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    text-align: center;
    background: var(--bg-deep);
    z-index: 40;
}
.footer-container { max-width: 1000px; margin: 0 auto; }
.footer-container p { font-size: 11px; color: var(--text-tertiary); }
.footer-meta { margin-top: 2px; }
.footer-meta strong { color: var(--accent); }

/* ── Responsive ── */

@media (max-width: 640px) {
    .clock-float { display: none; }
    .hero-xia .hero-main { font-size: 36px; }
    .hero-xia .hero-sub { font-size: 16px; }
    .cal-nav-toolbar { flex-direction: column; align-items: stretch; gap: 6px; }
    .cal-nav-toolbar .cal-nav-label { display: none; }
    .cal-nav-controls { justify-content: center; flex-wrap: wrap; }
    .cal-nav-controls input { width: 72px; font-size: 14px; padding: 6px 6px; }
    .cal-cell { min-height: 72px; padding: 4px; }
    .cal-day-lunar { font-size: 14px; }
    .cal-yiji-line .ji { display: inline; margin-left: 4px; }
    .drawer-content { width: 100vw; max-width: 100vw; }
    .nav-title .nav-xia-year { display: none; }
    .day-info-bar { flex-direction: column; gap: 4px; align-items: flex-start; }
}
