/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ===== Theme tokens ===== */
:root {
    --bg: #ffffff;
    --bg-elevated: #f7f7f9;
    --bg-code: #f1f1f4;
    --text: #1c1c1e;
    --text-secondary: #6b6b73;
    --border: #e5e5ea;
    --accent: #5283f3;
    --accent-soft: rgba(82, 131, 243, 0.12);
    --assistant: #a258f3;
    --attention: #f5891f;
    --tool: #5b9e44;
    --shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
}

[data-theme="dark"] {
    --bg: #0f0f12;
    --bg-elevated: #1a1a1f;
    --bg-code: #1f1f26;
    --text: #ececef;
    --text-secondary: #9a9aa3;
    --border: #2a2a32;
    --accent: #759cff;
    --accent-soft: rgba(117, 156, 255, 0.18);
    --assistant: #c89bff;
    --attention: #ffba6e;
    --tool: #8fd47e;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.35);
}

/* ===== Layout ===== */
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; align-self: start;
    height: 100vh; overflow-y: auto;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
}

.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 18px; margin-bottom: 16px;
}
.sidebar .brand .icon {
    width: 36px; height: 36px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--assistant));
    display: grid; place-items: center;
    color: white; font-size: 18px;
}
.sidebar .subtitle { color: var(--text-secondary); font-size: 12px; margin-top: -10px; margin-bottom: 16px; }

.lang-switch {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}
.lang-switch a,
.lang-switch .lang-disabled {
    flex: 1;
    text-align: center;
    padding: 5px 0;
    border-radius: 7px;
    border: 1px solid var(--border);
    font-size: 13px;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--bg);
    transition: all .15s;
}
.lang-switch a:hover { border-color: var(--accent); color: var(--text); }
.lang-switch a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.lang-switch .lang-disabled {
    opacity: .45;
    cursor: not-allowed;
}

.search-box {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 16px;
}

.nav ul { list-style: none; margin: 0; padding: 0; }
.nav li a {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 2px;
    transition: background-color 0.12s, color 0.12s;
}
.nav li a:hover { background: var(--accent-soft); color: var(--text); }
.nav li a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav .nav-num {
    display: inline-block; width: 20px;
    color: var(--text-secondary); font-variant-numeric: tabular-nums;
    font-size: 12px;
}
.nav li.hidden { display: none; }

.theme-toggle {
    margin-top: 16px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--accent-soft); }

/* ===== Main content ===== */
.content {
    padding: 40px 56px 80px;
    max-width: 880px;
    margin: 0 auto;
}

h1 { font-size: 32px; margin: 0 0 8px; }
h2 {
    font-size: 24px; margin: 48px 0 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
h2:first-of-type { border-top: none; padding-top: 0; }
h3 { font-size: 18px; margin: 24px 0 8px; }
p { margin: 12px 0; }

.lead {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

code, pre {
    font: 13px/1.5 ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}
code {
    background: var(--bg-code);
    padding: 2px 6px;
    border-radius: 4px;
}
pre {
    background: var(--bg-code);
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid var(--border);
}

ul, ol { padding-left: 22px; }
li { margin: 4px 0; }

/* ===== Screenshot frames ===== */
.shot {
    margin: 20px 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
}
.shot img {
    display: block;
    width: 100%;
    height: auto;
}
.shot figcaption {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* Placeholder for missing screenshots */
.shot.pending {
    border: 2px dashed var(--border);
    background:
        repeating-linear-gradient(45deg,
            transparent 0 8px,
            var(--bg-code) 8px 16px);
}
.shot.pending .pending-box {
    display: grid; place-items: center;
    height: 220px;
    padding: 24px;
    text-align: center;
}
.shot.pending .icon { font-size: 32px; margin-bottom: 8px; }
.shot.pending .label { font-weight: 600; color: var(--text); }
.shot.pending .path {
    font: 12px/1.5 ui-monospace, Menlo, monospace;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid var(--border);
}

/* ===== Callouts ===== */
.callout {
    margin: 16px 0;
    padding: 12px 16px 12px 14px;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 8px;
    font-size: 14px;
}
.callout.warning {
    border-left-color: var(--attention);
    background: rgba(245, 137, 31, .12);
}
.callout.tip {
    border-left-color: var(--tool);
    background: rgba(91, 158, 68, .12);
}
.callout strong { display: block; margin-bottom: 4px; }

/* ===== Steps ===== */
.steps {
    counter-reset: step;
    list-style: none;
    padding-left: 0;
}
.steps > li {
    counter-increment: step;
    position: relative;
    padding-left: 38px;
    margin: 14px 0;
}
.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0; top: 0;
    width: 26px; height: 26px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 13px; font-weight: 700;
}

/* ===== Two-column grid for short lists ===== */
.kv {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 8px 16px;
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
}
.kv dt { font-weight: 600; color: var(--text-secondary); }
.kv dd { margin: 0; }

/* ===== Footer ===== */
.footer {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .content { padding: 24px 20px 64px; }
}

/* Reference table (e.g. Prompt 庫 skill catalog) */
.reftable {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.92rem;
}
.reftable th,
.reftable td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}
.reftable thead th {
    background: var(--bg-elevated);
    font-weight: 600;
}
.reftable td:first-child {
    white-space: nowrap;
    font-weight: 500;
}

/* Inline UI-control reference (e.g. a toolbar button) */
.kbd {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elevated);
    font-size: 0.85em;
    white-space: nowrap;
}
