/*
 * 两个占星体系共用的样式。体系自己的样式在 systems/<体系>/static/<体系>.css。
 *
 * 配色：莫兰迪色系——所有颜色都是低饱和、带灰度的同一暖灰家族，
 * 只有一套深色配色，全部集中在下面的变量里；其它地方只引用变量，不写死颜色。
 */
:root {
    color-scheme: dark;
    --bg: #1d1b19;
    --surface: #26231f;
    --field: #2d2a26;
    --subtle: #2f2b27;
    --border: #3b3732;
    --border-strong: #544e47;
    --text: #e6e0d8;
    --text-2: #c2bab0;
    --muted: #91897f;
    --accent: #b8a696;
    --accent-hover: #c8b8a9;
    --on-accent: #221f1c;
    --accent-soft: #3a342e;
    --danger: #d29890;
    --danger-soft: #3c2b28;

    --chart-line: #7a7066;
    --chart-num: #81796f;
    --hl-self: #4e4136;
    --hl-aspect: #36413a;
    --c-planet: #ece6de;
    --c-deg: #aba398;
    --c-cusp: #9cb0c0;
    --c-asc: #dc9a91;
    --c-retro: #e5776c;
    --hover: rgba(184, 166, 150, 0.14);
    --pop-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

/* ---------- 顶栏 ---------- */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    height: 56px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: 0.02em; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    margin-right: 4px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

/* ---------- 按钮 ---------- */

button, .ghost-btn, .primary-btn {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    background: var(--field);
    color: var(--text);
    transition: background 0.12s, border-color 0.12s;
}

button:hover { background: var(--accent-soft); }
button:disabled { opacity: 0.45; cursor: default; background: var(--field); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }

.ghost-btn {
    display: inline-block;
    text-decoration: none;
    font-size: 13px;
    background: transparent;
    color: var(--text-2);
}

.ghost-btn:hover { background: var(--accent-soft); color: var(--text); }

.primary-btn {
    padding: 7px 22px;
    font-weight: 600;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.primary-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.6; }

.small-btn { padding: 5px 10px; font-size: 13px; }

/* ---------- 布局 ---------- */

.layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
    max-width: 1800px;
    margin: 0 auto;
}

.sidebar, .content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* 宽屏时侧栏独立滚动：调参数时星盘始终留在视野里。 */
@media (min-width: 981px) {
    .sidebar {
        position: sticky;
        top: 72px;
        max-height: calc(100vh - 88px);
        overflow-y: auto;
        padding-right: 4px;
        scrollbar-width: thin;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
}

.panel h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.panel-head h2 { margin: 0; }

/* ---------- 表单 ---------- */

label {
    display: block;
    margin: 8px 0;
    font-size: 12px;
    color: var(--muted);
}

input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 7px 9px;
    font: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--field);
    color: var(--text);
}

input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 0;
    border-color: var(--border-strong);
}

select:disabled { opacity: 0.5; }

/* 下拉列表本身：Windows 上的 Chrome / Edge 用下拉框自己的底色和字色画弹出列表，
   透明底的下拉框（如档案库切换）会变成白底浅字，这里统一指定。 */
select option, select optgroup { background-color: var(--field); color: var(--text); }
select option:disabled { color: var(--muted); }
textarea { resize: vertical; }

input.invalid { border-color: var(--danger); background: var(--danger-soft); }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
}

.grid-2 label { margin: 6px 0; }
.stack label { margin: 6px 0; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-size: 13px;
}

.checkbox-row input { width: auto; margin: 0; accent-color: var(--accent); }

.button-row {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.button-row.four { grid-template-columns: repeat(4, 1fr); }

/* ---------- 分段选择（数据来源 / 星盘样式） ---------- */

.segmented {
    display: flex;
    padding: 3px;
    gap: 2px;
    border-radius: 8px;
    background: var(--subtle);
    border: 1px solid var(--border);
}

.segmented label {
    flex: 1 1 0;
    margin: 0;
    position: relative;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 6px 4px;
    text-align: center;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}

.segmented span:hover { color: var(--text); }

.segmented input:checked + span {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.segmented input:focus-visible + span { outline: 2px solid var(--border-strong); }

.segmented.compact { display: inline-flex; }
.segmented.compact span { padding: 4px 14px; }

.info-line {
    margin: 8px 2px 0;
    font-size: 12px;
    color: var(--muted);
}

.info-line:empty { display: none; }

/* ---------- 折叠面板 ---------- */

.fold > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.fold > summary::-webkit-details-marker { display: none; }

.fold > summary::before {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s;
    flex: 0 0 auto;
    margin: 0 2px;
}

.fold[open] > summary::before { transform: rotate(45deg); }

.panel.fold > summary h2 { margin: 0; }
.panel.fold[open] > summary { margin-bottom: 6px; }

/* 嵌套的折叠栏：一条细分隔线 + 小标题 */
.fold.nested,
.panel > .fold:not(.panel) {
    border-top: 1px solid var(--border);
    margin-top: 10px;
}

.fold.nested > summary,
.panel > .fold:not(.panel) > summary {
    padding: 9px 0 1px;
    font-size: 13px;
    color: var(--text-2);
}

.fold.nested .fold.nested { margin-left: 0; }

.fold-meta {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
}

.fold-body { padding-top: 2px; }

/* ---------- 勾选组（启用模块） ---------- */


.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0 6px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.check-item:hover { background: var(--hover); }
.check-item input { width: auto; margin: 0; accent-color: var(--accent); }

.check-item.locked { color: var(--muted); cursor: not-allowed; }

/* ---------- 人物档案 ---------- */

.search-row {
    display: flex;
    gap: 6px;
}

.search-row input { margin: 0; }
.search-row button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; }

.badge {
    min-width: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

.filter-box {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding: 10px;
    border-radius: 8px;
    background: var(--subtle);
}
.field-item .option-editor { margin-left: 32px; }

.filter-box input, .filter-box select, .filter-box button { margin: 0; }

.filter-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-row > input { flex: 1 1 0; min-width: 0; }
.filter-row > select { width: auto; flex: 0 0 auto; }
.filter-row > select:first-child:not(:only-child) { flex: 1 1 0; min-width: 0; }
.filter-row > button { flex: 0 0 auto; }
.filter-sep { color: var(--muted); }

.profile-list {
    margin-top: 8px;
    max-height: 330px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--field);
    scrollbar-width: thin;
}

.profile-row {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    outline: none;
}

.profile-row:last-child { border-bottom: 0; }
.profile-row:hover, .profile-row:focus-visible { background: var(--hover); }

.profile-row.active {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}

.profile-row-main {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-row-name {
    flex: 0 1 auto;
    min-width: 2em;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-row-birth {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.profile-row-main .chips { flex: 0 1 auto; flex-wrap: nowrap; overflow: hidden; }
.profile-empty { padding: 14px 10px; margin: 0; text-align: center; }

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.pager button { min-width: 32px; }
.pager-info { display: inline-flex; align-items: center; gap: 4px; }

.pager-info input {
    width: 52px;
    margin: 0;
    padding: 3px 6px;
    text-align: center;
    -moz-appearance: textfield;
}

.pager-info input::-webkit-outer-spin-button,
.pager-info input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chips:empty { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--field);
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.6;
}

button.chip:hover { background: var(--accent-soft); }
.chip.small { padding: 0 6px; font-size: 11px; background: var(--subtle); border-color: transparent; color: var(--muted); }
.chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.chip-x {
    margin: 0;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 14px;
    line-height: 1;
}

.chip-x:hover { background: transparent; color: var(--danger); }

#profileTagSuggest { margin-top: -2px; }

.field-row,
.field-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    margin: 6px 0;
}

.field-row input, .field-add-row input,
.field-row select, .field-add-row select { margin: 0; }
.field-row select, .field-add-row select { width: auto; padding: 6px; }
.field-add-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 9em) auto; }
.field-row button, .field-add-row button { padding: 6px 9px; font-size: 13px; }

/* ---------- 通用 ---------- */

.error-box {
    padding: 10px 14px;
    border: 1px solid var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
    border-radius: 8px;
    white-space: pre-wrap;
    font-size: 13px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 7px 9px;
    text-align: left;
    vertical-align: top;
}

thead th {
    background: var(--subtle);
    color: var(--text-2);
    font-weight: 600;
    white-space: nowrap;
}

tbody th { color: var(--text-2); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }

pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
}

/* ---------- 星盘 ---------- */

.chart-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.chart-head h2 { margin: 0; }

.chart-box {
    display: flex;
    justify-content: center;
    min-height: 120px;
}

.chart-empty {
    align-self: center;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.chart-box { flex-direction: column; align-items: center; }

/* ---------- 结果区标签页 ---------- */

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.tab-bar button {
    padding: 5px 11px;
    font-size: 13px;
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
    border-radius: 6px;
}

.tab-bar button:hover { background: var(--hover); color: var(--text); }

.tab-bar button.active {
    background: var(--accent-soft);
    color: var(--text);
    font-weight: 600;
}

.tab-panel h3 { font-size: 13px; margin: 16px 0 6px; color: var(--text-2); }
.tab-panel h3:first-child { margin-top: 0; }

/* ---------- 窄屏 ---------- */

@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; padding: 12px; }
    .topbar { position: static; height: auto; padding: 10px 16px; flex-wrap: wrap; }
}

@media (max-width: 520px) {
    .status-badge { display: none; }
    .ghost-btn { padding: 6px 8px; }
}

/* ---------- 本地日期时间：分段输入 ---------- */

.field-block { margin: 8px 0; }

.field-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.dt-input {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 4px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--field);
    font-variant-numeric: tabular-nums;
}

.dt-input:focus-within { outline: 2px solid var(--accent-soft); border-color: var(--border-strong); }

.dt-input input {
    width: 2.3em;
    margin: 0;
    padding: 5px 1px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    text-align: center;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.dt-input input.dt-year { width: 3.6em; }
.dt-input input:focus { outline: none; background: var(--accent-soft); }
.dt-input input::placeholder { color: var(--muted); opacity: 0.7; font-size: 12px; }
.dt-input input.invalid { color: var(--danger); background: var(--danger-soft); }
.dt-sep { color: var(--muted); padding: 0 1px; }
.dt-gap { width: 10px; }

.dt-hint { margin: 4px 2px 0; font-size: 12px; color: var(--danger); min-height: 0; }
.dt-hint:empty { display: none; }

/* ---------- 时间步进 ---------- */

.time-step {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 4px 0 6px;
}

.time-step select { width: auto; flex: 1 1 0; min-width: 0; margin: 0; padding: 6px; }

.step-btn {
    flex: 0 0 auto;
    width: 36px;
    padding: 5px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
}

.step-offset { flex: 1 0 100%; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.step-offset:empty { display: none; }
#stepResetBtn { padding: 3px 8px; font-size: 12px; }

/* ---------- 人物档案：侧栏卡片 ---------- */

.button-row.three { grid-template-columns: repeat(3, 1fr); }
.button-row button { padding: 7px 4px; font-size: 13px; }

.accent-btn { background: var(--accent-soft); border-color: var(--border-strong); font-weight: 600; }
.accent-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

.profile-card {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--field);
}

.profile-card-name {
    font-size: 16px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-meta { margin-top: 2px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.profile-card .chips { margin-top: 6px; }
.profile-card-empty { margin: 0; line-height: 1.6; }

/* ---------- 浮窗 ---------- */

dialog.modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}

dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgba(30, 26, 22, 0.42); }

.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head .icon-btn { margin-left: auto; }

.icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--text-2);
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 16px;
}

.modal-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}

.modal-foot .spacer { flex: 1 1 auto; }

/* 选择人物 */
.picker-modal { height: min(760px, calc(100vh - 48px)); }
.picker-modal .modal-body { display: flex; flex-direction: column; }

.picker-modal .profile-list {
    flex: 1 1 auto;
    min-height: 160px;
    max-height: none;
}

.filter-label { flex: 0 0 2.6em; font-size: 12px; color: var(--muted); }
.filter-row > #numFieldSelect { flex: 1 1 0; min-width: 0; width: auto; }

.profile-row { padding: 8px 12px; }
.profile-row-main { display: flex; align-items: center; gap: 8px; }
.profile-row .chips { flex: 0 1 auto; flex-wrap: nowrap; overflow: hidden; }

/* 全文检索命中摘要 */
.profile-row-match {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-field {
    margin-right: 6px;
    padding: 0 5px;
    border-radius: 3px;
    background: var(--subtle);
    color: var(--muted);
}

mark { background: var(--hl-self); color: var(--text); border-radius: 2px; padding: 0 1px; }

/* 编辑档案 */
.editor-modal { width: min(820px, calc(100vw - 32px)); }

.editor-birth {
    margin: 0 0 4px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--subtle);
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.5;
}

.custom-fields { margin-top: 6px; }

/* 自定义字段：下级字段缩进，左侧一条细线表示归属；分组只是一个标题 */
.custom-field { margin: 8px 0; }
.custom-field-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}
.custom-field.group > .custom-field-title { color: var(--text); font-weight: 600; }
.custom-field-input { margin: 4px 0 0; }
.custom-field-children {
    margin: 6px 0 0 4px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.char-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.custom-fields textarea {
    min-height: 3.2em;
    line-height: 1.6;
    resize: vertical;
}

/* ---------- 档案资料（结果区标签页） ---------- */

.profile-view-head h3 { margin: 0 0 4px; font-size: 16px; color: var(--text); }
.profile-view-head p { margin: 0 0 8px; }
.profile-view-head { padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

.profile-field-view { padding: 10px 0; border-bottom: 1px solid var(--border); }
.profile-field-view:last-child { border-bottom: 0; }
.profile-field-children { margin-top: 6px; padding-left: 14px; border-left: 1px solid var(--border); }
.profile-field-view.nested { padding: 6px 0; border-bottom: 0; }
.profile-field-view.nested h4 { background: transparent; padding: 0; color: var(--muted); }
/* 字段名做成小色块标签，和下面的正文一眼分开 */
.profile-field-view h4 {
    display: inline-block;
    margin: 0 0 8px;
    padding: 2px 9px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.6;
}
.profile-field-view .chips { margin-top: 0; }

.profile-field-text {
    max-width: 72em;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.75;
    font-size: 14px;
}



/* ---------- 浮窗内的提示 ---------- */

.dialog-msg {
    margin: 0 0 10px;
    padding: 8px 12px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    white-space: pre-wrap;
}

.dialog-msg.notice, .error-box.notice {
    border-color: var(--border-strong);
    background: var(--subtle);
    color: var(--text);
}

/* ---------- 档案检索：搜索范围、字段条件 ---------- */

.search-row select { width: auto; flex: 0 0 auto; margin: 0; padding: 6px; }

.field-filters { display: grid; gap: 6px; }
.field-filters:empty { display: none; }

.field-filter {
    display: grid;
    grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.field-filter select, .field-filter input { margin: 0; }

.field-filter-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.field-filter-body input { flex: 1 1 0; min-width: 0; }
.icon-btn.small { width: 24px; height: 24px; font-size: 16px; }

.file-btn {
    display: inline-block;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.file-btn:hover { background: var(--accent-soft); color: var(--text); }
.file-btn input[type="file"] { display: none; }
.modal-foot .ghost-btn { padding: 5px 10px; }

/* ---------- 编辑浮窗：多选、选项编辑、标签管理 ---------- */

.multi-input { margin-top: 4px; }
.multi-input .chip { cursor: pointer; }

.field-item { margin: 6px 0; border-radius: 6px; }
.field-item .field-row { margin: 0; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 9em) auto; }
.field-children { margin: 2px 0 6px 13px; padding-left: 10px; border-left: 1px solid var(--border); }
.field-parent { max-width: 9em; }
.field-item.dragging { background: var(--accent-soft); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); position: relative; z-index: 1; }

.field-row .drag-handle {
    width: 26px;
    padding: 6px 0;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.field-row .drag-handle:hover { color: var(--text); background: var(--hover); }
.field-item.dragging .drag-handle { cursor: grabbing; color: var(--text); }

.option-editor {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--subtle);
}

.option-item {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--field);
    padding: 0 4px 0 2px;
}

.option-item input {
    width: auto;
    margin: 0;
    padding: 1px 4px;
    border: 0;
    background: transparent;
    font-size: 12px;
}

.option-add { width: 150px; margin: 0; padding: 2px 8px; font-size: 12px; border-radius: 999px; }

.tag-manager { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }

.tag-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
}

.tag-row input { margin: 0; padding: 4px 8px; }
.tag-row button { padding: 4px 9px; font-size: 12px; }
.tag-count { min-width: 3.5em; text-align: right; }

/* ---------- 星盘视图切换 / 过境操作 ---------- */

#chartViews span { padding: 4px 12px; }

/* ---------- 人物档案 / 过境 两个面板：同样的结构、同样的尺寸 ---------- */

/* 卡片固定高度：有没有选人、有没有标签，面板都一样高，本命 / 过境切换时下面的面板不跳动。 */
#profilePanel .profile-card,
#transitPanel .profile-card {
    height: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.profile-card .chips { flex-wrap: nowrap; overflow: hidden; }
.profile-card-empty { text-align: center; }

#profilePanel .button-row button,
#transitPanel .button-row button { height: 36px; }

.panel-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

#profilePanel .profile-card-name { font-size: 17px; }
/* 过境卡片：日主星 / 时主星两行，标签小而淡，星名与档案卡片的人名同一字号 */
#transitCard { gap: 4px; }
.lord-row { display: flex; align-items: baseline; gap: 14px; }
.lord-label { flex: 0 0 auto; font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.lord-name { font-size: 16px; font-weight: 650; color: var(--text); letter-spacing: 0.04em; }

/* 过境工具栏：四个图标按钮 */
.icon-row button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-2);
}

.icon-row button:hover:not(:disabled) { color: var(--text); }
.icon-row button.accent-btn { color: var(--text); }

.icon-row svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-row svg .dot { fill: currentColor; stroke: none; }

/* 点「更新到现在」：箭头转一圈；定位中：准星呼吸 */
.icon-row button.spin svg { animation: qa-spin 0.6s ease-out; }
.icon-row button.busy svg { animation: qa-pulse 1s ease-in-out infinite; }

@keyframes qa-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes qa-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
    .icon-row button.spin svg, .icon-row button.busy svg { animation: none; }
}

/* ---------- 档案库切换（人物档案面板的标题） ---------- */

/* 两个面板的标题行固定同一高度：标题换成下拉框后，本命 / 过境切换仍然严丝合缝。 */
#profilePanel .panel-head,
#transitPanel .panel-head { height: 26px; align-items: center; }

/* 标题处的档案库按钮：看起来就是面板标题，悬停时才显出按钮的底 */
.lib-switch { position: relative; display: flex; flex: 0 1 auto; min-width: 0; max-width: 70%; }

.library-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-left: -8px;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
}
.library-btn:hover,
.library-btn[aria-expanded="true"] { background: var(--subtle); border-color: var(--border); }
#libraryName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-btn .chev {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
}
.library-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* 悬浮菜单 */
.library-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: -8px;
    z-index: 30;
    width: 272px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--pop-shadow);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
}
.library-menu.open { opacity: 1; transform: none; }

.lm-title {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px 6px;
    font-size: 11.5px;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.lm-list { max-height: 260px; overflow-y: auto; }

.lm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px 7px 6px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 13.5px;
    text-align: left;
}
.lm-item:hover, .lm-item:focus-visible { background: var(--hover); outline: none; }
.lm-item.current { background: var(--accent-soft); font-weight: 650; }
.lm-item.current:hover, .lm-item.current:focus-visible { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--border-strong); }

.lm-check { flex: 0 0 18px; display: inline-flex; justify-content: center; color: var(--accent); }
.lm-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lm-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-lock { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.lm-lock svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.lm-lock.locked { color: var(--accent); }
.unlock-switch { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.unlock-switch-row { display: flex; gap: 8px; }
.unlock-switch-row select { flex: 1; min-width: 0; }
.lm-count { flex: 0 0 auto; font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.lm-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.lm-action { color: var(--text-2); }
.lm-action .lm-check { color: var(--muted); }

.lm-form { display: flex; gap: 6px; padding: 2px 2px 2px; }
.lm-form input { margin: 0; flex: 1 1 auto; min-width: 0; }
.lm-form button { flex: 0 0 auto; padding: 6px 12px; font-size: 13px; }
.lm-error { margin: 6px 6px 2px; font-size: 12px; color: var(--danger); }

/* ---------- 下拉框的弹出列表（Chrome / Edge 135+ 可定制；更早的浏览器保持系统样式） ----------
   与档案库菜单同一套样式：圆角浮层、莫兰迪选中色，不再是系统的直角白底 + 蓝色高亮。 */
@supports (appearance: base-select) {
    select,
    select::picker(select) { appearance: base-select; }

    select {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 33px;
        cursor: pointer;
    }
    select:hover:not(:disabled) { border-color: var(--border-strong); }
    select::picker-icon {
        content: "";
        width: 10px;
        height: 10px;
        margin-left: auto;
        background: var(--muted);
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
        transition: rotate 0.18s ease;
    }
    select:open::picker-icon { rotate: 180deg; }
    select:open { border-color: var(--accent); }

    select::picker(select) {
        margin-top: 4px;
        padding: 4px;
        min-width: anchor-size(width);
        max-height: min(340px, 60vh);
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface);
        color: var(--text);
        box-shadow: var(--pop-shadow);
        opacity: 0;
        translate: 0 -4px;
        transition: opacity 0.14s ease, translate 0.14s ease, display 0.14s allow-discrete, overlay 0.14s allow-discrete;
    }
    select:open::picker(select) { opacity: 1; translate: 0 0; }
    @starting-style {
        select:open::picker(select) { opacity: 0; translate: 0 -4px; }
    }

    select option {
        gap: 8px;
        padding: 6px 10px 6px 8px;
        border-radius: 6px;
        background: transparent;
        color: var(--text);
        font-size: 13px;
        white-space: nowrap;
    }
    select option:hover,
    select option:focus-visible { background: var(--hover); outline: none; }
    select option:checked { background: var(--accent-soft); font-weight: 600; }
    select option::checkmark { color: var(--accent); }
    select option:disabled { color: var(--muted); background: transparent; }
}

/* ---------- 经纬度：十进制 / 度分秒 ---------- */

.coord-block { margin-top: 2px; }

.coord-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 2px;
}

/* 小号分段开关：比星盘样式那组再小一号，只占标题行的高度 */
.segmented.mini { display: inline-flex; padding: 2px; border-radius: 7px; }
.segmented.mini span { padding: 2px 10px; font-size: 12px; border-radius: 5px; }

.coord-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
}
.coord-field { margin: 4px 0 6px; min-width: 0; }
.coord-field .coord-dec { margin-top: 4px; }

/* 度分秒：每个坐标占一整行，放得下「北纬 31° 13′ 48.36″」 */
.coord-block[data-format="dms"] .coord-fields { grid-template-columns: 1fr; }
.coord-block[data-format="dms"] .coord-dec,
.coord-block[data-format="dms"] .coord-field > .field-label { display: none; }   /* 北纬 / 东经标签已经说明是哪一个 */
.coord-block[data-format="dms"] .coord-field { margin: 6px 0; }
.coord-block[data-format="decimal"] .dms-input { display: none; }

.dms-input { gap: 0; }
/* 数字靠右贴住后面的 ° ′ ″，读起来是一串「33°52′04.2″」 */
.dms-input input { width: 2em; padding-right: 2px; text-align: right; }
.dms-input input[data-dms="d"] { width: 2.7em; }
.dms-input input.dms-sec { width: 3.6em; }
.dms-input .dt-sep { padding: 0 10px 0 1px; font-size: 14px; color: var(--text-2); }
/* 支持按内容定宽的浏览器：每一格刚好包住数字，间距均匀 */
@supports (field-sizing: content) {
    .dms-input input,
    .dms-input input[data-dms="d"],
    .dms-input input.dms-sec { field-sizing: content; width: auto; min-width: 1.6em; padding: 5px 3px; text-align: center; }
}
.dms-input .dt-sep:last-child { padding-right: 0; }

/* 南北纬 / 东西经：点一下切换，像一枚小标签 */
.dms-input .hemi {
    flex: 0 0 auto;
    margin: 3px 8px 3px 0;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--subtle);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.5;
}
.dms-input .hemi:hover { background: var(--accent-soft); color: var(--text); border-color: var(--border-strong); }
.dms-input .hemi[data-neg="1"] { background: var(--accent-soft); color: var(--accent); }

.chart-box { position: relative; }

/* ---------- 顶栏：占星体系切换 ---------- */

.topbar-title { display: flex; align-items: center; gap: 16px; min-width: 0; }
.system-switch { display: inline-flex; }
.system-switch a {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    color: var(--text-2);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}
.system-switch a:hover { background: var(--hover); color: var(--text); }
.system-switch a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---------- 数据库加密 ---------- */

.security-modal { width: min(520px, calc(100vw - 32px)); }
.unlock-modal { width: min(380px, calc(100vw - 32px)); }
.unlock-modal .modal-body input { width: 100%; }
#securityBody p { margin: 0 0 10px; line-height: 1.7; font-size: 13px; }
#securityBody code { background: var(--subtle); padding: 0 4px; border-radius: 3px; font-size: 12px; }
#securityBody details { margin-top: 10px; }
.security-state { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.security-state.off { background: var(--subtle); color: var(--text-2); }
.security-state.on { background: var(--accent-soft); color: var(--text); }
.security-warn { padding: 8px 10px; border-left: 3px solid var(--danger); background: var(--danger-soft); border-radius: 4px; }

/* ---------- 计算设置里的入口行（点开浮窗）：西占的星体配置 / 相位，以及两个体系共用的工具 ---------- */

.point-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }

.point-entries {
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--field);
}

.point-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    font-size: 13px;
    text-align: left;
}
.point-entry:last-child { border-bottom: 0; }
.point-entry:hover { background: var(--hover); }
.point-entry-name { flex: 1 1 auto; color: var(--text); }
.point-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.point-entry .chev {
    width: 12px; height: 12px; fill: none; stroke: var(--muted);
    stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

.point-hint { margin: 0 0 10px; line-height: 1.6; }

/* ---------- 结果标签页顺序 ---------- */

dialog.modal.order-modal { width: min(440px, calc(100vw - 32px)); }
.order-list { display: grid; gap: 4px; }
.order-row {
    display: grid;
    grid-template-columns: auto 1.8em minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--field);
    font-size: 13px;
}
.order-row.dragging { background: var(--accent-soft); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); position: relative; z-index: 1; }
.order-row .drag-handle {
    width: 26px; padding: 4px 0; border-color: transparent; background: transparent;
    color: var(--muted); font-size: 15px; line-height: 1; cursor: grab; touch-action: none; user-select: none;
}
.order-row .drag-handle:hover { color: var(--text); background: var(--hover); }
.order-row.dragging .drag-handle { cursor: grabbing; color: var(--text); }
.order-index { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.order-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row .icon-btn:disabled { opacity: 0.25; }

/* ---------- 原始参数 ---------- */

dialog.modal.raw-modal { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100vh - 48px)); }
.raw-tabs { flex-wrap: wrap; margin-bottom: 12px; }
.raw-tabs label { flex: 0 1 auto; }
.raw-tabs span { padding: 5px 12px; }
.raw-title { margin: 16px 0 6px; font-size: 13px; color: var(--text-2); }
.raw-title:first-child { margin-top: 0; }
.raw-body table { font-family: ui-monospace, "Cascadia Mono", Consolas, "Microsoft YaHei", monospace; font-size: 12.5px; }
.raw-body th { white-space: nowrap; }

/* ---------- 结果表（行星、宫位、值日星） ---------- */

.info-table td, .info-table th { white-space: nowrap; }
.info-table td.muted-cell { color: var(--muted); white-space: normal; }
.info-table td.dim { color: var(--muted); }
.info-table td.good { color: var(--asp-applying, #8cc3ae); font-weight: 600; }
.info-table td.bad { color: var(--asp-separating, #e0a37f); font-weight: 600; }
.info-table td.score-pos { color: #8cc3ae; font-weight: 700; }
.info-table td.score-neg { color: #e0a37f; font-weight: 700; }
.info-table .glyph { font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "Apple Symbols", "DejaVu Sans", sans-serif; font-size: 15px; }
.info-table .glyph.active { color: var(--text); font-weight: 700; border-bottom: 2px solid var(--accent); }
.info-table .glyph.inactive { color: var(--muted); }

/* 导入 / 导出设置 */
dialog.modal.transfer-modal { width: min(460px, calc(100vw - 32px)); }
.transfer-choices { display: flex; flex-direction: column; gap: 10px; }
.transfer-choice {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    width: 100%; padding: 12px 14px; text-align: left;
    border: 1px solid var(--border); border-radius: 8px; background: transparent;
}
.transfer-choice:hover { background: var(--hover); border-color: var(--border-strong); }
.transfer-name { font-size: 14px; font-weight: 600; color: var(--text); }
.transfer-desc { font-size: 12px; color: var(--muted); line-height: 1.5; white-space: normal; }
