:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1d2129;
    --muted: #6b7280;
    --border: #e3e5e8;
    --primary: #2f6fed;
    --primary-text: #ffffff;
    --ok: #16a34a;
    --ok-bg: #e8f7ee;
    --wait: #b45309;
    --wait-bg: #fdf3e2;
    --bad: #dc2626;
    --bad-bg: #fdecec;
    --idle-bg: #eef0f3;
    --surface: #1f2430;
    --surface-active: #14315f;
    --surface-text: #d6dae3;
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111317;
        --card: #1b1e24;
        --text: #e6e8eb;
        --muted: #9aa1ac;
        --border: #2c3038;
        --primary: #4d86f7;
        --ok: #4ade80;
        --ok-bg: #12301f;
        --wait: #fbbf24;
        --wait-bg: #33270f;
        --bad: #f87171;
        --bad-bg: #3a1717;
        --idle-bg: #262a31;
        --surface: #0b0d11;
        --surface-active: #10274d;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 4px 0; }
h3 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--idle-bg); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
a { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.ok { color: var(--ok); }
.warn { color: var(--wait); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.nav a.current, .nav a:hover { background: var(--idle-bg); color: var(--text); }

.container { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

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

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.step-no {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--primary); color: var(--primary-text); font-size: 13px;
}

/* 按钮 */
.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.chip { padding: 6px 12px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }
.link-btn { appearance: none; border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; font-size: 13px; }
.link-btn:disabled { color: var(--muted); cursor: default; }

/* 状态标签 */
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px; font-size: 13px;
    background: var(--idle-bg); color: var(--muted);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.wait { background: var(--wait-bg); color: var(--wait); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill:empty { display: none; }

/* 首页 */
.hero { margin: 8px 0 20px; }
.hero h1 { font-size: 24px; margin-bottom: 6px; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.role { display: block; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; margin: 0; }
.role:hover { border-color: var(--primary); transform: translateY(-2px); }
.role p { margin: 6px 0; }
.role-icon { font-size: 30px; }
.steps { padding-left: 36px; }
.steps li { margin: 6px 0; }

/* 表单 */
input, textarea, select {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field input { width: 100%; }
.share { display: flex; gap: 8px; margin-bottom: 8px; }
.share input { flex: 1; }

/* 活动记录 */
.log { list-style: none; margin: 10px 0 0; padding: 0; max-height: 260px; overflow: auto; font-size: 13px; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.log li .mono { color: var(--muted); margin-right: 6px; }
.log li.dropped { color: var(--muted); }

details.card summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary h3 { margin: 0; }
details.card summary h3::before { content: "▸"; color: var(--muted); }
details.card[open] summary h3::before { content: "▾"; }
details.card[open] summary { margin-bottom: 14px; }

/* 输入面板 */
.ip-blocked {
    background: var(--wait-bg); color: var(--wait);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
.ip-stage { background: var(--surface); border-radius: 10px; }
.ip-stage:fullscreen { border-radius: 0; }
.ip-surface {
    position: relative;
    height: 280px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--surface-text);
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    outline: none;
    padding: 16px;
    transition: background .15s;
}
.ip-stage:fullscreen .ip-surface { height: 100vh; border-radius: 0; }
.ip-surface.active { background: var(--surface-active); box-shadow: inset 0 0 0 2px var(--primary); cursor: none; }
.ip-surface-hint { font-size: 16px; max-width: 420px; }
.ip-pressed { position: absolute; bottom: 12px; left: 0; right: 0; font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: #9ec1ff; }
.ip-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.ip-sens { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ip-sens input { padding: 0; width: 120px; }
.ip-sens output { min-width: 36px; color: var(--muted); }
.ip-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ip-text-options { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 14px; }
.ip-text-options label { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
.ip-text-options select { min-width: 0; max-width: 100%; }
.ip-text-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ip-progress { width: 100%; margin-top: 10px; }
.ip-text-status { margin-top: 8px; min-height: 1em; }

/* 提示 */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
    background: var(--text); color: var(--bg);
    padding: 10px 18px; border-radius: 999px; font-size: 14px;
    opacity: 0; transition: opacity .2s, transform .2s; z-index: 100;
    max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 560px) {
    .topbar { padding: 10px 12px; }
    .brand { font-size: 14px; }
    .ip-surface { height: 240px; }
    .share { flex-direction: column; }
}
