:root {
    --bg: #f4f6f4;
    --panel: #ffffff;
    --panel-soft: #f8faf8;
    --line: #dfe5df;
    --text: #19211d;
    --muted: #6b766f;
    --primary: #1f8a5b;
    --primary-dark: #176d47;
    --accent: #3f6f9f;
    --danger: #c63d3d;
    --warning: #b97718;
    --bubble-customer: #ffffff;
    --bubble-assistant: #b9efc9;
    --shadow: 0 12px 34px rgba(31, 45, 38, 0.10);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 10px 11px;
    outline: none;
}

textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 138, 91, 0.12);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 600;
}

.checkbox-label {
    grid-template-columns: auto 1fr;
    align-items: center;
    align-content: center;
    gap: 8px;
    min-height: 42px;
    color: var(--text);
}

.checkbox-label input {
    width: auto;
}

button {
    border: 0;
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    min-height: 40px;
    white-space: nowrap;
}

button.primary {
    background: var(--primary);
    color: #fff;
}

button.primary:hover {
    background: var(--primary-dark);
}

button.secondary,
button.ghost {
    background: #e9efec;
    color: var(--text);
}

button.danger {
    background: var(--danger);
    color: #fff;
}

button.danger-text {
    background: transparent;
    color: var(--danger);
    padding: 4px 0;
    min-height: 0;
}

button.wide {
    width: 100%;
}

.topbar {
    height: 68px;
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.topbar nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.topbar nav a,
.logout {
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--muted);
}

.topbar nav a.active {
    color: var(--primary-dark);
    background: #e7f4ee;
    font-weight: 700;
}

.logout {
    color: var(--danger);
}

.page {
    padding: 20px;
}

.split-layout {
    display: grid;
    gap: 18px;
    align-items: start;
}

.chat-layout {
    grid-template-columns: minmax(760px, 1fr) 360px;
}

.samples-layout,
.rules-layout,
.traces-layout {
    grid-template-columns: 300px minmax(480px, 1fr) 340px;
}

.side-panel,
.content-panel,
.order-panel,
.settings-panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.side-panel,
.content-panel,
.order-panel {
    padding: 16px;
}

.section-title {
    margin: 18px 0 10px;
    color: var(--text);
    font-weight: 800;
}

.section-title:first-child {
    margin-top: 0;
}

.stack-form {
    display: grid;
    gap: 10px;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.session-list,
.rule-list {
    display: grid;
    gap: 8px;
    max-height: calc(100vh - 250px);
    overflow: auto;
}

.session-item,
.rule-item,
.file-card {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: var(--panel-soft);
    border: 1px solid transparent;
    border-radius: 6px;
}

.session-item.active,
.rule-item.active {
    border-color: var(--primary);
    background: #edf8f2;
}

.session-item span,
.rule-item span,
.rule-item small,
.file-card span,
.file-card small,
.muted {
    color: var(--muted);
    font-size: 12px;
}

.session-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.session-tag {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 700;
    color: #2c2f33;
    background: #eef1f4;
    border: 1px solid #dce1e6;
}

.session-tag.source-console {
    color: #2f4d6f;
    background: #e8f1fb;
    border-color: #c8dcee;
}

.session-tag.source-reused,
.session-tag.source-qiwe,
.session-tag.source-message {
    color: #1f5c35;
    background: #e6f4eb;
    border-color: #bddfc8;
}

.session-tag.binding-bound {
    color: #5c3d00;
    background: #fff3cf;
    border-color: #ecd48d;
}

.session-tag.binding-unbound {
    color: #60656b;
    background: #f4f5f6;
    border-color: #e0e3e6;
}

.rule-id-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rule-id-row code,
.rule-identity-panel strong {
    font-family: Consolas, "Courier New", monospace;
}

.rule-id-row code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #eef2ef;
    color: #2d5845;
    font-size: 12px;
}

.rule-id-row em {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.wechat-shell {
    height: calc(100vh - 108px);
    min-height: 620px;
    display: grid;
    grid-template-columns: 58px 286px minmax(420px, 1fr);
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.wechat-rail {
    display: grid;
    grid-template-rows: auto 1fr auto;
    justify-items: center;
    padding: 14px 0;
    background: #2e2e2e;
    color: #d6d6d6;
}

.wechat-self-avatar,
.wechat-rail-nav a,
.wechat-rail-settings,
.wechat-conv-avatar,
.message-avatar {
    display: grid;
    place-items: center;
}

.wechat-self-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: #1aad19;
    color: #fff;
    font-weight: 800;
}

.wechat-rail-nav {
    display: grid;
    gap: 10px;
    align-content: start;
    margin-top: 26px;
}

.wechat-rail-nav a,
.wechat-rail-settings {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: #bdbdbd;
    font-weight: 700;
}

.wechat-rail-nav a.active,
.wechat-rail-nav a:hover,
.wechat-rail-settings:hover {
    color: #fff;
    background: #3b3b3b;
}

.wechat-list-pane {
    display: grid;
    grid-template-rows: auto auto 1fr;
    overflow: hidden;
    background: #e8e8e8;
    border-right: 1px solid #d2d2d2;
}

.wechat-search-head {
    padding: 16px 12px 10px;
}

.wechat-order-form {
    display: grid;
    grid-template-columns: 1fr 36px;
    gap: 8px;
}

.wechat-order-form input {
    height: 36px;
    border: 0;
    border-radius: 4px;
    background: #dedede;
    padding: 0 10px;
}

.wechat-order-form button {
    min-height: 36px;
    height: 36px;
    padding: 0;
    border-radius: 4px;
    background: #d6d6d6;
    color: #333;
    font-size: 22px;
    line-height: 1;
}

.wechat-list-caption {
    padding: 0 14px 8px;
    color: #777;
    font-size: 12px;
}

.wechat-conversation-list {
    overflow-y: auto;
}

.wechat-conversation {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 10px;
    align-items: center;
    min-height: 88px;
    padding: 10px 12px;
    border-left: 3px solid transparent;
}

.wechat-conversation:hover {
    background: #dfdfdf;
}

.wechat-conversation.active {
    background: #d4d4d4;
    border-left-color: #1aad19;
}

.wechat-conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    background: #4aa3df;
    color: #fff;
    font-weight: 800;
}

.wechat-conv-body {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.wechat-conv-body strong,
.wechat-conv-body small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wechat-conv-body strong {
    font-size: 14px;
}

.wechat-conv-body small,
.wechat-contact-hint,
.wechat-conversation time {
    color: #777;
    font-size: 12px;
}

.chat-phone {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    background: #f5f5f5;
}

.wechat-empty {
    display: grid;
    place-content: center;
    gap: 8px;
    min-height: 100%;
    color: #8a8a8a;
    text-align: center;
}

.wechat-empty strong {
    color: #333;
    font-size: 18px;
}

.phone-head {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: #f8faf8;
    border-bottom: 1px solid var(--line);
}

.wechat-chat-head {
    min-height: 72px;
    background: #f5f5f5;
    border-bottom: 1px solid #dedede;
}

.wechat-chat-head strong {
    font-size: 16px;
}

.wechat-chat-head .ghost {
    background: #e8e8e8;
    border-radius: 4px;
}

.chat-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chat-head-actions form {
    margin: 0;
}

.takeover-segmented {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid #d5d5d5;
    border-radius: 4px;
    background: #fff;
}

.takeover-segmented .takeover-option {
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-right: 1px solid #d5d5d5;
    border-radius: 0;
    background: transparent;
    color: #555;
    font-size: 12px;
    white-space: nowrap;
}

.takeover-segmented .takeover-option:last-child {
    border-right: 0;
}

.takeover-segmented .takeover-option.active {
    background: #1aad19;
    color: #fff;
}

.takeover-segmented .takeover-option:not(.active):hover {
    background: #f2f2f2;
}

.phone-head strong,
.phone-head span {
    display: block;
}

.phone-head span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.phone-head .session-tags {
    display: flex;
    margin-top: 5px;
}

.phone-head .session-tag {
    display: inline-flex;
}

.phone-head .ai-takeover-mode {
    margin-top: 5px;
}

.chat-window {
    padding: 18px;
    overflow-y: auto;
}

.wechat-message-list {
    padding: 18px 24px;
    background: #f5f5f5;
}

.wechat-time-divider {
    width: fit-content;
    margin: 0 auto 18px;
    padding: 4px 9px;
    border-radius: 3px;
    background: #dadada;
    color: #fff;
    font-size: 12px;
}

.bubble-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 14px 0;
}

.bubble-row.customer {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.bubble-row.assistant {
    justify-content: flex-start;
}

.bubble-row.staff {
    justify-content: flex-start;
}

.message-avatar {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 4px;
    color: #fff;
    font-weight: 800;
    display: grid;
    place-items: center;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0;
}

.customer .message-avatar {
    background: #6f88a7;
}

.assistant .message-avatar {
    background: #1aad19;
}

.staff .message-avatar {
    background: #7a5a36;
    border: 1px solid #6a4d2d;
    font-size: 13px;
}

.message-stack {
    max-width: min(72%, 680px);
    display: grid;
    gap: 5px;
}

.customer .message-stack {
    justify-items: end;
}

.message-meta {
    color: #9a9a9a;
    font-size: 12px;
}

.bubble {
    position: relative;
    padding: 11px 13px;
    border-radius: 4px;
    line-height: 1.6;
    word-break: break-word;
    white-space: normal;
    box-shadow: none;
}

.customer .bubble {
    background: #95ec69;
    border: 1px solid #83dc5d;
}

.assistant .bubble {
    background: var(--bubble-customer);
    border: 1px solid #ededed;
}

.staff .bubble {
    background: #fff7e6;
    border: 1px solid #ead6b8;
}

.bubble::before {
    content: "";
    position: absolute;
    top: 13px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.customer .bubble::before {
    right: -7px;
    border-left: 7px solid #95ec69;
}

.assistant .bubble::before {
    left: -7px;
    border-right: 7px solid #fff;
}

.staff .bubble::before {
    left: -7px;
    border-right: 7px solid #fff7e6;
}

.bubble.pending {
    color: var(--muted);
}

.chat-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    background: #f8faf8;
    border-top: 1px solid var(--line);
}

.wechat-composer {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr;
    gap: 8px 12px;
    min-height: 158px;
    padding: 10px 14px 12px;
    background: #fff;
    border-top: 1px solid #dedede;
}

.composer-tools {
    grid-column: 1 / -1;
    display: flex;
    gap: 16px;
    height: 24px;
    align-items: center;
    color: #6b6b6b;
    font-size: 13px;
}

.chat-input textarea {
    min-height: 48px;
    max-height: 120px;
}

.wechat-composer textarea {
    min-height: 82px;
    max-height: 112px;
    border: 0;
    padding: 6px 2px;
    box-shadow: none;
    resize: none;
}

.wechat-composer textarea:focus {
    border: 0;
    box-shadow: none;
}

.wechat-composer button {
    align-self: end;
    min-width: 72px;
    min-height: 34px;
    padding: 0 18px;
    border-radius: 4px;
    background: #f5f5f5;
    border: 1px solid #dddddd;
    color: #06a306;
}

.wechat-composer button:hover {
    background: #f0f0f0;
}

.json-box {
    width: 100%;
    max-height: 480px;
    overflow: auto;
    padding: 12px;
    background: #101614;
    color: #d9efe2;
    border-radius: 6px;
    line-height: 1.45;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-box.compact {
    max-height: 320px;
}

.order-readable {
    display: grid;
    gap: 12px;
}

.order-freshness {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.order-freshness strong {
    font-size: 18px;
}

.order-freshness span {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.order-card,
.station-card,
.order-address,
.raw-snapshot {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.order-card {
    display: grid;
    gap: 5px;
}

.order-card-label,
.order-address span,
.station-card dt {
    color: var(--muted);
    font-size: 12px;
}

.order-card strong {
    font-size: 16px;
}

.order-card small {
    color: var(--muted);
}

.order-kv {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.order-kv span {
    color: var(--muted);
}

.order-kv strong {
    min-width: 0;
    word-break: break-word;
}

.price-text {
    color: var(--primary-dark);
    font-size: 16px;
}

.order-address {
    display: grid;
    gap: 6px;
}

.order-address p {
    margin: 0 0 8px;
    line-height: 1.55;
    word-break: break-word;
}

.order-address p:last-child {
    margin-bottom: 0;
}

.station-card {
    display: grid;
    gap: 10px;
}

.station-card strong {
    font-size: 14px;
}

.station-card dl {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px 10px;
    margin: 0;
}

.station-card dd {
    margin: 0;
    line-height: 1.55;
    word-break: break-word;
}

.raw-snapshot summary {
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
}

.raw-snapshot .json-box {
    margin-top: 10px;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    color: var(--muted);
    text-align: center;
    padding: 28px;
}

.empty-state.small {
    min-height: 80px;
    background: var(--panel-soft);
    border-radius: 6px;
}

.alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #eef7f1;
}

.alert.success {
    border-color: #9ad2b3;
    color: #176d47;
}

.alert.danger {
    border-color: #e2a6a6;
    background: #fff3f3;
    color: var(--danger);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.metric-grid div {
    display: grid;
    gap: 3px;
    padding: 10px;
    background: var(--panel-soft);
    border-radius: 6px;
    text-align: center;
}

.metric-grid strong {
    font-size: 20px;
}

.metric-grid span {
    color: var(--muted);
    font-size: 12px;
}

.learning-status {
    margin-top: 10px;
    min-height: 18px;
    color: var(--accent);
    font-size: 12px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12px;
}

tr.selected {
    background: #edf8f2;
}

form.inline {
    display: inline;
}

.message-editor {
    display: grid;
    gap: 10px;
}

.message-edit-row {
    display: grid;
    grid-template-columns: 92px 150px 160px minmax(260px, 1fr) auto auto;
    gap: 8px;
    align-items: start;
    padding: 10px;
    background: var(--panel-soft);
    border-radius: 6px;
}

.message-edit-row textarea {
    min-height: 56px;
}

.rule-editor {
    display: grid;
    gap: 14px;
}

.rule-identity-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.rule-identity-panel div {
    display: grid;
    gap: 4px;
}

.rule-identity-panel span {
    color: var(--muted);
    font-size: 12px;
}

.rule-identity-panel strong {
    font-size: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
}

.rule-editor textarea.tall {
    min-height: 150px;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trace-message,
.trace-card,
.mini-detail {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.trace-message strong {
    margin-right: 8px;
}

.trace-message span {
    color: var(--muted);
    font-size: 12px;
}

.trace-message p {
    margin: 8px 0 0;
    line-height: 1.6;
}

.trace-card summary,
.mini-detail summary {
    cursor: pointer;
    font-weight: 700;
}

.trace-card h4 {
    margin: 14px 0 8px;
}

.traces-layout {
    height: calc(100vh - 108px);
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: stretch;
    overflow: hidden;
}

.traces-layout > .order-panel {
    display: none;
}

.traces-layout .side-panel,
.traces-layout .content-panel {
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.traces-layout .session-list {
    max-height: calc(100% - 34px);
}

.trace-panel {
    display: grid;
    min-width: 0;
}

.trace-grid {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.15fr) minmax(280px, 0.9fr);
    gap: 12px;
    overflow: hidden;
}

.trace-column {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.trace-column .section-title {
    margin-bottom: 8px;
}

.trace-scroll {
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}

.trace-panel .json-box {
    max-height: 360px;
}

.trace-rule-note {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.trace-rewrite-note {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid #b7d5c3;
    border-radius: 6px;
    background: #edf8f2;
}

.trace-rewrite-note strong,
.trace-rewrite-note span,
.trace-rewrite-note small {
    display: block;
}

.trace-rewrite-note strong {
    color: #245a42;
    font-size: 12px;
}

.trace-rewrite-note span,
.trace-rewrite-note p,
.trace-rewrite-note small {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.trace-tool-reviews {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.trace-tool-review {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7fbf8;
}

.trace-tool-review.warning {
    border-color: #f0c36a;
    background: #fff8e7;
}

.trace-tool-review strong {
    display: block;
    margin: 0 0 4px;
    color: var(--text);
    font-size: 12px;
}

.trace-tool-review p,
.trace-tool-review small {
    display: block;
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.trace-tool-review code {
    display: block;
    color: #76510d;
    font-size: 11px;
    white-space: normal;
    word-break: break-all;
}

.trace-rules {
    margin-top: 8px;
}

.trace-rules summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.trace-rule-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.trace-rule-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 4px 6px;
    border-radius: 4px;
    background: #edf8f2;
    color: #245a42;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

.trace-rule-chip.selected {
    background: #dff4e8;
    border: 1px solid #9fc7b0;
}

.trace-rule-chip small {
    color: var(--muted);
    font-size: 11px;
}

.trace-warning-label {
    display: inline-flex;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fff0ca;
    color: #7a5200;
    font-size: 11px;
    font-weight: 700;
}

.trace-warning-box {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #f0c36a;
    border-radius: 6px;
    background: #fff8e7;
}

.trace-warning-box strong {
    display: block;
    color: #6f4b00;
    font-size: 13px;
}

.trace-warning-box p {
    margin: 4px 0 0;
    color: #755c25;
    font-size: 12px;
    line-height: 1.5;
}

.settings-panel {
    max-width: 860px;
    margin: 0 auto;
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(360px, 1fr) 280px;
    gap: 18px;
}

.settings-form {
    display: grid;
    gap: 14px;
}

.settings-section {
    display: grid;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.settings-section h2 {
    margin: 0;
    color: var(--text);
    font-size: 15px;
}

.form-grid.compact {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.info-box {
    padding: 14px;
    background: var(--panel-soft);
    border-radius: 6px;
}

.info-box p {
    font-family: Consolas, "Courier New", monospace;
    word-break: break-all;
}

.settings-endpoints {
    display: grid;
    gap: 6px;
    margin-top: 16px;
}

.settings-endpoints code {
    display: block;
    padding: 6px 8px;
    border-radius: 4px;
    background: #fff;
    color: #245a42;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    word-break: break-all;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(145deg, #f3f7f4 0%, #e7efea 100%);
}

.login-panel {
    width: min(420px, 100%);
    padding: 26px;
}

.login-panel h1 {
    margin: 0 0 18px;
    font-size: 24px;
}

.login-panel form {
    display: grid;
    gap: 12px;
}

@media (max-width: 1180px) {
    .chat-layout,
    .samples-layout,
    .rules-layout,
    .traces-layout {
        grid-template-columns: 1fr;
    }

    .wechat-shell {
        height: 720px;
        grid-template-columns: 58px 260px minmax(360px, 1fr);
    }

    .chat-phone {
        height: 100%;
    }

    .side-panel,
    .order-panel {
        max-height: none;
    }

    .traces-layout {
        height: auto;
        overflow: visible;
    }

    .traces-layout > .order-panel {
        display: block;
    }

    .traces-layout .side-panel,
    .traces-layout .content-panel {
        height: auto;
        overflow: visible;
    }

    .trace-grid {
        height: auto;
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .trace-scroll {
        max-height: 520px;
    }
}

@media (max-width: 760px) {
    .topbar {
        height: auto;
        padding: 12px;
        flex-wrap: wrap;
    }

    .brand {
        min-width: 0;
        width: 100%;
    }

    .page {
        padding: 12px;
    }

    .wechat-shell {
        height: calc(100vh - 150px);
        min-height: 620px;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }

    .wechat-rail {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: 1fr;
        align-items: center;
        justify-items: start;
        height: 54px;
        padding: 0 10px;
    }

    .wechat-rail-nav {
        display: flex;
        gap: 6px;
        margin: 0 0 0 12px;
    }

    .wechat-rail-settings {
        justify-self: end;
    }

    .wechat-list-pane {
        max-height: 210px;
        border-right: 0;
        border-bottom: 1px solid #d2d2d2;
    }

    .wechat-conversation-list {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .wechat-conversation {
        min-width: 260px;
        border-left: 0;
        border-bottom: 3px solid transparent;
    }

    .wechat-conversation.active {
        border-bottom-color: #1aad19;
    }

    .wechat-message-list {
        padding: 14px;
    }

    .message-stack {
        max-width: calc(100% - 54px);
    }

    .chat-input,
    .inline-form,
    .settings-panel {
        grid-template-columns: 1fr;
    }

    .message-edit-row,
    .form-grid,
    .rule-identity-panel {
        grid-template-columns: 1fr;
    }

    .form-grid.compact {
        grid-template-columns: 1fr;
    }

    .wechat-composer {
        grid-template-columns: 1fr;
        min-height: 170px;
    }

    .wechat-composer button {
        justify-self: end;
    }
}
