:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --text: #0f172a;
    --muted: #5b6b80;
    --border: #dbe4ef;
    --accent: #0ea5e9;
    --link: #0369a1;
    --accent-ink: #04121f;
    --danger: #b91c1c;
    --ok: #15803d;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #101a2c;
    --surface-2: #162238;
    --surface-3: #1d2c45;
    --text: #e6edf7;
    --muted: #93a3bb;
    --border: #243248;
    --accent: #38bdf8;
    --link: #7dd3fc;
    --accent-ink: #04121f;
    --danger: #fca5a5;
    --ok: #86efac;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.tools-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 12px 20px;
}

.tools-brand {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.tools-brand a {
    color: var(--text);
}

.tools-brand span {
    margin-left: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 18px;
}

.head-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.head-nav .selected {
    color: var(--text);
    font-weight: 600;
}

.theme-toggle {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.theme-toggle:hover {
    border-color: var(--accent);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 30px 20px 52px;
}

.section-label {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.page-head {
    margin-bottom: 24px;
}

.page-head h1 {
    margin: 0 0 6px;
    font-size: 27px;
    line-height: 1.25;
    letter-spacing: -0.03em;
}

.page-head p {
    max-width: 72ch;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.index-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.55fr);
    gap: 30px;
    align-items: end;
    margin-bottom: 30px;
    padding: 22px 0 26px;
    border-bottom: 1px solid var(--border);
}

.index-hero h1 {
    max-width: 760px;
    margin: 0 0 12px;
    font-size: clamp(32px, 4.6vw, 48px);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.index-hero p {
    max-width: 640px;
    margin: 0 0 1em;
    color: var(--muted);
    font-size: 15px;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.hero-badges span {
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}

.hero-note {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12.5px;
}

.hero-note strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text);
    font-size: 13px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    min-height: 138px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.tool-card:hover {
    border-color: var(--accent);
}

.tool-card .tag {
    margin-bottom: 8px;
    color: var(--link);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.04em;
}

.tool-card h2 {
    margin: 0 0 6px;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.tool-card p {
    flex: 1;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 12.5px;
}

.tool-card .open {
    font-size: 12px;
    font-weight: 600;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.info-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.info-card h2 {
    margin: 0 0 6px;
    font-size: 15px;
}

.info-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.tool-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
    gap: 18px;
    align-items: start;
}

.workspace {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.workspace h2 {
    margin: 0 0 12px;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.workspace h2:not(:first-child) {
    margin-top: 24px;
}

.notes {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12.5px;
}

.notes h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 14px;
}

.notes h2:not(:first-child) {
    margin-top: 20px;
}

.notes p {
    margin: 0 0 0.9em;
}

.notes ul {
    margin: 0 0 0.9em;
    padding-left: 17px;
}

.notes li {
    margin: 0 0 5px;
}

.notes code {
    color: var(--text);
}

.field {
    min-width: 0;
    margin-bottom: 14px;
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
}

.field label span {
    color: var(--muted);
    font-weight: 400;
}

textarea,
input[type="text"],
input[type="number"],
input[type="color"],
select {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

textarea {
    min-height: 190px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    line-height: 1.5;
}

input[type="color"] {
    height: 38px;
    padding: 3px;
    cursor: pointer;
}

textarea:focus,
input:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.three-col {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

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

.btn {
    padding: 7px 12px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn.secondary {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.btn:hover {
    filter: brightness(0.96);
}

.btn:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.result {
    min-width: 0;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
}

.result .label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.result .btn {
    margin-top: 8px;
}

.result output,
.result pre {
    display: block;
    margin: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.55;
}

.error {
    min-height: 1.5em;
    margin: 8px 0 0;
    color: var(--danger);
    font-size: 12px;
}

.copy-status {
    min-height: 1.5em;
    margin: 6px 0 0;
    color: var(--ok);
    font-size: 11px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.stat {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
}

.stat strong {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 19px;
    line-height: 1.3;
}

.stat span {
    color: var(--muted);
    font-size: 10.5px;
}

.preview {
    height: 150px;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: linear-gradient(135deg, #0ea5e9, #d8a7a0);
}

.code-output {
    width: 100%;
    min-height: 96px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.55;
}

.page-copy {
    max-width: 76ch;
}

.page-copy h2 {
    margin: 34px 0 8px;
    font-size: 19px;
    letter-spacing: -0.02em;
}

.page-copy h2:first-child {
    margin-top: 0;
}

.page-copy p {
    margin: 0 0 1em;
}

.page-copy ul {
    margin: 0 0 1.2em;
    padding-left: 1.35em;
}

.page-copy li {
    margin: 0.25em 0;
}

.callout {
    margin: 20px 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
}

.callout strong {
    color: var(--text);
}

.tools-footer {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 20px 34px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11.5px;
}

.tools-footer p {
    margin: 0;
}

.err-shell {
    padding: 36px 0 30px;
}

.err-shell .status-code {
    margin: 0 0 6px;
    color: var(--link);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
}

.err-shell h1 {
    margin: 0 0 12px;
    font-size: 32px;
    letter-spacing: -0.035em;
}

.err-shell p {
    max-width: 60ch;
    margin: 0 0 1em;
    color: var(--muted);
}

.error-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 20px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .index-hero {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .header-inner {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 16px;
    }

    .header-tools {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .head-nav ul {
        gap: 4px 14px;
        font-size: 14px;
    }

    .theme-toggle,
    .btn {
        font-size: 14px;
    }

    main {
        padding: 22px 16px 44px;
    }

    .index-hero h1 {
        font-size: 31px;
    }

    .tool-grid,
    .info-grid,
    .stats,
    .two-col,
    .three-col {
        grid-template-columns: 1fr;
    }

    .tool-card p,
    .info-card p,
    .notes,
    .notes h2,
    .field label,
    .result output,
    .result pre,
    .error,
    .copy-status,
    .tools-footer,
    .page-head p,
    .page-copy,
    .callout,
    .error-links {
        font-size: 14px;
    }

    .section-label,
    .tool-card .tag,
    .tool-card .open,
    .stat span,
    .hero-badges span,
    .hero-note,
    .hero-note strong,
    .tools-brand span,
    .result .label,
    .err-shell .status-code {
        font-size: 14px;
    }

    textarea,
    input[type="text"],
    input[type="number"],
    select {
        font-size: 16px;
    }

    .result output,
    .result pre,
    .code-output {
        font-size: 14px;
    }
}

.jump-main {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 100;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}

.jump-main:focus {
    top: 12px;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#main-content:focus {
    outline: none;
}
