/* =========================================================
   CoolText.CC — base layer
   tokens → reset → shell → header → hero → sections → footer
   ========================================================= */

:root {
    color-scheme: light;

    /* surfaces */
    --bg: #f6f7fb;
    --solid: #ffffff;
    --panel: #ffffff;
    --panel-2: #f3f5f9;
    --panel-3: #eaedf4;
    --line: #e4e7ef;
    --line-2: #ccd2e0;

    /* text */
    --ink: #0f1222;
    --ink-2: #4d5567;
    --ink-3: #737c90;

    /* brand */
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-ink: #3730a3;
    --brand-soft: #eef0ff;
    --on-brand: #ffffff;
    --accent: #0e7490;
    --hot: #db2777;
    --ok: #059669;
    --warn: #b45309;

    /* shape */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-pill: 999px;

    /* depth */
    --shadow-sm: 0 1px 2px rgba(15, 18, 34, 0.06);
    --shadow: 0 16px 40px -24px rgba(15, 18, 34, 0.32);
    --shadow-lg: 0 32px 64px -32px rgba(15, 18, 34, 0.38);
    --ring: 0 0 0 4px rgba(79, 70, 229, 0.14);

    /* type */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    /* layout */
    --shell: 1180px;
    --header-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);

    /* legacy aliases kept for component compatibility */
    --bg-2: var(--panel-2);
    --card-bg: var(--panel);
    --card-border: var(--line);
    --card-radius: var(--radius-lg);
    --card-pad: 20px;
    --chip-bg: var(--panel);
    --chip-border: var(--line);
    --chip-radius: var(--radius-sm);
    --button-bg: var(--panel-2);
    --button-fg: var(--ink);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #090b11;
    --solid: #0f121b;
    --panel: #12151f;
    --panel-2: #171b26;
    --panel-3: #1e232f;
    --line: #222834;
    --line-2: #333b4b;
    --ink: #eef1f8;
    --ink-2: #aeb6c8;
    --ink-3: #838ca2;
    --brand: #8189ff;
    --brand-2: #a78bfa;
    --brand-ink: #c7cbff;
    --brand-soft: rgba(129, 137, 255, 0.16);
    --on-brand: #0b0d14;
    --accent: #22d3ee;
    --hot: #f472b6;
    --ok: #34d399;
    --warn: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.55);
    --shadow: 0 20px 50px -28px rgba(0, 0, 0, 0.9);
    --shadow-lg: 0 36px 72px -32px rgba(0, 0, 0, 0.95);
    --ring: 0 0 0 4px rgba(129, 137, 255, 0.22);
}

/* ===== reset ===== */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { margin-inline-start: 20px; }

h1, h2, h3, h4 {
    line-height: 1.2;
    letter-spacing: -0.025em;
    font-weight: 700;
}

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

[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--brand) 26%, transparent); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skiplink {
    position: fixed;
    top: 10px;
    inset-inline-start: 10px;
    z-index: 300;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--bg);
    font-size: 0.86rem;
    font-weight: 700;
    transform: translateY(-200%);
    transition: transform 0.18s ease;
}

.skiplink:focus-visible { transform: none; }

/* ===== shell ===== */
.shell {
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: 20px;
}

.main { display: block; }
.main .shell { max-width: none; padding-inline: 0; }

/* ===== header ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--solid) 88%, transparent);
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: none;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand em { font-style: normal; color: var(--ink-3); font-weight: 600; }

.topnav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-inline-start: 12px;
    min-width: 0;
}

.topnav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    transition: color 0.16s, background 0.16s;
}

.topnav-link i { font-style: normal; font-size: 0.95rem; line-height: 1; }
.topnav-link:hover { color: var(--ink); background: var(--panel-2); }

.topnav-link.is-active { color: var(--ink); background: var(--panel-2); }

.topnav-link.is-active::after {
    content: "";
    position: absolute;
    inset-inline: 11px;
    bottom: 2px;
    height: 2px;
    border-radius: 2px;
    background: var(--brand);
}

.header-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
    flex: none;
}

.ctl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--solid);
    color: var(--ink-2);
    font-size: 0.8rem;
    font-weight: 600;
    transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.ctl:hover { color: var(--ink); border-color: var(--line-2); background: var(--panel-2); }
.ctl svg { width: 17px; height: 17px; }
.langbtn span { min-width: 2ch; text-align: center; }

.ctl .moon { display: none; }
[data-theme="light"] .ctl .sun { display: none; }
[data-theme="light"] .ctl .moon { display: block; }

.menubtn { display: none; }

.iconbtn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink-2);
    font-size: 1.15rem;
    line-height: 1;
    transition: 0.16s;
}

.iconbtn:hover { color: var(--ink); border-color: var(--line-2); background: var(--panel-2); }

/* ===== hero ===== */
.hero { padding: 52px 0 20px; }

.home-hero { padding: 46px 0 16px; }

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
    gap: 46px;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--ink-2);
    font-size: 0.76rem;
    font-weight: 600;
    margin-bottom: 18px;
}

.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent);
}

.hero h1 {
    font-size: clamp(2rem, 4.4vw, 3.15rem);
    font-weight: 800;
    letter-spacing: -0.042em;
    line-height: 1.08;
    margin-bottom: 14px;
    max-width: 20ch;
    text-wrap: balance;
}

.hero p {
    font-size: 1.02rem;
    color: var(--ink-2);
    max-width: 56ch;
    margin-bottom: 22px;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 20px;
    margin-top: 18px;
    font-size: 0.8rem;
    color: var(--ink-3);
}

.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* static preview card in the hero */
.hero-preview {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.hero-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.hero-preview-dots { display: inline-flex; gap: 5px; }
.hero-preview-dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-2);
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border-top: 1px solid var(--line);
}

.mini-row:first-of-type { border-top: 0; }
.mini-label { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); flex: none; }
.mini-sample {
    font-size: 1.1rem;
    line-height: 1.4;
    text-align: end;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero-preview-foot {
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--ink-3);
    font-size: 0.74rem;
    text-align: center;
}

/* ===== page head ===== */
.pagehead { padding: 26px 0 14px; }

.crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.76rem;
    color: var(--ink-3);
}

.crumbs a:hover { color: var(--ink); }
.crumbs span { color: var(--line-2); }

.pagehead h1 {
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    margin-bottom: 8px;
}

.pagehead p {
    font-size: 0.94rem;
    color: var(--ink-2);
    max-width: 72ch;
}

/* ===== sections ===== */
.section { padding: 26px 0; }

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px 20px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.section-head h2 { font-size: 1.2rem; letter-spacing: -0.03em; }
.section-head p { font-size: 0.85rem; color: var(--ink-3); }

.eyebrow {
    display: block;
    margin-bottom: 0;
    color: var(--ink-3);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* ===== footer ===== */
.footer {
    margin-top: 40px;
    padding: 42px 0 30px;
    border-top: 1px solid var(--line);
    background: var(--solid);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: 30px;
}

.footer-col { display: flex; flex-direction: column; gap: 8px; }

.footer-col h4 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 4px;
}

.footer-col a {
    font-size: 0.87rem;
    color: var(--ink-2);
    transition: color 0.16s;
    width: fit-content;
}

.footer-col a:hover { color: var(--brand); }

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.footer-brand img { width: 26px; height: 26px; border-radius: 8px; }
.footer-col p { font-size: 0.86rem; color: var(--ink-3); max-width: 34ch; }

.footer-disclosure {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    max-width: 960px;
    font-size: 0.76rem;
    line-height: 1.7;
    color: var(--ink-3);
}

.footer-disclosure a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.footer-disclosure a:hover { color: var(--brand); }

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 0.8rem;
    color: var(--ink-3);
}

.footer-note { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ===== legal ===== */
.legal {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px 34px;
}

.legal h2 { font-size: 1.16rem; margin: 26px 0 10px; }
.legal h2:first-child { margin-top: 0; }
.legal h3 { font-size: 1rem; margin: 20px 0 8px; }
.legal p { color: var(--ink-2); margin-bottom: 14px; font-size: 0.93rem; }
.legal ul { color: var(--ink-2); margin: 0 0 16px 22px; font-size: 0.93rem; }
.legal li { margin-bottom: 7px; }
.legal a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.legal strong { color: var(--ink); }

.legal code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--panel-2);
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* ===== 404 ===== */
.notfound { text-align: center; padding: 64px 0 10px; }
.notfound .shell { max-width: 760px; }

.notfound-code {
    font-size: clamp(3rem, 12vw, 5.5rem);
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 1;
    background: linear-gradient(140deg, var(--brand), var(--accent) 60%, var(--hot));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.notfound h1 { font-size: 1.4rem; margin-bottom: 10px; }
.notfound p { margin: 0 auto 24px; color: var(--ink-2); }
.notfound .composer { text-align: start; margin-inline: auto; }

/* ===== responsive ===== */
@media (max-width: 1080px) {
    .footer-grid { grid-template-columns: 1.4fr repeat(3, 1fr); gap: 24px; }
    .hero-grid { gap: 32px; }
}

@media (max-width: 960px) {
    .topbar-inner { gap: 8px; }
    .menubtn { display: inline-flex; }

    .topnav {
        position: absolute;
        inset-inline: 0;
        top: 100%;
        z-index: 5;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        margin: 0;
        padding: 10px 12px calc(14px + var(--safe-b));
        max-height: calc(100dvh - var(--header-h));
        overflow-y: auto;
        background: var(--solid);
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow);
    }

    .topnav.is-open { display: flex; }

    .topnav-link {
        gap: 12px;
        padding: 12px 12px;
        font-size: 0.95rem;
        white-space: normal;
    }

    .topnav-link.is-active::after { display: none; }
    .topnav-link i { font-size: 1.05rem; }

    .hero { padding-top: 34px; }
    .hero-grid { grid-template-columns: 1fr; gap: 26px; }
    .hero h1 { max-width: none; }
    .hero-preview { display: none; }

    .footer { padding-bottom: calc(30px + var(--safe-b)); }
    body.has-cookiebar .footer { padding-bottom: calc(210px + var(--safe-b)); }
}

@media (max-width: 640px) {
    .shell { padding-inline: 16px; }
    .section { padding: 20px 0; }
    .hero { padding: 22px 0 10px; }
    .hero h1 { font-size: clamp(1.75rem, 8vw, 2.3rem); }
    .hero p { font-size: 0.95rem; }
    .legal { padding: 22px 18px; }

    .footer { padding: 30px 0 calc(24px + var(--safe-b)); }
    .footer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 14px; }
    .footer-col:first-child { grid-column: 1 / -1; }
    .footer-col { gap: 5px; }
    .footer-col h4 { margin-bottom: 2px; font-size: 0.62rem; letter-spacing: 0.08em; }
    .footer-col a { font-size: 0.79rem; line-height: 1.5; }
    .footer-disclosure { margin-top: 16px; padding-top: 14px; font-size: 0.72rem; }
    .footer-bottom { margin-top: 16px; padding-top: 14px; gap: 8px; font-size: 0.76rem; }
}

@media (max-width: 420px) {
    .brand em { display: none; }
    .header-controls { gap: 6px; }
    .ctl { height: 34px; padding: 0 9px; }
    .iconbtn { width: 34px; height: 34px; }
}

/* RTL: flip directional glyphs */
[dir="rtl"] .morelink svg,
[dir="rtl"] .toolcard-arrow { transform: scaleX(-1); }
