/* story-summary.css */

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

/* ═══════════════════════════════════════════════════════════════════════════
   Facts (替换 World State)
   ═══════════════════════════════════════════════════════════════════════════ */

.facts {
    flex: 0 0 auto;
}

.facts-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.fact-group {
    margin-bottom: 12px;
}

.fact-group:last-child {
    margin-bottom: 0;
}

.fact-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--hl);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--bdr2);
}

.fact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: var(--bg3);
    border: 1px solid var(--bdr2);
    border-radius: 4px;
    font-size: 0.8125rem;
}

.fact-predicate {
    color: var(--txt2);
    min-width: 60px;
}

.fact-predicate::after {
    content: '：';
}

.fact-object {
    color: var(--txt);
    flex: 1;
}

.fact-since {
    font-size: 0.625rem;
    color: var(--txt3);
}

@media (max-width: 768px) {
    .facts-list {
        max-height: 180px;
    }

    .fact-item {
        padding: 6px 8px;
        font-size: 0.75rem;
    }
}

:root {
    --bg: #fafafa;
    --bg2: #fff;
    --bg3: #f5f5f5;
    --txt: #1a1a1a;
    --txt2: #444;
    --txt3: #666;
    --bdr: #dcdcdc;
    --bdr2: #e8e8e8;
    --acc: #1a1a1a;
    --hl: #d87a7a;
    --hl-soft: rgba(184, 90, 90, .1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--txt);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════════════════════════ */

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 24px 40px;
    max-width: 1800px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--bdr);
    margin-bottom: 24px;
}

main {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

.left,
.right {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
}

/* 关键词卡片：固定高度 */
.left>.card:first-child {
    flex: 0 0 auto;
    /* 关键词：不伸缩 */
}

/* ═══════════════════════════════════════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════════════════════════════════════ */

h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: -.02em;
    margin-bottom: 4px;
}

h1 span {
    font-weight: 600;
}

.subtitle {
    font-size: .875rem;
    color: var(--txt3);
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Stats
   ═══════════════════════════════════════════════════════════════════════════ */

.stats {
    display: flex;
    gap: 48px;
    text-align: right;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-val {
    font-size: 2.5rem;
    font-weight: 200;
    line-height: 1;
    letter-spacing: -.03em;
}

.stat-val .hl {
    color: var(--hl);
}

.stat-lbl {
    font-size: .75rem;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-top: 4px;
}

.stat-warning {
    font-size: .625rem;
    color: #ff9800;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Controls
   ═══════════════════════════════════════════════════════════════════════════ */

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

.chk-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    background: transparent;
    border: none;
    font-size: .8125rem;
    color: var(--txt2);
    cursor: pointer;
    transition: all .2s;
}

.chk-label:hover {
    color: var(--txt);
}

.chk-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--hl);
    cursor: pointer;
}

.chk-label strong {
    color: var(--hl);
}

#keep-visible-count {
    width: 3.5em;
    min-width: 3em;
    max-width: 4em;
    padding: 4px 6px;
    margin: 0 4px;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    font-size: inherit;
    font-weight: bold;
    color: var(--hl);
    text-align: center;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;

    /* 禁用 number input 的 spinner（PC 上会挤掉数字） */
    -moz-appearance: textfield;
    appearance: textfield;
}

#keep-visible-count::-webkit-outer-spin-button,
#keep-visible-count::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#keep-visible-count:focus {
    border-color: var(--acc);
    outline: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    padding: 12px 28px;
    background: var(--bg2);
    color: var(--txt);
    border: 1px solid var(--bdr);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.btn:hover {
    border-color: var(--acc);
    background: var(--bg3);
}

.btn-p {
    background: var(--acc);
    color: #fff;
    border-color: var(--acc);
}

.btn-p:hover {
    background: #555;
}

.btn-p:disabled {
    background: #999;
    border-color: #999;
    cursor: not-allowed;
    opacity: .7;
}

.btn-icon {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: .8125rem;
}

.btn-del {
    background: transparent;
    color: var(--hl);
    border-color: var(--hl);
}

.btn-del:hover {
    background: var(--hl-soft);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.btn-group .btn {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    text-align: center;
    white-space: nowrap;
}

.btn-group .btn-icon {
    padding: 10px 14px;
}

.btn-debug {
    background: var(--bg2);
    color: var(--txt2);
    border: 1px solid var(--bdr);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.btn-debug svg {
    width: 14px;
    height: 14px;
}

.btn-debug:hover {
    background: var(--bg3);
    border-color: var(--acc);
    color: var(--txt);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cards & Sections
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--bg2);
    border: 1px solid var(--bdr);
    padding: 24px;
}

.sec-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sec-title {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--txt2);
}

.sec-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--bdr);
    font-size: .6875rem;
    color: var(--txt3);
    cursor: pointer;
    transition: all .2s;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.sec-btn:hover {
    border-color: var(--acc);
    color: var(--txt);
    background: var(--bg3);
}

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

.sec-icon {
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Keywords
   ═══════════════════════════════════════════════════════════════════════════ */

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.tag {
    padding: 8px 20px;
    background: var(--bg3);
    border: 1px solid var(--bdr2);
    font-size: .875rem;
    color: var(--txt2);
    transition: all .2s;
    cursor: default;
}

.tag.p {
    background: var(--acc);
    color: #fff;
    border-color: var(--acc);
    font-weight: 500;
}

.tag.s {
    background: var(--hl-soft);
    border-color: rgba(255, 68, 68, .2);
    color: var(--hl);
}

.tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Timeline
   ═══════════════════════════════════════════════════════════════════════════ */

.timeline {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 1140px;
}

.tl-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    min-height: 0;
}

.tl-list::-webkit-scrollbar,
.scroll::-webkit-scrollbar {
    width: 4px;
}

.tl-list::-webkit-scrollbar-thumb,
.scroll::-webkit-scrollbar-thumb {
    background: var(--bdr);
}

.tl-item {
    position: relative;
    padding-left: 32px;
    padding-bottom: 32px;
    border-left: 1px solid var(--bdr);
    margin-left: 8px;
}

.tl-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.tl-dot {
    position: absolute;
    left: -5px;
    top: 0;
    width: 9px;
    height: 9px;
    background: var(--bg2);
    border: 2px solid var(--txt3);
    border-radius: 50%;
    transition: all .2s;
}

.tl-item:hover .tl-dot {
    border-color: var(--hl);
    background: var(--hl);
    transform: scale(1.3);
}

.tl-item.crit .tl-dot {
    border-color: var(--hl);
    background: var(--hl);
}

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

.tl-title {
    font-size: 1rem;
    font-weight: 500;
}

.tl-time {
    font-size: .75rem;
    color: var(--txt3);
    font-variant-numeric: tabular-nums;
}

.tl-brief {
    font-size: .875rem;
    color: var(--txt2);
    line-height: 1.7;
    margin-bottom: 12px;
}

.tl-meta {
    display: flex;
    gap: 16px;
    font-size: .75rem;
    color: var(--txt3);
}

.tl-meta .imp {
    color: var(--hl);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Relations Chart
   ═══════════════════════════════════════════════════════════════════════════ */

.relations {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 480px;
}

#relation-chart,
#relation-chart-fullscreen {
    width: 100%;
    flex: 1;
    min-height: 0;
    touch-action: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Profile
   ═══════════════════════════════════════════════════════════════════════════ */

.profile {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 480px;
}

.profile-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    min-height: 0;
}

.prof-arc {
    padding: 16px;
    margin-bottom: 24px;
}

.prof-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.prof-traj {
    font-size: .8125rem;
    color: var(--txt3);
    line-height: 1.5;
}

.prof-prog-wrap {
    margin-bottom: 16px;
}

.prof-prog-lbl {
    display: flex;
    justify-content: space-between;
    font-size: .75rem;
    color: var(--txt3);
    margin-bottom: 6px;
}

.prof-prog {
    height: 4px;
    background: var(--bdr);
    border-radius: 2px;
    overflow: hidden;
}

.prof-prog-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--hl), #d85858);
    border-radius: 2px;
    transition: width .6s;
}

.prof-moments {
    background: var(--bg2);
    border-left: 3px solid var(--hl);
    padding: 12px 16px;
}

.prof-moments-title {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--txt3);
    margin-bottom: 8px;
}

.prof-moment {
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
    font-size: .8125rem;
    color: var(--txt2);
    line-height: 1.5;
}

.prof-moment::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    background: var(--hl);
    border-radius: 50%;
}

.prof-moment:last-child {
    margin-bottom: 0;
}

.prof-rels {
    display: flex;
    flex-direction: column;
}

.rels-group {
    border-bottom: 1px solid var(--bdr2);
    padding: 16px 0;
}

.rels-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rels-group:first-child {
    padding-top: 0;
}

.rels-group-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--txt3);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rel-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
}

.rel-item:hover {
    background: var(--bg3);
}

.rel-target {
    font-size: .9rem;
    color: var(--txt2);
    white-space: nowrap;
    min-width: 60px;
}

.rel-label {
    font-size: .7rem;
    line-height: 1.5;
    flex: 1;
}

.rel-trend {
    font-size: .6875rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.trend-broken {
    background: rgba(68, 68, 68, .15);
    color: #444;
}

.trend-hate {
    background: rgba(139, 0, 0, .15);
    color: #8b0000;
}

.trend-dislike {
    background: rgba(205, 92, 92, .15);
    color: #cd5c5c;
}

.trend-stranger {
    background: rgba(136, 136, 136, .15);
    color: #888;
}

.trend-click {
    background: rgba(102, 205, 170, .15);
    color: #4a9a7e;
}

.trend-close {
    background: rgba(235, 106, 106, .15);
    color: var(--hl);
}

.trend-merge {
    background: rgba(199, 21, 133, .2);
    color: #c71585;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Custom Select
   ═══════════════════════════════════════════════════════════════════════════ */

.custom-select {
    position: relative;
    min-width: 140px;
    font-size: .8125rem;
}

.sel-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
}

.sel-trigger:hover {
    border-color: var(--acc);
    background: var(--bg2);
}

.sel-trigger::after {
    content: '';
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d8d8d' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e") center/16px no-repeat;
    transition: transform .2s;
}

.custom-select.open .sel-trigger::after {
    transform: rotate(180deg);
}

.sel-opts {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
    z-index: 100;
    display: none;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
}

.custom-select.open .sel-opts {
    display: block;
    animation: fadeIn .2s;
}

.sel-opt {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background .1s;
}

.sel-opt:hover {
    background: var(--bg3);
}

.sel-opt.sel {
    background: var(--hl-soft);
    color: var(--hl);
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════════════════════════════════════ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
}

.modal-box {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--bdr);
}

.modal-head h2 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--bdr);
    cursor: pointer;
    transition: all .2s;
}

.modal-close:hover {
    background: var(--bg3);
    border-color: var(--acc);
}

.modal-close svg {
    width: 14px;
    height: 14px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--bdr);
}

.fullscreen .modal-box {
    width: 95vw;
    height: 90vh;
    max-width: none;
    max-height: none;
}

.fullscreen .modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
}

#relation-chart-fullscreen {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Editor
   ═══════════════════════════════════════════════════════════════════════════ */

.editor-ta {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: .8125rem;
    line-height: 1.6;
    color: var(--txt);
    resize: vertical;
    outline: none;
}

.editor-ta:focus {
    border-color: var(--acc);
}

.editor-hint {
    font-size: .75rem;
    color: var(--txt3);
    margin-bottom: 12px;
    line-height: 1.5;
}

.editor-err {
    padding: 12px;
    background: var(--hl-soft);
    border: 1px solid rgba(255, 68, 68, .3);
    color: var(--hl);
    font-size: .8125rem;
    margin-top: 12px;
    display: none;
}

.editor-err.visible {
    display: block;
}

.struct-item {
    border: 1px solid var(--bdr);
    background: var(--bg3);
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.struct-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.struct-row input,
.struct-row select,
.struct-row textarea {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    font-size: .8125rem;
    color: var(--txt);
    outline: none;
    transition: border-color .2s;
}

.struct-row input:focus,
.struct-row select:focus,
.struct-row textarea:focus {
    border-color: var(--acc);
}

.struct-row textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 60px;
}

.struct-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.struct-actions span {
    font-size: .75rem;
    color: var(--txt3);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Settings
   ═══════════════════════════════════════════════════════════════════════════ */

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--txt3);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bdr2);
}

.settings-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.settings-field.full {
    flex: 100%;
}

.settings-field label {
    font-size: .75rem;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.settings-field input:not([type="checkbox"]):not([type="radio"]),
.settings-field select {
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
    font-size: .875rem;
    color: var(--txt);
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
}

.settings-field input[type="checkbox"],
.settings-field input[type="radio"] {
    width: auto;
    height: auto;
}

.settings-field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 4.5 6 7.5 9 4.5'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.settings-field input:focus,
.settings-field select:focus {
    border-color: var(--acc);
}

.settings-field input[type="password"] {
    letter-spacing: .15em;
}

.settings-field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-field-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--acc);
}

.settings-field-inline label {
    font-size: .8125rem;
    color: var(--txt2);
    text-transform: none;
    letter-spacing: 0;
}

.settings-hint {
    font-size: .75rem;
    color: var(--txt3);
    margin-top: 4px;
}

.settings-btn-row {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Vector Settings
   ═══════════════════════════════════════════════════════════════════════════ */

.engine-selector {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.engine-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: .875rem;
    color: var(--txt2);
}

.engine-option input {
    accent-color: var(--hl);
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.engine-area {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
}

.engine-card {
    text-align: center;
}

.engine-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.engine-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.engine-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8125rem;
    color: var(--txt3);
    flex: 1;
    /* 占 1/3 */
}

.engine-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex: 2;
    /* 占 2/3 */
}

/* 针对在线测试连接按钮的特殊处理 */
#btn-test-vector-api {
    flex: 2;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--txt3);
}

.status-dot.ready {
    background: #22c55e;
}

.status-dot.cached {
    background: #3b82f6;
}

.status-dot.downloading {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot.success {
    background: #22c55e;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.engine-progress {
    margin: 12px 0;
}

.progress-bar {
    height: 6px;
    background: var(--bdr);
    border-radius: 3px;
    overflow: hidden;
}

.progress-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--hl), #d85858);
    border-radius: 3px;
    width: 0%;
    transition: width .3s;
}

.progress-text {
    font-size: .75rem;
    color: var(--txt3);
    display: block;
    text-align: center;
    margin-top: 4px;
}

.engine-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex: 2;
}

.model-select-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.model-select-row select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    font-size: .875rem;
    color: var(--txt);
}

.model-desc {
    font-size: .75rem;
    color: var(--txt3);
    text-align: left;
    margin-bottom: 4px;
}

.vector-stats {
    display: flex;
    gap: 8px;
    font-size: .875rem;
    color: var(--txt2);
    margin-top: 8px;
}

.vector-stats strong {
    color: var(--hl);
}

.vector-mismatch-warning {
    font-size: .75rem;
    color: #f59e0b;
    margin-top: 6px;
}

.vector-chat-section {
    border-top: 1px solid var(--bdr);
    padding-top: 16px;
    margin-top: 16px;
}

#vector-action-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
}

#vector-action-row .btn {
    flex: 1;
    min-width: 0;
}

.provider-hint {
    font-size: .75rem;
    color: var(--txt3);
    margin-top: 4px;
}

.provider-hint a {
    color: var(--hl);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Recall Log
   ═══════════════════════════════════════════════════════════════════════════ */

#recall-log-modal .modal-box {
    max-width: 900px;
    display: flex;
    flex-direction: column;
}

#recall-log-modal .modal-body {
    flex: 1;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

#recall-log-content {
    font-family: 'Consolas', 'Monaco', 'SF Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #e8e8e8;
    white-space: pre-wrap !important;
    overflow-x: hidden !important;
    word-break: break-word;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.recall-empty {
    color: #999;
    text-align: center;
    padding: 40px;
    font-style: italic;
    font-size: .8125rem;
    line-height: 1.8;
}

/* 移动端适配 */
@media (max-width: 768px) {
    #recall-log-modal .modal-box {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .debug-log-viewer,
    #recall-log-content {
        font-size: 11px;
        padding: 12px;
        line-height: 1.5;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HF Guide
   ═══════════════════════════════════════════════════════════════════════════ */

.hf-guide {
    font-size: .875rem;
    line-height: 1.7;
}

.hf-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--bdr2);
}

.hf-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.hf-intro {
    background: linear-gradient(135deg, rgba(102, 126, 234, .08), rgba(118, 75, 162, .08));
    border: 1px solid rgba(102, 126, 234, .2);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    border-bottom: none;
}

.hf-intro-text {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.hf-intro-badges {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.hf-badge {
    padding: 4px 12px;
    background: var(--bg2);
    border: 1px solid var(--bdr);
    border-radius: 20px;
    font-size: .75rem;
    color: var(--txt2);
}

.hf-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.hf-step-num {
    width: 28px;
    height: 28px;
    background: var(--acc);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .875rem;
    flex-shrink: 0;
}

.hf-step-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--txt);
}

.hf-step-content {
    padding-left: 40px;
}

.hf-step-content p {
    margin: 0 0 12px;
}

.hf-step-content a {
    color: var(--hl);
    text-decoration: none;
}

.hf-step-content a:hover {
    text-decoration: underline;
}

.hf-checklist {
    margin: 12px 0;
    padding-left: 20px;
}

.hf-checklist li {
    margin-bottom: 6px;
}

.hf-checklist li::marker {
    color: var(--hl);
}

.hf-checklist code,
.hf-faq code {
    background: var(--bg3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: .8125rem;
}

.hf-file {
    margin-bottom: 16px;
    border: 1px solid var(--bdr);
    border-radius: 6px;
    overflow: hidden;
}

.hf-file:last-child {
    margin-bottom: 0;
}

.hf-file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg3);
    border-bottom: 1px solid var(--bdr);
    font-size: .8125rem;
}

.hf-file-icon {
    font-size: 1rem;
}

.hf-file-name {
    font-weight: 600;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.hf-file-note {
    color: var(--txt3);
    font-size: .75rem;
    margin-left: auto;
}

.hf-code {
    margin: 0;
    padding: 14px;
    background: #1e1e1e;
    overflow-x: auto;
    position: relative;
}

.hf-code code {
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-size: .75rem;
    line-height: 1.5;
    color: #d4d4d4;
    display: block;
    white-space: pre;
}

.hf-code .copy-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #999;
    font-size: .6875rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all .2s;
}

.hf-code .copy-btn:hover {
    background: rgba(255, 255, 255, .2);
    color: #fff;
}

.hf-status-badge {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(34, 197, 94, .15);
    color: #22c55e;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 500;
}

.hf-config-table {
    background: var(--bg3);
    border: 1px solid var(--bdr);
    border-radius: 6px;
    overflow: hidden;
}

.hf-config-row {
    display: flex;
    padding: 12px 16px;
    border-bottom: 1px solid var(--bdr);
}

.hf-config-row:last-child {
    border-bottom: none;
}

.hf-config-label {
    width: 100px;
    flex-shrink: 0;
    font-weight: 500;
    color: var(--txt2);
}

.hf-config-value {
    flex: 1;
    color: var(--txt);
}

.hf-config-value code {
    background: var(--bg2);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: .8125rem;
    word-break: break-all;
}

.hf-faq {
    background: var(--bg3);
    border: 1px solid var(--bdr);
    border-radius: 6px;
    padding: 16px 20px;
    border-bottom: none;
}

.hf-faq-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--txt);
}

.hf-faq ul {
    margin: 0;
    padding-left: 20px;
}

.hf-faq li {
    margin-bottom: 8px;
    color: var(--txt2);
}

.hf-faq li:last-child {
    margin-bottom: 0;
}

.hf-faq a {
    color: var(--hl);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════════════════════════ */

.hidden {
    display: none !important;
}

.empty {
    text-align: center;
    padding: 40px;
    color: var(--txt3);
    font-size: .875rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive - Tablet
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
    .container {
        padding: 16px 24px;
    }

    main {
        grid-template-columns: 1fr;
    }

    .right {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .relations,
    .world-state,
    .profile {
        min-height: 280px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive - Mobile
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .container {
        height: auto;
        min-height: 100vh;
        padding: 16px;
    }

    header {
        flex-direction: column;
        gap: 16px;
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .stats {
        width: 100%;
        justify-content: space-between;
        gap: 16px;
        text-align: center;
    }

    .stat-val {
        font-size: 1.75rem;
    }

    .stat-lbl {
        font-size: .625rem;
    }

    .controls {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 0;
        margin-bottom: 16px;
    }

    .spacer {
        display: none;
    }

    .chk-label {
        width: 100%;
        justify-content: center;
    }

    .btn-group {
        width: 100%;
        display: flex;
        gap: 6px;
    }

    .btn-group .btn {
        padding: 10px 8px;
        font-size: .75rem;
    }

    .btn-group .btn-icon {
        padding: 10px 8px;
        justify-content: center;
    }

    .btn-group .btn-icon svg {
        width: 14px;
        height: 14px;
    }

    .btn-group .btn-icon span {
        display: none;
    }

    main {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .left,
    .right {
        gap: 16px;
    }

    .right {
        display: flex;
        flex-direction: column;
    }

    .timeline {
        max-height: 400px;
    }

    /* 关键：relations 和 profile 完全一致的高度 */
    .relations,
    .profile {
        min-height: 350px;
        max-height: 350px;
        height: 350px;
    }

    #relation-chart {
        height: 100%;
        min-height: 300px;
    }

    .world-state {
        min-height: 180px;
        max-height: 180px;
    }

    .card {
        padding: 16px;
    }

    .keywords {
        gap: 8px;
        margin-top: 12px;
    }

    .tag {
        padding: 6px 14px;
        font-size: .8125rem;
    }

    .tl-item {
        padding-left: 24px;
        padding-bottom: 24px;
    }

    .tl-title {
        font-size: .9375rem;
    }

    .tl-brief {
        font-size: .8125rem;
        line-height: 1.6;
    }

    .modal-box {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border: none;
    }

    .modal-head,
    .modal-body,
    .modal-foot {
        padding: 16px;
    }

    .settings-row {
        flex-direction: column;
        gap: 12px;
    }

    .settings-field {
        min-width: 100%;
    }

    .settings-field input,
    .settings-field select {
        padding: 12px 14px;
        font-size: 1rem;
    }

    .fullscreen .modal-box {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .hf-step-content {
        padding-left: 0;
        margin-top: 12px;
    }

    .hf-config-row {
        flex-direction: column;
        gap: 4px;
    }

    .hf-config-label {
        width: auto;
        font-size: .75rem;
        color: var(--txt3);
    }

    .hf-intro-badges {
        gap: 8px;
    }

    .hf-badge {
        font-size: .6875rem;
        padding: 3px 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive - Small Mobile
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: .6875rem;
    }

    .stats {
        gap: 8px;
    }

    .stat {
        flex: 1;
    }

    .stat-val {
        font-size: 1.5rem;
    }

    .controls {
        gap: 6px;
        padding: 8px 0;
        margin-bottom: 12px;
    }

    .btn-group {
        gap: 4px;
    }

    .btn-group .btn {
        padding: 10px 6px;
        font-size: .6875rem;
    }

    main,
    .left,
    .right {
        gap: 12px;
    }

    .card {
        padding: 12px;
    }

    .sec-title {
        font-size: .6875rem;
    }

    .sec-btn {
        font-size: .625rem;
        padding: 3px 8px;
    }

    /* 小屏也保持一致 */
    .relations,
    .profile {
        min-height: 300px;
        max-height: 300px;
        height: 300px;
    }

    #relation-chart {
        height: 100%;
        min-height: 250px;
    }

    .world-state {
        min-height: 150px;
        max-height: 150px;
    }

    .keywords {
        gap: 6px;
        margin-top: 10px;
    }

    .tag {
        padding: 5px 10px;
        font-size: .75rem;
    }

    .tl-item {
        padding-left: 20px;
        padding-bottom: 20px;
        margin-left: 6px;
    }

    .tl-dot {
        width: 7px;
        height: 7px;
        left: -4px;
    }

    .tl-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .tl-title {
        font-size: .875rem;
    }

    .tl-time {
        font-size: .6875rem;
    }

    .tl-brief {
        font-size: .8rem;
        margin-bottom: 8px;
    }

    .tl-meta {
        flex-direction: column;
        gap: 4px;
        font-size: .6875rem;
    }

    .modal-head h2 {
        font-size: .875rem;
    }

    .settings-section-title {
        font-size: .625rem;
    }

    .settings-field label {
        font-size: .6875rem;
    }

    .settings-field-inline label {
        font-size: .75rem;
    }

    .settings-hint {
        font-size: .6875rem;
    }

    .btn-sm {
        padding: 10px 14px;
        font-size: .75rem;
        width: 100%;
    }

    .editor-ta {
        min-height: 200px;
        font-size: .75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Touch Devices
   ═══════════════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .tag {
        min-height: 36px;
        display: flex;
        align-items: center;
    }

    .tag:hover {
        transform: none;
    }

    .tl-item:hover .tl-dot {
        transform: none;
    }

    .modal-close {
        width: 44px;
        height: 44px;
    }

    .settings-field input,
    .settings-field select {
        min-height: 44px;
    }

    .settings-field-inline input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .sec-btn {
        min-height: 32px;
        padding: 6px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   World State (L3)
   ═══════════════════════════════════════════════════════════════════════════ */

.world-state {
    flex: 0 0 auto;
}

.world-state-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

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

.world-group:last-child {
    margin-bottom: 0;
}

.world-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--txt3);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--bdr2);
}

.world-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--bg3);
    border: 1px solid var(--bdr2);
    border-radius: 6px;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
}

.world-item:hover {
    border-color: var(--bdr);
    background: var(--bg2);
}

.world-item:last-child {
    margin-bottom: 0;
}

.world-topic {
    font-weight: 600;
    color: var(--txt);
    white-space: nowrap;
    flex-shrink: 0;
}

.world-topic::after {
    content: '';
}

.world-content {
    color: var(--txt2);
    flex: 1;
    line-height: 1.5;
}

/* 分类图标颜色 */
.world-group[data-category="status"] .world-group-title {
    color: #e57373;
}

.world-group[data-category="inventory"] .world-group-title {
    color: #64b5f6;
}

.world-group[data-category="relation"] .world-group-title {
    color: #ba68c8;
}

.world-group[data-category="knowledge"] .world-group-title {
    color: #4db6ac;
}

.world-group[data-category="rule"] .world-group-title {
    color: #ffd54f;
}

/* 空状态 */
.world-state-list .empty {
    padding: 24px;
    font-size: 0.8125rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .world-state {
        max-height: none;
    }

    .world-state-list {
        max-height: 180px;
    }

    .world-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
    }

    .world-topic::after {
        content: '';
    }
}

@media (max-width: 480px) {
    .world-state-list {
        max-height: 150px;
    }

    .world-group-title {
        font-size: 0.625rem;
    }

    .world-item {
        font-size: 0.75rem;
        padding: 6px 8px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   New Settings Styles
   ═══════════════════════════════════════════════════════════════════════════ */

.settings-modal-box {
    max-width: 680px;
}

/* Collapsible Section */
.settings-collapse {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
}

.settings-collapse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--txt2);
    transition: all .2s;
}

.settings-collapse-header:hover {
    background: var(--bdr);
}

.collapse-icon {
    width: 16px;
    height: 16px;
    transition: transform .2s;
}

.settings-collapse.open .collapse-icon {
    transform: rotate(180deg);
}

.settings-collapse-content {
    padding: 16px;
    border-top: 1px solid var(--bdr);
}

/* Checkbox Group */
.settings-checkbox-group {
    margin-bottom: 20px;
    padding: 0;
    background: transparent;
    border: none;
}

.settings-checkbox-group:last-child {
    margin-bottom: 0;
}

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.settings-checkbox input[type="checkbox"] {
    display: none;
}

.checkbox-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bdr);
    border-radius: 4px;
    background: var(--bg2);
    position: relative;
    transition: all .2s;
    flex-shrink: 0;
}

.settings-checkbox input:checked+.checkbox-mark {
    background: var(--acc);
    border-color: var(--acc);
}

.settings-checkbox input:checked+.checkbox-mark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: .875rem;
    color: var(--txt);
}

.settings-checkbox-group .settings-hint {
    margin-left: 30px;
    margin-top: 4px;
}

/* Sub Options */
.settings-sub-options {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--bdr);
}

/* Filter Rules */
.filter-rules-section {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
    border-radius: 8px;
}

.filter-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.filter-rules-header label {
    font-size: .75rem;
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    flex: 1;
    /* 1/3 */
}

.btn-add {
    flex: 2;
    /* 2/3 */
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
}

.filter-rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.filter-rule-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--bdr2);
    border-radius: 6px;
}

.filter-rule-inputs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.filter-rule-item input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg3);
    border: 1px solid var(--bdr);
    font-size: .8125rem;
    color: var(--txt);
    border-radius: 4px;
}

.filter-rule-item input:focus {
    border-color: var(--acc);
    outline: none;
}

.filter-rule-item .rule-arrow {
    color: var(--txt3);
    font-size: .875rem;
    flex-shrink: 0;
    padding: 2px 0;
}

.filter-rule-item .btn-del-rule {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--hl);
    color: var(--hl);
    cursor: pointer;
    border-radius: 4px;
    font-size: .75rem;
    transition: all .2s;
    flex-shrink: 0;
    align-self: center;
}

.filter-rule-item .btn-del-rule:hover {
    background: var(--hl-soft);
}

/* Vector Stats - Original horizontal layout */
.vector-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
    font-size: .875rem;
    color: var(--txt2);
    margin-top: 8px;
}

.vector-stat-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.vector-stat-label {
    font-size: .75rem;
    color: var(--txt3);
}

.vector-stat-value {
    color: var(--txt2);
}

.vector-stat-value strong {
    color: var(--hl);
}

.vector-stat-sep {
    color: var(--txt3);
    align-self: center;
}

.vector-io-section {
    border-top: 1px solid var(--bdr);
    padding-top: 16px;
    margin-top: 16px;
}

/* Mobile Settings Responsive */
@media (max-width: 768px) {
    .settings-modal-box {
        max-width: 100%;
    }

    .settings-collapse-header {
        padding: 14px 16px;
    }

    .settings-checkbox-group {
        padding: 14px;
    }

    .checkbox-label {
        font-size: .8125rem;
    }

    .vector-stats {
        gap: 8px;
    }

    .vector-stat-sep {
        display: none;
    }

    .vector-stat-col {
        flex-direction: row;
        gap: 4px;
    }

    .settings-field {
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .settings-checkbox-group {
        padding: 12px;
    }

    .checkbox-mark {
        width: 18px;
        height: 18px;
    }

    .settings-checkbox input:checked+.checkbox-mark::after {
        left: 5px;
        top: 1px;
        width: 4px;
        height: 9px;
    }

    .filter-rules-section {
        padding: 12px;
    }

    .filter-rule-item {
        padding: 8px 10px;
    }

    .filter-rule-item .btn-del-rule {
        padding: 4px 8px;
    }

    .settings-sub-options .settings-row {
        flex-direction: column;
    }
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 24px;
    align-self: flex-end;
    /* 使底部边框与 header 底部对齐 */
    margin-bottom: -20px;
    /* 抵消 modal-head 的 padding，让边框贴合底部 */
}

.settings-tab {
    font-size: .875rem;
    color: var(--txt3);
    cursor: pointer;
    padding-bottom: 20px;
    /* 增加内边距使点击区域更大且贴合底部 */
    border-bottom: 2px solid transparent;
    transition: all .2s;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 500;
}

.settings-tab:hover {
    color: var(--txt);
}

.settings-tab.active {
    color: var(--hl);
    border-bottom-color: var(--hl);
    font-weight: 600;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn .3s ease;
}

.debug-log-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--bdr2);
}

.debug-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Recall Log / Debug Log
   ═══════════════════════════════════════════════════════════════════════════ */

.debug-log-viewer {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'SF Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.recall-empty {
    color: #999;
    text-align: center;
    padding: 40px;
    font-style: italic;
    font-size: .8125rem;
    line-height: 1.8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   记忆锚点区域（L0）
   ═══════════════════════════════════════════════════════════════════════════ */

.anchor-section {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.05), rgba(255, 152, 0, 0.05));
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
}

.anchor-header {
    margin-bottom: 12px;
}

.anchor-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 4px;
}

.anchor-icon {
    font-size: 1rem;
}

.anchor-hint {
    font-size: 0.75rem;
    color: var(--txt3);
}

.anchor-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--txt2);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg2);
    border-radius: 6px;
}

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

.anchor-stat-label {
    color: var(--txt3);
}

.anchor-stat-value strong {
    color: var(--hl);
    font-weight: 600;
}

.anchor-stat-sep {
    color: var(--txt3);
}

.anchor-stat-pending {
    color: #f59e0b;
    font-size: 0.75rem;
}

.anchor-stat-pending strong {
    font-weight: 600;
}

.anchor-progress {
    margin-bottom: 12px;
}

.anchor-actions {
    display: flex;
    gap: 8px;
}

.anchor-actions .btn {
    flex: 1;
    min-width: 0;
}

.vector-empty-warning {
    font-size: 0.75rem;
    color: #f59e0b;
    margin-top: 6px;
}

@media (max-width: 768px) {
    .anchor-section {
        padding: 12px;
    }

    .anchor-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .anchor-stat-sep {
        display: none;
    }
}

@media (max-width: 480px) {
    .anchor-title {
        font-size: 0.8125rem;
    }

    .anchor-stats {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Metrics Log Styling
   ═══════════════════════════════════════════════════════════════════════════ */

#recall-log-content .metric-warn {
    color: #f59e0b;
}

#recall-log-content .metric-error {
    color: #ef4444;
}

#recall-log-content .metric-good {
    color: #22c55e;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Guide Tab (使用说明)
   ═══════════════════════════════════════════════════════════════════════════ */

.guide-container {
    font-size: .875rem;
    line-height: 1.7;
    color: var(--txt2);
}

/* Section */
.guide-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--bdr2);
}

.guide-section-last,
.guide-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Title */
.guide-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--txt);
}

.guide-num {
    width: 26px;
    height: 26px;
    background: var(--acc);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .8125rem;
    flex-shrink: 0;
}

/* Text */
.guide-text {
    margin-bottom: 8px;
    color: var(--txt2);
}

.guide-text:last-child {
    margin-bottom: 0;
}

.guide-text a {
    color: var(--hl);
    text-decoration: none;
}

.guide-text a:hover {
    text-decoration: underline;
}

/* Steps */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 4px;
}

.guide-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.guide-step-num {
    width: 22px;
    height: 22px;
    background: var(--hl);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.guide-step-body {
    flex: 1;
    min-width: 0;
}

.guide-step-title {
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 2px;
    font-size: .875rem;
}

.guide-step-desc {
    color: var(--txt2);
    font-size: .8125rem;
    line-height: 1.6;
}

.guide-step-desc a {
    color: var(--hl);
    text-decoration: none;
}

.guide-step-desc a:hover {
    text-decoration: underline;
}

.guide-tag {
    display: inline-block;
    padding: 1px 8px;
    background: var(--hl-soft);
    color: var(--hl);
    border-radius: 10px;
    font-size: .6875rem;
    font-weight: 500;
    vertical-align: middle;
    margin-left: 4px;
}

/* Card List */
.guide-card-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.guide-card {
    padding: 14px 16px;
    background: var(--bg3);
    border: 1px solid var(--bdr2);
    border-radius: 6px;
    transition: border-color .2s;
}

.guide-card:hover {
    border-color: var(--bdr);
}

.guide-card-title {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 6px;
}

.guide-card-desc {
    font-size: .75rem;
    color: var(--txt3);
    line-height: 1.6;
}

/* Highlight */
.guide-highlight {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(216, 122, 122, .06), rgba(216, 122, 122, .02));
    border: 1px solid rgba(216, 122, 122, .2);
    border-radius: 8px;
    margin-top: 4px;
}

.guide-highlight-title {
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 8px;
    font-size: .875rem;
}

/* List */
.guide-list {
    margin: 8px 0;
    padding-left: 20px;
    color: var(--txt2);
}

.guide-list li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.guide-list li:last-child {
    margin-bottom: 0;
}

.guide-list li::marker {
    color: var(--hl);
}

.guide-list a {
    color: var(--hl);
    text-decoration: none;
}

.guide-list a:hover {
    text-decoration: underline;
}

.guide-list code {
    background: var(--bg3);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: .75rem;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    color: var(--txt);
}

.guide-list-inner {
    margin-top: 6px;
    margin-bottom: 4px;
    padding-left: 18px;
}

.guide-list-inner li {
    margin-bottom: 3px;
    font-size: .8125rem;
    color: var(--txt3);
}

.guide-list-inner li::marker {
    color: var(--txt3);
}

/* Tip */
.guide-tip {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    background: var(--bg3);
    border: 1px solid var(--bdr2);
    border-left: 3px solid var(--hl);
    border-radius: 0 6px 6px 0;
    margin-top: 12px;
}

.guide-tip-icon {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1.5;
}

.guide-tip-text {
    font-size: .8125rem;
    color: var(--txt2);
    line-height: 1.6;
    flex: 1;
}

/* Tips List */
.guide-tips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.guide-tips-list .guide-tip {
    margin-top: 0;
}

/* FAQ */
.guide-faq-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 4px;
}

.guide-faq-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--bdr2);
}

.guide-faq-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.guide-faq-item:first-child {
    padding-top: 0;
}

.guide-faq-q {
    font-weight: 600;
    color: var(--txt);
    font-size: .8125rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.guide-faq-q::before {
    content: 'Q';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--acc);
    color: #fff;
    border-radius: 3px;
    font-size: .625rem;
    font-weight: 700;
    flex-shrink: 0;
}

.guide-faq-a {
    font-size: .8125rem;
    color: var(--txt2);
    line-height: 1.6;
    padding-left: 24px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Guide Tab - Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .guide-container {
        font-size: .8125rem;
    }

    .guide-title {
        font-size: .9375rem;
    }

    .guide-num {
        width: 24px;
        height: 24px;
        font-size: .75rem;
    }

    .guide-section {
        margin-bottom: 20px;
        padding-bottom: 18px;
    }

    .guide-card-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .guide-card {
        padding: 12px 14px;
    }

    .guide-step {
        gap: 10px;
    }

    .guide-step-num {
        width: 20px;
        height: 20px;
        font-size: .6875rem;
    }

    .guide-highlight {
        padding: 14px 16px;
    }

    .guide-tip {
        padding: 10px 12px;
    }

    .guide-faq-a {
        padding-left: 0;
    }

    .guide-faq-q::before {
        width: 16px;
        height: 16px;
        font-size: .5625rem;
    }
}

@media (max-width: 480px) {
    .guide-container {
        font-size: .75rem;
    }

    .guide-title {
        font-size: .875rem;
        gap: 8px;
    }

    .guide-num {
        width: 22px;
        height: 22px;
        font-size: .6875rem;
    }

    .guide-section {
        margin-bottom: 16px;
        padding-bottom: 14px;
    }

    .guide-steps {
        gap: 12px;
    }

    .guide-step-title {
        font-size: .8125rem;
    }

    .guide-step-desc {
        font-size: .75rem;
    }

    .guide-card-title {
        font-size: .75rem;
    }

    .guide-card-desc {
        font-size: .6875rem;
    }

    .guide-highlight {
        padding: 12px 14px;
    }

    .guide-highlight-title {
        font-size: .8125rem;
    }

    .guide-list {
        padding-left: 16px;
        font-size: .75rem;
    }

    .guide-list-inner li {
        font-size: .75rem;
    }

    .guide-tip {
        padding: 8px 10px;
        gap: 8px;
    }

    .guide-tip-icon {
        font-size: .875rem;
    }

    .guide-tip-text {
        font-size: .75rem;
    }

    .guide-faq-q {
        font-size: .75rem;
    }

    .guide-faq-a {
        font-size: .75rem;
    }

    .guide-faq-item {
        padding: 10px 0;
    }
}

@media (hover: none) and (pointer: coarse) {
    .guide-card:hover {
        border-color: var(--bdr2);
    }
}