:root {
    --bg: #0d0b1f;
    --bg-2: #15122e;
    --card: #1c1840;
    --card-2: #241f52;
    --line: #3a3470;
    --text: #ece9ff;
    --muted: #a49fcb;
    --accent: #f5b942;
    --accent-2: #8f7cff;
    --good: #3ecf8e;
    --warn: #ff8a65;
    --radius: 14px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background:
        radial-gradient(900px 480px at 10% -8%, rgba(245, 185, 66, .12) 0%, transparent 55%),
        radial-gradient(1200px 600px at 80% -10%, #2a1f6b 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; margin: .4rem 0 1rem; }
h1:focus { outline: none; }
h2 { font-size: 1.25rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
small { color: var(--muted); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 1.2rem;
    padding: .7rem 1.2rem;
    background: rgba(13, 11, 31, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.brand-mark { color: var(--accent); }
.lang-picker { display: inline-flex; align-items: center; gap: .3rem; margin-inline-start: auto; }
.lang-picker select { width: auto; max-width: 11rem; padding: .3rem .5rem; font-size: .85rem; }

.nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--muted); padding: .4rem .75rem; border-radius: 999px; white-space: nowrap; font-size: .92rem;
}
.nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.nav a.active { color: #1a1433; background: var(--accent); font-weight: 600; }

.content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem 1.2rem 2rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; border-top: 1px solid var(--line); }

.card {
    background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }

.hero { padding: 1.5rem 0 1rem; }
.hero h1 { font-size: 2.2rem; margin: 0 0 .3rem; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); margin: 0; max-width: 640px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; margin: 1rem 0 1.4rem; }
.feature {
    display: flex; flex-direction: column; gap: .2rem;
    padding: 1rem; border-radius: var(--radius);
    background: linear-gradient(180deg, var(--card-2), var(--card));
    border: 1px solid var(--line); color: var(--text);
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.feature:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.feature span { font-size: 1.6rem; }

/* forms */
fieldset { border: 0; padding: 0; margin: 0 0 .5rem; min-width: 0; }
legend { font-weight: 600; color: var(--accent); margin-bottom: .4rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; min-width: 0; }
.field > span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; margin: 0; }
input, select {
    width: 100%; padding: .55rem .7rem;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(143, 124, 255, .25); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 .8rem; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

.place-picker { position: relative; }
.suggestions {
    position: absolute; z-index: 5; left: 0; right: 0; top: 4.2rem;
    list-style: none; margin: 0; padding: .3rem;
    background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
    max-height: 260px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.suggestions li { padding: .45rem .6rem; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.suggestions li:hover { background: var(--line); }
.suggestions li.online { color: var(--accent-2); border-top: 1px solid var(--line); justify-content: flex-start; gap: .5rem; }

button, .button {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line);
    background: var(--card-2); color: var(--text); font: inherit; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent-2); text-decoration: none; }
button.primary { background: linear-gradient(90deg, var(--accent), #f08a3c); color: #1a1433; border: 0; font-weight: 700; box-shadow: 0 6px 16px rgba(245, 185, 66, .25); }
button.ghost { background: transparent; }
button:disabled { opacity: .6; cursor: wait; }
.actions { display: flex; gap: .6rem; margin-top: .4rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: .35rem .85rem; color: var(--muted); }
.segmented button.on { background: var(--accent-2); color: #fff; }

.tabs { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: .55rem .9rem; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; }
.chip.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.chinese-hero { display: flex; gap: 1.2rem; align-items: center; margin-bottom: 1rem; }
.chinese-hero .animal { font-size: 4rem; line-height: 1; }
.chinese-hero h2 { margin: 0 0 .3rem; }
.pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.pillar { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .4rem; display: flex; flex-direction: column; align-items: center; text-align: center; }
.pillar small { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pillar .hanzi { font-size: 2.2rem; font-weight: 700; line-height: 1.2; margin-top: .3rem; }
.pillar .pinyin { color: var(--muted); font-size: .78rem; }
.el-wood { color: #4caf50; } .el-fire { color: #ff6b5b; } .el-earth { color: #d4a256; } .el-metal { color: #cfd8dc; } .el-water { color: #4fa3ff; }

.status { padding: .6rem .8rem; border-radius: 10px; margin-top: .6rem; }
.status.busy { color: var(--muted); }
.status.error { background: rgba(255, 138, 101, .12); border: 1px solid var(--warn); color: #ffc2ad; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: rgba(13, 11, 31, .45); }
table.data.compact td { padding: .3rem .6rem; }
table.data tr.asc-row td { color: var(--accent); }
table.data tr.running td { background: rgba(62, 207, 142, .1); }
.glyph { font-family: "Segoe UI Symbol", "Noto Sans Symbols", "DejaVu Sans", sans-serif; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.good { background: rgba(62, 207, 142, .15); color: var(--good); }
.badge.warn { background: rgba(255, 138, 101, .15); color: var(--warn); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: .6rem; }
.summary-grid > div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; display: flex; flex-direction: column; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.summary-grid strong { font-size: 1.1rem; }
.summary-grid span { color: var(--muted); font-size: .85rem; }

.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .4rem .8rem; }

/* charts */
.chart-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.chart-figure { margin: 0; display: flex; flex-direction: column; align-items: center; }
.chart-figure figcaption { color: var(--muted); margin-top: .4rem; font-size: .9rem; }

svg.kundli { width: 100%; max-width: 420px; background: var(--bg); border-radius: 12px; }
svg.kundli line, svg.kundli polygon, svg.kundli rect { stroke: var(--accent); stroke-width: 1.4; fill: none; }
svg.kundli text { fill: var(--text); font-size: 13px; text-anchor: middle; dominant-baseline: middle; }
svg.kundli text.sign-no { fill: var(--muted); font-size: 11px; }
svg.kundli text.asc { fill: var(--accent); font-weight: 700; }
svg.kundli polygon.asc-area { fill: rgba(245, 185, 66, .1); stroke: none; }

.kundli.south {
    width: 100%; max-width: 420px; aspect-ratio: 1;
    display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr);
    border: 1.5px solid var(--accent); border-radius: 12px; overflow: hidden; background: var(--bg);
}
.kundli.south .cell { border: 1px solid var(--line); padding: 4px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px 6px; font-size: 13px; }
.kundli.south .cell-sign { width: 100%; font-size: 10px; color: var(--muted); }
.kundli.south .asc-cell { background: rgba(245, 185, 66, .08); }
.kundli.south .asc { color: var(--accent); font-weight: 700; }
.kundli.south .center { grid-row: 2 / 4; grid-column: 2 / 4; display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: .5rem; }

svg.wheel { width: 100%; max-width: 480px; }
svg.wheel circle { fill: none; stroke: var(--line); stroke-width: 1.2; }
svg.wheel circle.ring-outer { stroke: var(--accent); fill: var(--bg); }
svg.wheel line.tick { stroke: var(--line); }
svg.wheel line.cusp { stroke: var(--line); stroke-dasharray: 3 3; }
svg.wheel line.cusp.angular { stroke: var(--accent); stroke-dasharray: none; stroke-width: 1.6; }
svg.wheel text { fill: var(--text); text-anchor: middle; dominant-baseline: central; }
svg.wheel text.glyph { font-size: 16px; }
svg.wheel text.sign-0 { fill: #ff8a65; }
svg.wheel text.sign-1 { fill: #a5d66f; }
svg.wheel text.sign-2 { fill: #8fd3ff; }
svg.wheel text.sign-3 { fill: #8f7cff; }
svg.wheel text.planet { fill: var(--accent); font-size: 18px; }
svg.wheel text.house-no { fill: var(--muted); font-size: 10px; }
svg.wheel text.angle-label { fill: var(--accent); font-size: 10px; font-weight: 700; }

/* horoscope */
.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.sign-tile { flex-direction: column; justify-content: center; padding: .6rem .3rem; font-size: .85rem; }
.sign-tile.on { border-color: var(--accent); background: rgba(245, 185, 66, .12); }
.sign-badge { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; }
.sign-badge img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.sign-badge .sign-glyph { font-size: 1.6rem; color: var(--accent); font-family: "Segoe UI Symbol", "Noto Sans Symbols", sans-serif; }
.sign-badge.large { width: 64px; height: 64px; }
.sign-badge.large .sign-glyph { font-size: 2.6rem; }
.headline { font-size: 1.05rem; color: var(--accent); }
.area-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; }
.area { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; }
.area header { display: flex; justify-content: space-between; }
.area p { margin: .4rem 0 0; color: #d6d2f5; }
.stars { color: var(--accent); letter-spacing: 2px; }
.lucky { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 1rem 0; color: var(--muted); }
.lucky strong { color: var(--text); }
details summary { cursor: pointer; color: var(--accent-2); margin: .4rem 0; }

/* dasha */
.dasha-list { display: flex; flex-direction: column; gap: .5rem; }
details.dasha { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .8rem; }
details.dasha.current { border-color: var(--good); }
details.dasha summary { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--text); }

/* match */
.score { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.score-ring {
    --p: 50;
    width: 120px; height: 120px; border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
    display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--card); }
.score-ring > * { position: relative; }
.score-ring strong { font-size: 1.8rem; line-height: 1; }
.person { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; margin-bottom: 1rem; }
.person h3 { margin-top: 0; }
.person p { margin: .2rem 0; }
.meter { display: inline-block; width: 70px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: .4rem; }
.meter span { display: block; height: 100%; background: var(--accent); }

/* numerology */
.number-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .8rem; }
.number { display: flex; gap: .9rem; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; }
.number .big { font-size: 2.2rem; font-weight: 800; color: var(--accent); min-width: 2.6rem; text-align: center; }
.number small, .number strong { display: block; }
.number p { margin: .3rem 0 0; color: #d6d2f5; font-size: .9rem; }

/* signs */
.signs-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.sign-card { display: flex; gap: 1rem; align-items: flex-start; margin: 0; }
.sign-card h2 small { font-weight: 400; }

/* settings */
.settings-form { max-width: 520px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: .6rem 1.2rem; background: #5a1f1f; color: #fff;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
#blazor-error-ui .reload { color: var(--accent); }

@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: stretch; gap: .5rem; padding: .6rem .8rem; }
    .content { padding: .8rem; }
    h1 { font-size: 1.5rem; }
    .hero h1 { font-size: 1.8rem; }
    .card { padding: .9rem; }
}
