/* emoqi ANALYSIS OS: warm paper, ink type, hairlines, frosted glass */
:root {
    --bg: #e9e6de;
    --paper: #f4f2ec;
    --glass: rgba(255, 255, 255, 0.58);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --sunken: rgba(20, 20, 18, 0.045);
    --ink: #141413;
    --ink-2: #4d4c46;
    --ink-3: #6b695f;
    --line: rgba(20, 20, 18, 0.16);
    --line-strong: rgba(20, 20, 18, 0.62);
    --gold: #c49a3a;
    --gold-bg: rgba(196, 154, 58, 0.16);
    --ok: #2d7a58;
    --warn: #a86f12;
    --bad: #b3432f;
    --radius: 3px;
    --font: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 30% 0%, rgba(255, 255, 255, 0.7), transparent 70%),
        repeating-linear-gradient(90deg, rgba(20, 20, 18, 0.028) 0 1px, transparent 1px 18px);
    background-attachment: fixed;
    min-height: 100vh;
}

a { color: var(--ink); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.3; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.muted { color: var(--ink-3); font-size: 13px; }
.empty { color: var(--ink-3); padding: 32px 16px; text-align: center; grid-column: 1 / -1; }

/* tiny spaced labels, the recurring motif */
.label, .stat_label, .tab_en, .section_head h2 small, .fact_kind, .tag, .chip, .btn, .modal_subtab, .seg_btn, .status_step, .log_time {
    letter-spacing: 0.06em;
}

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(233, 230, 222, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar_inner {
    max-width: 1320px; margin: 0 auto; padding: 14px 28px 10px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand_mark {
    width: 40px; height: 40px; display: grid; place-items: center;
    border: 2px solid var(--ink); border-radius: 50%; font-size: 17px; position: relative;
}
.brand_mark::after { content: ""; position: absolute; inset: 5px; border: 1px solid var(--ink); border-radius: 50%; opacity: 0.45; }
.brand_text h1 { font-size: 22px; font-weight: 800; letter-spacing: 0.04em; line-height: 1; text-transform: uppercase; }
.brand_text p { font-size: 9.5px; letter-spacing: 0.2em; color: var(--ink-2); text-transform: uppercase; margin-top: 3px; line-height: 1.3; }
.brand_text p b { font-weight: 800; color: var(--ink); }

.status_box { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 220px; }
.status_dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(45, 122, 88, 0.16); flex: none; }
.status_dot.paused { background: var(--warn); box-shadow: 0 0 0 4px rgba(168, 111, 18, 0.16); }
.status_lines { display: flex; flex-direction: column; min-width: 0; }
.status_text { font-size: 13.5px; font-weight: 700; }
.status_step { font-size: 11px; color: var(--ink-3); text-transform: uppercase; }

.topbar_actions { display: flex; gap: 8px; }

.account_chips { display: flex; gap: 8px; }
.account_chip {
    display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px;
    background: var(--glass); border: 1px solid var(--line); border-radius: 999px; text-align: left;
}
.account_chip:hover { border-color: var(--line-strong); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--sunken); object-fit: cover; filter: grayscale(0.3); }
.account_text { display: flex; flex-direction: column; line-height: 1.25; max-width: 130px; }
.account_name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account_role { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.04em; }
.account_role.ok { color: var(--ok); }
.account_role.warn { color: var(--warn); }

.tabs {
    max-width: 1320px; margin: 0 auto; padding: 0 28px;
    display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    background: none; border: 0; border-bottom: 2px solid transparent;
    padding: 8px 16px 9px; font-size: 14px; color: var(--ink-2); white-space: nowrap;
    display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25;
}
.tab_en { font-size: 9.5px; letter-spacing: 0.18em; color: var(--ink-3); font-weight: 600; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.tab.active .tab_en { color: var(--gold); }
.tab_count { margin-left: 5px; font-size: 11px; color: var(--ink-3); font-weight: 400; font-family: var(--mono); }

/* ---------- buttons & inputs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; background: transparent; border: 1px solid var(--line-strong);
    border-radius: 2px; font-size: 13px; font-weight: 600; white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn_primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn_primary:hover { background: #2b2a27; }
.btn_sm { padding: 5px 13px; font-size: 12px; }
.btn_block { width: 100%; margin-top: 12px; }
.btn_more { display: block; margin: 18px auto 0; min-width: 180px; }

.input {
    width: 100%; background: var(--glass-strong); color: var(--ink);
    border: 1px solid var(--line); border-radius: 2px; padding: 9px 12px; font: inherit;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 2px 0 var(--gold); }
textarea.input { resize: vertical; line-height: 1.6; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 3px 12px; background: transparent; border: 1px solid var(--line-strong);
    border-radius: 999px; font-size: 12px; color: var(--ink-2);
}
.chip:hover { background: var(--sunken); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip small { margin-left: 5px; opacity: 0.65; font-size: 11px; font-family: var(--mono); }

.tag {
    display: inline-block; padding: 0 8px; border-radius: 2px; background: var(--sunken);
    border: 1px solid transparent; font-size: 12px; color: var(--ink-2); line-height: 1.8;
}
a.tag { text-decoration: none; }
a.tag:hover { border-color: var(--ink); }
.tag_entity { background: var(--gold-bg); color: #6c5210; }
.tag_row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag_link { cursor: pointer; font: inherit; letter-spacing: 0.04em; border: 1px solid var(--line); background: transparent; }
.tag_link:hover { border-color: var(--ink); background: var(--sunken); }

/* ---------- layout ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 28px; }
.pane { display: none; }
.pane.active { display: block; }

.section_head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong);
}
.section_head:first-child { margin-top: 0; }
.section_head h2 { font-size: 19px; font-weight: 800; }
.section_head h2 small { margin-left: 10px; font-size: 10px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.2em; }

.lead { margin: -4px 0 12px; font-size: 14px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .input { max-width: 400px; }
.toolbar .muted { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; counter-reset: file; }
.grid_2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 14px; counter-reset: file; }
.select_inline { width: auto; min-width: 130px; }

/* archive cards: glass slab with a FILE # tab on the top edge */
.card {
    position: relative; background: var(--glass); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px 16px;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 24px -18px rgba(20, 20, 18, 0.5);
}
#history_list .card, #events_list .card, #notes_content .card, #knowledge_list .card { counter-increment: file; }
#history_list .card::before, #events_list .card::before, #notes_content .card::before, #knowledge_list .card::before {
    content: "FILE # " counter(file, decimal-leading-zero);
    position: absolute; top: -8px; left: 16px; padding: 0 7px;
    background: var(--bg); font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--ink-3);
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line-strong); background: var(--glass); }
.stat { padding: 12px 18px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat_label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; font-weight: 600; }
.stat_value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat_mono { font-family: var(--mono); font-size: 16px; font-weight: 700; line-height: 2.1; }

/* ---------- channels ---------- */
.channel_grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.channel {
    --c: var(--ink); background: var(--glass); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.channel.idle { opacity: 0.7; border-style: dashed; }
.channel_head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px 8px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.channel_name { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.channel_name::before { content: ""; width: 8px; height: 8px; background: var(--c); flex: none; }
.channel_step { color: var(--ink-3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel_cover { position: relative; aspect-ratio: 16 / 9; background: var(--sunken); }
.channel_cover img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(0.9); }
.channel_idle_note { display: grid; place-items: center; height: 100%; color: var(--ink-3); font-size: 12.5px; letter-spacing: 0.08em; }
.channel_body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.channel_title {
    font-size: 14px; font-weight: 700; line-height: 1.45; color: var(--ink); text-decoration: none;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em;
}
.channel_title:hover { text-decoration: underline; text-decoration-color: var(--gold); }
.channel_meta { font-size: 12px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 8px; }
.channel_meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- feed layout ---------- */
.feed_layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.feed_side { position: sticky; top: 118px; }
.log_box {
    background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 8px 4px; height: 70vh; min-height: 360px; overflow-y: auto;
    font-family: var(--mono); font-size: 12px; line-height: 1.6;
}
.log_box:empty::before { content: "等待新的运行日志…"; display: block; padding: 24px 12px; color: var(--ink-3); text-align: center; font-family: var(--font); }
.log_item { padding: 3px 12px; border-bottom: 1px dashed var(--line); word-break: break-word; }
.log_item:last-child { border-bottom: 0; }
.log_time { color: var(--ink-3); margin-right: 6px; }
.log_text { color: var(--ink-2); }
.log_warn .log_text { color: var(--warn); }
.log_error .log_text { color: var(--bad); }
.log_success .log_text { color: var(--ok); }

/* ---------- items ---------- */
.item { display: flex; gap: 16px; }
.item_thumb { flex: none; width: 176px; aspect-ratio: 16 / 9; border-radius: 2px; overflow: hidden; background: var(--sunken); align-self: flex-start; }
.item_thumb img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(0.9); }
.item_main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item_title { font-size: 16px; font-weight: 700; line-height: 1.45; color: var(--ink); text-decoration: none; }
.item_title:hover { text-decoration: underline; text-decoration-color: var(--gold); }
.item_meta { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 3px 14px; letter-spacing: 0.03em; }
.item_text { color: var(--ink-2); }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.expanded .clamp { display: block; -webkit-line-clamp: unset; }
.item_more { display: none; flex-direction: column; gap: 10px; margin-top: 4px; }
.expanded .item_more { display: flex; }
.toggle { align-self: flex-start; background: none; border: 0; border-bottom: 1px solid var(--line-strong); padding: 0 0 1px; font-size: 12px; letter-spacing: 0.08em; color: var(--ink); }
.toggle:hover { border-bottom-color: var(--gold); }

.sub_block { border-left: 2px solid var(--gold); padding: 2px 0 2px 12px; font-size: 14px; color: var(--ink-2); }
.sub_block b { display: block; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin-bottom: 2px; }
.sub_block ul { margin-left: 18px; }
.sub_block li { margin: 2px 0; }

.event_title, .kitem_topic { font-size: 16.5px; font-weight: 800; line-height: 1.45; }
.card_top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card_flow { display: flex; flex-direction: column; gap: 9px; }

/* ---------- unified knowledge ---------- */
.pipeline_note { font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line); border-left: 3px solid var(--gold); background: var(--glass); padding: 8px 12px; margin-bottom: 12px; }
.pipeline_note:empty { display: none; }
.topic_meta { font-size: 11.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 3px 14px; font-family: var(--mono); letter-spacing: 0.02em; }
.fact_list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.fact { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.fact_text { flex: 1; min-width: 0; }
.fact_kind { flex: none; margin-top: 3px; padding: 0 7px; border-radius: 2px; font-size: 10.5px; line-height: 1.8; font-weight: 700; background: var(--sunken); color: var(--ink-3); border: 1px solid var(--line); }
.fact_kind.web { color: var(--ok); border-color: var(--ok); background: transparent; }
.fact_kind.video { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.fact_kind.chat { color: var(--warn); border-color: var(--warn); background: transparent; }
.fact_src { display: inline-block; max-width: 240px; margin-left: 6px; font-size: 12px; vertical-align: bottom; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purpose { font-weight: 700; margin-right: 4px; color: #6c5210; }

/* view switch */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden; }
.seg_btn { border: 0; background: transparent; padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.seg_btn + .seg_btn { border-left: 1px solid var(--line-strong); }
.seg_btn.active { background: var(--ink); color: var(--paper); }

/* ---------- relationship network ---------- */
.net_layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: stretch; margin-top: 14px; }
.net_stage {
    position: relative; border: 1px solid var(--line-strong); border-radius: var(--radius);
    background-color: var(--paper);
    background-image: radial-gradient(circle, rgba(20, 20, 18, 0.16) 1px, transparent 1.4px);
    background-size: 22px 22px; overflow: hidden; min-height: 460px; height: 70vh;
}
#net_canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#net_canvas.dragging { cursor: grabbing; }
.net_hud { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.net_info { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--ink-2); background: var(--glass-strong); padding: 3px 8px; border: 1px solid var(--line); }
.net_zoom { display: flex; flex-direction: column; pointer-events: auto; border: 1px solid var(--line-strong); background: var(--glass-strong); }
.net_zoom button { width: 30px; height: 30px; border: 0; background: transparent; font-size: 16px; line-height: 1; }
.net_zoom button + button { border-top: 1px solid var(--line); }
.net_zoom button:hover { background: var(--ink); color: var(--paper); }
.net_legend { position: absolute; left: 12px; bottom: 10px; right: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--ink-2); pointer-events: none; }
.net_legend span { display: inline-flex; align-items: center; gap: 5px; background: var(--glass-strong); padding: 0 6px; }
.net_legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.net_empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); pointer-events: none; }

.net_detail { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--glass-strong); padding: 18px 20px; height: 70vh; min-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.net_detail .file_no { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: var(--ink-3); }
.net_detail h3 { font-size: 22px; font-weight: 800; line-height: 1.25; border-bottom: 1px solid var(--line-strong); padding-bottom: 8px; }
.net_detail .hint_empty { color: var(--ink-3); font-size: 14px; }
.meta_grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12.5px; }
.meta_grid dt { font-size: 10px; letter-spacing: 0.16em; color: var(--ink-3); text-transform: uppercase; }
.meta_grid dd { font-weight: 600; margin: 0 0 4px; }
.neighbor { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; background: transparent; border: 1px solid var(--line); padding: 7px 10px; border-radius: 2px; }
.neighbor:hover { border-color: var(--ink); background: var(--sunken); }
.neighbor b { font-size: 13.5px; }
.neighbor small { color: var(--ink-3); font-size: 11.5px; }

/* ---------- hubs ---------- */
.net_left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.net_tools { display: flex; gap: 4px; pointer-events: auto; flex-wrap: wrap; }
.net_tool { border: 1px solid var(--line-strong); background: var(--glass-strong); padding: 2px 10px; font-size: 11.5px; letter-spacing: 0.06em; border-radius: 2px; }
.net_tool:hover { background: var(--sunken); }
.net_tool[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sec_group { margin-top: 10px; }
.sec_group:first-child { margin-top: 4px; }
.sec_title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink); margin-bottom: 5px; }
.sec_title small { color: var(--ink-3); font-family: var(--mono); font-weight: 400; margin-left: 4px; }
.tag_hub { background: var(--ink); color: var(--paper); }

/* ---------- twin memory ---------- */
.chat_top_actions { display: flex; gap: 8px; }
.modal_wide { max-width: 560px; }
.modal_sub { font-size: 14px; margin: 18px 0 6px; padding-top: 14px; border-top: 1px solid var(--line-strong); letter-spacing: 0.06em; }
.persona_summary { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.persona_summary details { background: var(--sunken); border: 1px solid var(--line); border-radius: 2px; padding: 8px 12px; }
.persona_summary summary { cursor: pointer; color: var(--ink-2); }
.persona_summary ul { margin: 8px 0 0 18px; color: var(--ink-2); }
.persona_summary li + li { margin-top: 4px; }

/* ---------- notes (markdown) ---------- */
.note_head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.note_date { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.note_body { max-height: 12.5em; overflow: hidden; position: relative; }
.note_body::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3.5em; background: linear-gradient(transparent, rgba(244, 242, 236, 0.95)); }
.expanded .note_body { max-height: none; }
.expanded .note_body::after { display: none; }

.md { color: var(--ink-2); max-width: 72ch; }
.md > * + * { margin-top: 0.8em; }
.md h1, .md h2, .md h3, .md h4 { color: var(--ink); margin-top: 1.2em; font-weight: 800; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 0.3em; }
.md strong { color: var(--ink); }
.md code { font-family: var(--mono); font-size: 0.9em; background: var(--sunken); padding: 1px 5px; border-radius: 2px; }
.md blockquote { border-left: 2px solid var(--gold); padding-left: 12px; color: var(--ink-3); }
.md hr { border: 0; border-top: 1px solid var(--line); }

/* ---------- chat ---------- */
.chat_shell {
    background: var(--glass); border: 1px solid var(--line-strong); border-radius: var(--radius);
    display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 480px; max-width: 880px; margin: 0 auto;
}
.chat_top { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-strong); }
.chat_top h2 { font-size: 18px; font-weight: 800; }
.chat_messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.chat_msg { display: flex; gap: 10px; max-width: 92%; }
.chat_msg.msg_user { align-self: flex-end; flex-direction: row-reverse; }
.msg_avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 13px; background: var(--paper); }
.msg_body { padding: 10px 14px; border-radius: 2px; background: var(--glass-strong); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg_user .msg_body { background: var(--ink); border-color: var(--ink); color: var(--paper); white-space: pre-wrap; }
.msg_assistant .md { max-width: none; color: var(--ink); }
.msg_pending { color: var(--ink-3); font-style: italic; }
.chat_suggest { padding: 0 18px 10px; }
.chat_input_bar { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat_textarea { resize: none; }

.code_area { font-family: var(--mono); font-size: 13px; line-height: 1.7; min-height: 60vh; }

/* ---------- modal ---------- */
.modal_overlay {
    position: fixed; inset: 0; z-index: 50; background: rgba(233, 230, 222, 0.62);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal_overlay.active { display: flex; }
.modal_box {
    width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
    background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius);
    padding: 20px; box-shadow: 0 30px 60px -30px rgba(20, 20, 18, 0.55);
}
.modal_header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); }
.modal_header h3 { font-size: 17px; font-weight: 800; }
.btn_close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--ink-3); padding: 0 4px; }
.btn_close:hover { color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-3); margin: 10px 0; }
.modal_box .seg { display: flex; }
.modal_box .seg_btn { flex: 1; padding: 8px; }
.modal_subtabs { display: flex; gap: 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.modal_subtab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 2px; color: var(--ink-2); font-size: 13px; }
.modal_subtab.active { color: var(--ink); border-bottom-color: var(--gold); font-weight: 700; }
.login_view { display: none; }
.login_view.active { display: block; }
.qr_wrapper { position: relative; width: 200px; height: 200px; margin: 0 auto; background: #fff; border: 1px solid var(--line-strong); padding: 8px; }
.qr_image { width: 100%; height: 100%; display: block; }
.qr_overlay { position: absolute; inset: 0; background: rgba(20, 20, 18, 0.78); color: #fff; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.qr_status_msg { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }

.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
    background: var(--ink); color: var(--paper); padding: 10px 20px; border-radius: 2px; font-size: 13.5px;
    opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.page_foot { max-width: 1320px; margin: 0 auto; padding: 8px 28px 32px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: var(--ink-3); text-transform: uppercase; }
.page_foot b { color: var(--ink); }

/* ---------- passkey gate ---------- */
.locked .topbar, .locked .page, .locked .page_foot { display: none; }
.auth_gate { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.locked .auth_gate { display: flex; }
.auth_card {
    width: 100%; max-width: 420px; padding: 28px 28px 24px; background: var(--glass-strong);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    box-shadow: 0 30px 60px -34px rgba(20, 20, 18, 0.55);
}
.auth_label { margin: 26px 0 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }
.auth_card h2 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.auth_card .field { margin-top: 14px; }
.auth_error { min-height: 1.5em; margin-top: 12px; font-size: 13px; color: var(--bad); }
.passkey_list { display: flex; flex-direction: column; gap: 8px; }
.passkey_row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--sunken); }
.passkey_row b { font-size: 14px; }
.passkey_row small { display: block; color: var(--ink-3); font-size: 11.5px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .channel_grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .feed_layout, .net_layout { grid-template-columns: minmax(0, 1fr); }
    .feed_side { position: static; }
    .log_box { height: 320px; min-height: 0; }
    .net_detail { height: auto; min-height: 0; max-height: 60vh; }
}
@media (max-width: 760px) {
    .topbar_inner { padding: 10px 16px; gap: 10px; }
    .tabs, .page, .page_foot { padding-left: 16px; padding-right: 16px; }
    .page { padding-top: 18px; }
    .brand_text p { display: none; }
    .account_chips, .topbar_actions { width: 100%; }
    .account_chip, .topbar_actions .btn { flex: 1; min-width: 0; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat:nth-child(3) { border-left: 0; }
    .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
    .channel_grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .channel_head { flex-direction: column; align-items: flex-start; gap: 0; }
    .grid_2 { grid-template-columns: minmax(0, 1fr); }
    .item { flex-direction: column; }
    .item_thumb { width: 100%; }
    .toolbar .muted { margin-left: 0; }
    .net_stage { height: 56vh; min-height: 340px; }
    .chat_shell { height: calc(100vh - 230px); }
    .chat_msg { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
