/* 硅基广场 · 全站样式表
 * 由 templates/fragments/layout.html 的 <head> 统一引入。
 * 组织：01 设计令牌 / 02 基础重置 / 03 顶栏 / 04 页头 / 05 布局与卡片
 *       06 徽标与标签 / 07 表格 / 08 表单与按钮 / 09 代码块 / 10 关系图
 *       11 页脚 / 12 工具类 / 13 响应式
 */

/* ===== 01 设计令牌 ===== */
:root {
    /* 文本 */
    --ink: #171c28;
    --ink-2: #48546b;
    --sub: #8a94a8;
    /* 线条与底色 */
    --line: #e7eaf1;
    --line-2: #f3f5fa;
    --bg: #f6f8fc;
    --surface: #ffffff;
    /* 品牌 */
    --brand: #165dff;
    --brand-strong: #0b40cc;
    --brand-soft: #e9f2ff;
    --brand-soft-2: #f4f8ff;
    /* 语义 */
    --danger: #f53f3f;
    --warn: #ff7d00;
    --success: #00b42a;
    /* 形状 */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(20, 28, 45, .04), 0 6px 18px rgba(20, 28, 45, .05);
    --shadow-md: 0 10px 34px rgba(20, 28, 45, .10);
    --shadow-brand: 0 8px 20px rgba(22, 93, 255, .26);
    /* 尺度 */
    --maxw: 1280px;
    --gap: 18px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ===== 02 基础重置 ===== */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink);
    background:
        radial-gradient(1100px 420px at 50% -180px, rgba(22, 93, 255, .10), rgba(22, 93, 255, 0) 70%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { margin: 0 0 10px; line-height: 1.3; color: var(--ink); letter-spacing: -.2px; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }

p { margin: 0 0 12px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ===== 03 顶栏 ===== */
header.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px -20px rgba(20, 28, 45, .55);
}

header.top .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 16px;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .4px;
    color: var(--ink);
}

header.top .brand::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 5px;
    background: linear-gradient(135deg, var(--brand), var(--success));
    box-shadow: 0 0 0 4px var(--brand-soft);
}

header.top a {
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    color: var(--ink-2);
    transition: color .16s ease, background-color .16s ease;
}

header.top a:hover { color: var(--brand); background: var(--brand-soft-2); text-decoration: none; }

header.top a.is-active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

header.top .nav-note {
    margin-left: auto;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font-size: 12.5px;
}

/* ===== 04 页头 ===== */
.masthead { margin: 10px 0 30px; }

.masthead-kicker {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    margin-bottom: 14px;
    border: 1px solid var(--brand-soft);
    border-radius: var(--radius-pill);
    background: var(--brand-soft-2);
    color: var(--brand);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .6px;
}

.masthead-title {
    margin: 0 0 10px;
    font-size: clamp(28px, 3.4vw, 40px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
}

.masthead-lede {
    max-width: 72ch;
    margin: 0;
    font-size: 15.5px;
    color: var(--ink-2);
}

/* ===== 05 布局与卡片 ===== */
main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 32px 28px 12px;
}

.card {
    padding: 20px 22px;
    margin-bottom: var(--gap);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}

.card:hover { border-color: #dde3ee; box-shadow: var(--shadow-md); }

.card > strong {
    display: block;
    margin: 0 0 12px;
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -.1px;
    color: var(--ink);
}

.card > p:not(.muted) { font-size: 15px; line-height: 1.85; color: var(--ink-2); }

/* 时间线帖子 */
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-head > strong { margin: 0; font-size: 16.5px; font-weight: 700; letter-spacing: -.2px; }
.post-body { color: var(--ink-2); font-size: 14.5px; line-height: 1.8; }
.post-meta { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.card.post:hover { transform: translateY(-2px); }

/* 三栏栅格（辩论页） */
.cols {
    display: grid;
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(280px, 340px);
    gap: var(--gap);
    align-items: start;
}
.cols > section, .cols > aside { min-width: 0; }

/* ===== 06 徽标与标签 ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    margin-right: 6px;
    border-radius: var(--radius-pill);
    background: var(--line-2);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
}
.badge-debate { background: #fff1f0; color: #cb2634; }
.badge-article { background: #e8f3ff; color: var(--brand); }
.badge-question { background: #fff7e8; color: #c25c00; }
.badge-answer { background: #e8ffea; color: #00a021; }

.muted { color: var(--sub); font-size: 13px; }

.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    border-radius: 3px;
    vertical-align: middle;
}
.swatch.challenge { background: var(--danger); }
.swatch.question { background: var(--warn); }
.swatch.support { background: var(--brand); }
.swatch.concede { background: var(--success); }

/* 筛选条 */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filters > strong { display: inline; margin: 0 6px 0 0; font-size: 13.5px; font-weight: 600; color: var(--sub); }
.chip {
    padding: 6px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font-size: 13.5px;
    line-height: 20px;
    color: var(--ink-2);
    transition: all .16s ease;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft-2); text-decoration: none; }
.chip.is-active { border-color: var(--brand); background: var(--brand); color: #fff; font-weight: 600; box-shadow: var(--shadow-brand); }

/* ===== 07 表格 ===== */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }

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

th {
    background: var(--line-2);
    color: var(--sub);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}
th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

td { color: var(--ink-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--brand-soft-2); }

/* ===== 08 表单与按钮 ===== */
label {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 14px 0 0;
    vertical-align: top;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
}

input, textarea, select {
    width: 100%;
    max-width: 440px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color .16s ease, box-shadow .16s ease;
}

input::placeholder, textarea::placeholder { color: var(--sub); }
input[type="number"] { max-width: 160px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
}

.card form > div { margin-bottom: 14px; }

button {
    padding: 9px 16px;
    font: inherit;
    font-size: 14px;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .16s ease;
}
button:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft-2); }
button:active { transform: translateY(1px); }

/* 卡片直属表单的提交按钮 = 主按钮（申领／找回／管理台各类保存、暂停、签发） */
.card > form > button[type="submit"] {
    padding: 10px 22px;
    color: #fff;
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    border-color: transparent;
    font-weight: 600;
    box-shadow: var(--shadow-brand);
}
.card > form > button[type="submit"]:hover {
    color: #fff;
    background: linear-gradient(180deg, #2b6cff, var(--brand));
    border-color: transparent;
}

.inline-form { display: inline; }

/* ===== 09 代码块 ===== */
code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--line-2);
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--ink-2);
}

pre {
    margin: 10px 0;
    padding: 14px 16px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--line-2);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink-2);
}
pre code { padding: 0; background: none; }

/* ===== 10 关系图（手写 SVG） ===== */
#relation-svg { display: block; width: 100%; max-width: 340px; height: auto; margin: 8px auto 14px; }
#relation-svg circle { transition: r .18s ease, fill .18s ease; }
#relation-svg g:hover circle { r: 17; fill: #d6e8ff; }
#relation-svg text { fill: var(--ink-2); pointer-events: none; }

/* ===== 11 页脚 ===== */
footer {
    margin-top: 48px;
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface));
}
.footer-note { max-width: var(--maxw); margin: 0 auto; padding: 26px 28px; }

/* ===== 12 工具类 ===== */
.hidden { display: none !important; }
.field-error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #fff1f0;
    color: #cb2634;
    font-size: 13px;
}
.field-warn { color: var(--danger); }
.token-value {
    padding: 2px 8px;
    background: var(--brand-soft);
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .4px;
    color: var(--brand-strong);
}
.config-pre { max-height: 280px; }
.empty {
    padding: 44px 20px;
    text-align: center;
    font-size: 14px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.stack > * + * { margin-top: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.is-accepted { border-color: var(--success); box-shadow: 0 0 0 3px rgba(0, 180, 42, .10); }

/* ===== 13 响应式 ===== */
@media (max-width: 1120px) {
    .cols { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    main { padding: 20px 16px 8px; }
    header.top { padding: 12px 16px; }
    header.top .brand { margin-right: 8px; }
    header.top .nav-note { display: none; }
    .masthead { margin: 4px 0 22px; }
    .card { padding: 16px; border-radius: 14px; }
    .footer-note { padding: 20px 16px; }
    input, textarea, select { max-width: none; }
}
