:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef3ff;
    --text: #172033;
    --muted: #5f6b7c;
    --border: #dfe5ef;
    --primary: #315efb;
    --primary-dark: #2044c9;
    --success: #16835f;
    --warning: #a26400;
    --danger: #b42318;
    --shadow: 0 18px 55px rgba(35, 49, 85, .10);
    --radius: 18px;
    --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
pre, code, textarea { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
img { max-width: 100%; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.content-narrow { width: min(880px, calc(100% - 32px)); margin-left: auto; margin-right: auto; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 10px 14px; background: var(--surface); }
.skip-link:focus { left: 8px; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(223,229,239,.9);
}
.nav-wrap { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(145deg, var(--primary), #7948ff); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand small { color: var(--muted); font-size: .75rem; margin-top: 3px; }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { color: #465267; padding: 9px 11px; border-radius: 9px; font-size: .93rem; }
.site-nav a:hover, .site-nav a.active { color: var(--primary); background: var(--surface-2); text-decoration: none; }
.nav-toggle { display: none; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 12px; }

.hero { padding: 84px 0 70px; background: radial-gradient(circle at 85% 5%, #dfe7ff 0, transparent 35%), linear-gradient(180deg, #fff, var(--bg)); }
.hero-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 56px; align-items: center; }
.eyebrow { display: inline-block; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; margin-bottom: 10px; }
h1, h2, h3 { line-height: 1.18; letter-spacing: -.025em; }
h1 { font-size: clamp(2.35rem, 6vw, 4.45rem); margin: 0 0 22px; }
h2 { font-size: clamp(1.75rem, 4vw, 2.65rem); margin: 0 0 14px; }
h3 { font-size: 1.12rem; }
.hero-copy { max-width: 700px; font-size: 1.17rem; color: var(--muted); margin: 0 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border-radius: 11px; border: 1px solid transparent; font-weight: 750; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.primary { color: white; background: var(--primary); box-shadow: 0 10px 26px rgba(49,94,251,.25); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--text); background: var(--surface); border-color: var(--border); }
.button.small { min-height: 38px; padding: 7px 12px; font-size: .9rem; }
.button.danger { color: var(--danger); background: #fff5f3; border-color: #f4c7c1; }
.trust-row { display: flex; flex-wrap: wrap; gap: 17px; color: var(--muted); font-size: .9rem; }
.privacy-panel { background: var(--surface); padding: 28px; border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); }
.privacy-step { display: flex; align-items: center; gap: 13px; font-weight: 700; }
.privacy-step b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: white; background: var(--primary); }
.privacy-line { height: 28px; border-left: 2px dashed #b9c6e8; margin-left: 16px; }
.privacy-panel p { margin: 22px 0 0; color: var(--muted); font-size: .9rem; }

.section { padding: 74px 0; }
.section.alt { background: #edf1f8; border-block: 1px solid var(--border); }
.section-heading { max-width: 760px; margin-bottom: 36px; }
.section-heading.compact { margin-bottom: 24px; }
.section-heading p { color: var(--muted); font-size: 1.05rem; }
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.category-card { display: block; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: 0 8px 26px rgba(35,49,85,.04); }
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; border-color: #bdc9e2; }
.category-icon, .tool-icon { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 8px; border-radius: 12px; background: var(--surface-2); color: var(--primary); font-weight: 850; letter-spacing: -.04em; }
.category-icon.large, .tool-icon.large { min-width: 58px; height: 58px; border-radius: 17px; font-size: 1.05rem; }
.category-card h3 { margin: 18px 0 8px; }
.category-card p { color: var(--muted); min-height: 78px; }
.category-card > span:last-child { font-weight: 750; color: var(--primary); }
.tool-group + .tool-group { margin-top: 45px; }
.tool-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.tool-group-heading h2, .tool-group-heading h3 { margin: 0; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; overflow: hidden; }
.tool-card:hover { border-color: #b8c4df; box-shadow: 0 12px 32px rgba(35,49,85,.07); }
.tool-card-link { min-height: 104px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; padding: 17px; color: var(--text); }
.tool-card-link:hover { text-decoration: none; }
.tool-card-link strong, .tool-card-link small { display: block; }
.tool-card-link small { color: var(--muted); margin-top: 4px; line-height: 1.4; }
.arrow { color: var(--primary); font-size: 1.3rem; }
.prose-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; }
.prose-columns p, .prose p, .prose li { color: var(--muted); }
.prose h2 { font-size: 1.55rem; margin-top: 38px; }
.prose h2:first-child { margin-top: 0; }
.prose code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

.page-hero, .tool-hero { padding: 58px 0 42px; background: linear-gradient(180deg, #fff, #f5f7fb); border-bottom: 1px solid var(--border); }
.page-hero h1, .tool-hero h1 { font-size: clamp(2rem, 5vw, 3.35rem); }
.page-hero p, .tool-lead { color: var(--muted); font-size: 1.1rem; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: .88rem; margin-bottom: 24px; }
.breadcrumbs span { color: #8c97a8; }
.tool-title-row { display: flex; gap: 18px; align-items: center; }
.tool-title-row h1 { margin: 0; }
.tool-title-row .eyebrow { margin-bottom: 3px; }
.tool-lead { max-width: 780px; }
.privacy-badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.privacy-badges span { padding: 6px 10px; border-radius: 999px; background: #eaf8f3; color: var(--success); font-size: .82rem; font-weight: 750; }
.tool-workspace-section { padding: 34px 0 20px; }
.tool-workspace { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; }
.loading-box { padding: 28px; text-align: center; color: var(--muted); }
.workspace-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.workspace-head h2 { font-size: 1.25rem; margin: 0; }
.workspace-head .local-label { color: var(--success); font-size: .82rem; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label, .field-label { font-size: .88rem; font-weight: 760; color: #39445a; }
textarea, input[type="text"], input[type="number"], input[type="file"], select {
    width: 100%; border: 1px solid #cfd7e5; border-radius: 11px; background: #fff; color: var(--text); padding: 11px 12px; outline: none;
}
textarea { min-height: 210px; resize: vertical; line-height: 1.52; font-size: .91rem; }
textarea.short { min-height: 125px; }
textarea:focus, input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(49,94,251,.12); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.action-button { min-height: 41px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); padding: 8px 13px; font-weight: 740; }
.action-button:hover { border-color: #aebbd3; background: #f8faff; }
.action-button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.action-button.primary:hover { background: var(--primary-dark); }
.action-button.success { background: var(--success); border-color: var(--success); color: white; }
.action-button:disabled { opacity: .55; cursor: not-allowed; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 12px 0; }
.checkbox-row label { display: inline-flex; align-items: center; gap: 7px; color: #465267; font-size: .9rem; }
.notice { margin-top: 14px; padding: 11px 13px; border-radius: 10px; background: #eef4ff; color: #294481; font-size: .9rem; }
.notice.success { background: #eaf8f3; color: #126c4e; }
.notice.warning { background: #fff7e8; color: var(--warning); }
.notice.error { background: #fff1ef; color: var(--danger); }
.result-panel { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 20px; }
.result-panel h3 { margin-top: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.stat-card { padding: 15px; background: #f7f9fd; border: 1px solid var(--border); border-radius: 12px; }
.stat-card strong { display: block; font-size: 1.35rem; }
.stat-card span { color: var(--muted); font-size: .8rem; }
.file-results { display: grid; gap: 10px; margin-top: 16px; }
.file-result { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 13px; background: #f9fbff; }
.file-result strong, .file-result small { display: block; }
.file-result small { color: var(--muted); }
.candidate { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-top: 11px; }
.candidate.best { border-color: #72c4a7; background: #f1fbf7; }
.candidate-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.candidate pre { margin: 11px 0 0; white-space: pre-wrap; word-break: break-word; background: white; border: 1px solid var(--border); padding: 12px; border-radius: 9px; max-height: 260px; overflow: auto; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: #f3f6fb; }

.example-box { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.example-box span { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.example-box pre { white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; background: #f6f8fc; border-radius: 10px; padding: 13px; }
.example-arrow { font-size: 1.5rem; color: var(--primary); }
.faq-list details { border: 1px solid var(--border); border-radius: 11px; background: var(--surface); margin: 10px 0; padding: 13px 15px; }
.faq-list summary { cursor: pointer; font-weight: 750; }
.faq-list p { margin-bottom: 0; }

.site-footer { padding: 48px 0 18px; background: #111827; color: #d9e1ef; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 30px; }
.footer-grid strong { color: white; display: block; margin-bottom: 10px; }
.footer-grid a { display: block; color: #bdc8db; margin: 5px 0; }
.footer-grid p { margin: 5px 0; }
.footer-grid .muted { color: #93a0b4; font-size: .88rem; }
.footer-bottom { margin-top: 34px; padding-top: 17px; border-top: 1px solid #2b3547; color: #8f9bad; font-size: .82rem; }

@media (max-width: 900px) {
    .hero-grid, .category-grid, .prose-columns { grid-template-columns: 1fr; }
    .hero { padding-top: 54px; }
    .privacy-panel { max-width: 650px; }
    .site-nav { display: none; position: absolute; top: 64px; left: 16px; right: 16px; flex-direction: column; align-items: stretch; padding: 12px; background: white; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
    .site-nav.open { display: flex; }
    .nav-toggle { display: block; }
    .category-card p { min-height: 0; }
}

@media (max-width: 680px) {
    .container, .content-narrow { width: min(100% - 22px, 1180px); }
    .tool-grid, .form-grid, .footer-grid { grid-template-columns: 1fr; }
    .form-field.full { grid-column: auto; }
    .tool-card-link { min-height: 90px; }
    .tool-workspace { padding: 16px; border-radius: 15px; }
    .workspace-head { align-items: flex-start; flex-direction: column; }
    .example-box { grid-template-columns: 1fr; }
    .example-arrow { transform: rotate(90deg); justify-self: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .file-result { grid-template-columns: 1fr; }
    .tool-title-row { align-items: flex-start; }
    h1 { font-size: 2.25rem; }
}

/* Expanded subtitle, printable and calculator modules */
.canvas-stage {
    margin-top: 18px;
    min-height: 260px;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #e5e7eb;
}
.canvas-stage canvas { display: block; max-width: 100%; max-height: 720px; background: transparent; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); }
.prompter-screen {
    position: relative;
    height: min(62vh, 620px);
    margin-top: 18px;
    overflow: auto;
    border-radius: 16px;
    background: #05070b;
    color: #fff;
    scroll-behavior: auto;
}
.prompter-screen:fullscreen { height: 100vh; border-radius: 0; }
.prompter-content { padding: 42vh 7vw; white-space: pre-wrap; line-height: 1.55; font-weight: 650; }
.prompter-focus { display: none; position: sticky; top: 42%; z-index: 2; height: 18%; pointer-events: none; border-block: 2px solid rgba(65, 255, 153, .75); background: rgba(65, 255, 153, .06); }
.prompter-screen.show-focus .prompter-focus { display: block; margin-bottom: -18%; }
.printable-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 22px; }
.printable-toolbar .actions { margin-top: 0; }
.print-preview {
    margin-top: 14px;
    min-height: 420px;
    max-height: 820px;
    overflow: auto;
    display: grid;
    place-items: start center;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #dfe4ec;
}
.print-preview svg { display: block; width: min(100%, 760px); height: auto; background: white; box-shadow: 0 12px 34px rgba(15, 23, 42, .18); }
.result-callout { padding: 18px; border-radius: 13px; background: #eef4ff; border: 1px solid #cdd9ff; }
.result-callout h3 { margin: 0; font-size: 1.3rem; }
.result-callout p { margin: 7px 0 0; color: var(--muted); }
.calculation-details { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: #fafbfe; }
.calculation-details h3 { margin: 0 0 8px; }
.calculation-details ul { margin: 0; padding-left: 20px; color: var(--muted); }
.table-wrap tbody tr:nth-child(even) { background: #fbfcfe; }
input[type="range"], input[type="color"] { width: 100%; }
input[type="color"] { min-height: 44px; border: 1px solid #cfd7e5; border-radius: 11px; background: #fff; padding: 5px; }
output { color: var(--muted); font-size: .84rem; }
.site-nav details { position: relative; }
.site-nav summary { list-style: none; cursor: pointer; color: #465267; padding: 9px 11px; border-radius: 9px; font-size: .93rem; }
.site-nav summary::-webkit-details-marker { display: none; }
.site-nav summary::after { content: " ▾"; color: var(--primary); }
.site-nav details[open] summary, .site-nav summary:hover { color: var(--primary); background: var(--surface-2); }
.nav-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; padding: 10px; border: 1px solid var(--border); border-radius: 13px; background: white; box-shadow: var(--shadow); }
.nav-dropdown a { display: block; }

@media (max-width: 900px) {
    .site-nav details { width: 100%; }
    .site-nav summary { width: 100%; }
    .nav-dropdown { position: static; width: 100%; margin-top: 5px; box-shadow: none; background: #f8faff; }
}
@media (max-width: 680px) {
    .printable-toolbar { align-items: flex-start; flex-direction: column; }
    .print-preview { min-height: 280px; padding: 10px; }
    .canvas-stage { padding: 8px; }
    .prompter-content { padding-inline: 24px; }
}

/* Language switcher */
.language-menu > summary { min-width: 54px; text-align: center; font-weight: 700; }
.language-dropdown { width: 170px; }
.language-dropdown a[lang] { white-space: nowrap; }
.language-note { max-width: 260px; font-size: .78rem; line-height: 1.45; }
body[data-language="zh-CN"], body[data-language="ja"] { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Noto Sans CJK JP", "Microsoft YaHei", "Yu Gothic", sans-serif; }
.preview-panel { margin-top: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #fff; overflow: auto; }
