:root {
    --bg: #f5fbff;
    --bg-strong: #eafbff;
    --surface: #ffffff;
    --surface-muted: #f2f7fb;
    --surface-soft: #eaf2f8;
    --text: #0b1b3f;
    --muted: #5d708b;
    --line: #c6d7e7;
    --line-strong: #91a9c2;
    --primary: #113d86;
    --primary-2: #0d63c7;
    --accent: #ff7448;
    --green: #139b77;
    --purple: #7b55d9;
    --danger: #c7474b;
    --focus: rgba(13, 99, 199, 0.24);
    --shadow: 0 22px 70px rgba(12, 35, 78, 0.12);
    --radius: 8px;
    --topbar-top: 12px;
    --topbar-reserved: 92px;
    color-scheme: light;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #07111f;
    --bg-strong: #0b2133;
    --surface: #0f1d2f;
    --surface-muted: #13283e;
    --surface-soft: #102d43;
    --text: #edf7ff;
    --muted: #9eb2c7;
    --line: #2d4862;
    --line-strong: #456780;
    --primary: #90c9ff;
    --primary-2: #61afff;
    --accent: #ff9a6c;
    --green: #45d3a8;
    --purple: #b293ff;
    --danger: #ff797d;
    --focus: rgba(97, 175, 255, 0.28);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    overflow-x: hidden;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% -10%, rgba(255, 116, 72, 0.16), transparent 28rem),
        radial-gradient(circle at 82% -16%, rgba(13, 99, 199, 0.18), transparent 30rem),
        linear-gradient(180deg, var(--bg-strong) 0, var(--bg) 30rem);
    color: var(--text);
    text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

svg {
    display: block;
    width: 1.2rem;
    height: 1.2rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

::selection {
    background: color-mix(in srgb, var(--primary-2) 22%, transparent);
    color: var(--text);
}

main:focus {
    outline: 0;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2400;
    padding: 0.72rem 0.92rem;
    border-radius: 10px;
    background: var(--text);
    color: var(--surface);
    font-weight: 900;
    text-decoration: none;
    box-shadow: var(--shadow);
    transform: translateY(-140%);
    transition: transform 0.16s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.noscript-banner {
    margin: 0;
    padding: 0.85rem 1rem;
    background: var(--text);
    color: var(--surface);
    text-align: center;
    font-weight: 800;
}

.site-shell {
    min-height: 100vh;
    padding-top: var(--topbar-reserved);
}

/* TOPBAR */

.topbar {
    position: fixed;
    top: var(--topbar-top);
    left: 50%;
    z-index: 1000;
    margin: 0;
    min-height: 64px;
    width: min(1440px, calc(100% - 32px));
    padding: 8px 14px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
    align-items: center;
    gap: 14px;
    isolation: isolate;
    border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--surface-muted) 68%, transparent));
    backdrop-filter: blur(26px) saturate(1.18);
    -webkit-backdrop-filter: blur(26px) saturate(1.18);
    border-radius: 22px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.72),
        0 16px 42px rgba(12, 35, 78, 0.13);
    transform: translateX(-50%);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    min-width: max-content;
    justify-self: start;
}

.brand-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    box-shadow: 0 12px 28px rgba(11, 114, 255, 0.25);
    overflow: hidden;
    background: color-mix(in srgb, var(--primary-2) 8%, var(--surface));
}

.brand-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand strong {
    display: block;
    font-size: 0.94rem;
    letter-spacing: -0.03em;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    margin-top: 2px;
}

.desktop-nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-self: center;
    gap: 4px;
    padding: 5px;
    border-radius: 999px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 58%, var(--surface-muted)), color-mix(in srgb, var(--surface-muted) 78%, transparent));
    border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
    overflow: visible;
}

.desktop-nav > button,
.nav-trigger {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 13px;
    border-radius: 999px;
    font-weight: 780;
    font-size: 0.88rem;
    white-space: nowrap;
    transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.desktop-nav > button:hover,
.desktop-nav > button:focus-visible,
.nav-trigger:hover,
.nav-trigger:focus-visible,
.nav-menu-item.open .nav-trigger {
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.nav-menu-item {
    position: relative;
}

.nav-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
}

.nav-trigger svg {
    width: 0.9rem;
    height: 0.9rem;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav-menu-item.open .nav-trigger svg {
    transform: rotate(180deg);
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 120;
    display: grid;
    gap: 0.3rem;
    width: min(360px, 92vw);
    padding: 0.52rem;
    border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
    border-radius: 20px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--surface) 98%, transparent), color-mix(in srgb, var(--surface-muted) 78%, var(--surface))),
        var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 26px 76px rgba(12, 35, 78, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.982);
    transform-origin: top left;
    transition:
        opacity 0.16s ease,
        transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: opacity, transform;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.nav-menu-item.open .nav-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.nav-dropdown button,
.nav-dropdown a {
    position: relative;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 12px;
    align-items: center;
    gap: 0.58rem;
    min-height: 52px;
    padding: 0.5rem 0.56rem;
    border: 1px solid transparent;
    border-radius: 13px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 86%, transparent), color-mix(in srgb, var(--surface-muted) 46%, transparent));
    color: var(--text);
    text-decoration: none;
    text-align: left;
    font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.nav-dropdown button::after,
.nav-dropdown a::after {
    content: "";
    width: 0.46rem;
    height: 0.46rem;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    color: color-mix(in srgb, var(--primary) 72%, var(--muted));
    opacity: 0.46;
    transform: rotate(45deg);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.nav-dropdown button:hover,
.nav-dropdown button:focus-visible,
.nav-dropdown a:hover,
.nav-dropdown a:focus-visible {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-2) 11%, var(--surface)), color-mix(in srgb, var(--surface) 96%, transparent));
    border-color: color-mix(in srgb, var(--primary-2) 22%, var(--line));
    transform: translateY(-1px) translateX(1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 10px 26px rgba(12, 35, 78, 0.085);
}

.nav-dropdown button:hover::after,
.nav-dropdown button:focus-visible::after,
.nav-dropdown a:hover::after,
.nav-dropdown a:focus-visible::after {
    opacity: 1;
    transform: translateX(2px) rotate(45deg);
}

.nav-tool-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.9), transparent 32px),
        color-mix(in srgb, var(--primary-2) 13%, var(--surface));
    color: var(--primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.74),
        0 8px 16px rgba(12, 35, 78, 0.07);
}

.nav-tool-icon svg {
    width: 0.98rem;
    height: 0.98rem;
    stroke-width: 2.1;
}

.nav-dropdown strong,
.nav-dropdown small {
    display: block;
}

.nav-dropdown strong {
    font-size: 0.78rem;
    font-weight: 660;
    line-height: 1.18;
}

.nav-dropdown small {
    margin-top: 0.12rem;
    color: var(--muted);
    font-size: 0.67rem;
    font-weight: 500;
    line-height: 1.35;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, #fff), var(--surface-muted));
    color: var(--primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75),
        0 10px 24px rgba(12, 35, 78, 0.10);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 14px 30px rgba(12, 35, 78, 0.16);
}

.theme-icon {
    width: 20px;
    height: 20px;
    display: block;
    border-radius: 999px;
    background:
        radial-gradient(circle at 68% 32%, var(--surface) 0 32%, transparent 33%),
        linear-gradient(135deg, #0b1b3f, #2563eb);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-2) 10%, transparent);
}

:root[data-theme="dark"] .theme-icon {
    background:
        radial-gradient(circle at 50% 50%, #f8fafc 0 22%, transparent 23%),
        radial-gradient(circle at 50% 50%, transparent 0 44%, #f8fafc 45% 48%, transparent 49%),
        linear-gradient(135deg, #facc15, #fb923c);
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.13);
}

.language-menu {
    position: relative;
}

.language-btn {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 0.42rem;
    min-width: 146px;
    padding: 0 0.62rem 0 0.38rem;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, var(--surface-muted)), var(--surface));
    color: var(--text);
    border-radius: 999px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.78),
        0 10px 24px rgba(15, 23, 42, 0.07);
    font-size: 0.84rem;
    font-weight: 560;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.language-btn:hover,
.language-btn:focus-visible {
    border-color: var(--primary-2);
    box-shadow: 0 12px 28px rgba(12, 35, 78, 0.12);
    transform: translateY(-1px);
}

.language-globe {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-2) 10%, var(--surface));
    color: var(--primary);
}

.language-globe svg,
.language-chevron {
    width: 1rem;
    height: 1rem;
}

.language-chevron {
    flex: 0 0 1rem;
    color: var(--muted);
}

#languageLabel {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flag {
    display: inline-block;
    width: 24px;
    height: 16px;
    flex: 0 0 24px;
    overflow: hidden;
    border-radius: 4px;
    background-color: var(--surface-muted);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    box-shadow:
        inset 0 0 0 1px rgba(8, 27, 63, 0.12),
        0 4px 10px rgba(8, 27, 63, 0.08);
}

.flag-de { background-image: url("flags/de.svg"); }
.flag-el { background-image: url("flags/el.svg"); }
.flag-en { background-image: url("flags/en.svg"); }
.flag-ar { background-image: url("flags/ar.svg"); }
.flag-es { background-image: url("flags/es.svg"); }
.flag-fil { background-image: url("flags/fil.svg"); }
.flag-fr { background-image: url("flags/fr.svg"); }
.flag-hi { background-image: url("flags/hi.svg"); }
.flag-hu { background-image: url("flags/hu.svg"); }
.flag-it { background-image: url("flags/it.svg"); }
.flag-pl { background-image: url("flags/pl.svg"); }
.flag-pt { background-image: url("flags/pt.svg"); }
.flag-sl { background-image: url("flags/sl.svg"); }
.flag-tr { background-image: url("flags/tr.svg"); }
.flag-uk { background-image: url("flags/uk.svg"); }

.language-list {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 238px;
    max-height: min(70vh, 560px);
    overflow: auto;
    padding: 8px;
    display: grid;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.language-menu.open .language-list {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.language-list button {
    display: flex;
    align-items: center;
    gap: 0.62rem;
    min-height: 38px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 9px 10px;
    border-radius: 11px;
    font-size: 0.86rem;
    font-weight: 540;
}

.language-list button:hover {
    background: color-mix(in srgb, var(--primary-2) 10%, var(--surface));
}

.language-list button[aria-selected="true"] {
    background: color-mix(in srgb, var(--primary-2) 12%, var(--surface));
    color: var(--primary);
}

/* PAGE */

.studio-hero {
    max-width: 1780px;
    margin: 0 auto;
    padding: clamp(0.55rem, 1.25vw, 1rem) clamp(1rem, 3vw, 3.5rem) 0.72rem;
}

.hero-copy {
    max-width: 1120px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 0.35rem;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero-copy h1 {
    max-width: 1120px;
    margin: 0;
    color: var(--text);
    font-size: clamp(1.85rem, 2.8vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.hero-copy p:last-child {
    max-width: 860px;
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: clamp(0.98rem, 1.25vw, 1.12rem);
    line-height: 1.5;
}

.workspace {
    display: grid;
    gap: 0.65rem;
    max-width: 1780px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 3.5rem) 1.5rem;
}

.editor-panel,
.save-panel,
.api-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.editor-panel {
    position: relative;
    container-type: inline-size;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.editor-panel:focus-within {
    border-color: color-mix(in srgb, var(--primary-2) 52%, var(--line));
    box-shadow:
        0 0 0 4px var(--focus),
        var(--shadow);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    min-height: 30px;
    padding: 0 0.68rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--green) 15%, transparent);
    color: var(--green);
    font-size: 0.82rem;
    font-weight: 560;
}

.status-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent);
}

.status-pill.busy {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}

.live-stats {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.34rem;
    flex-wrap: wrap;
    color: var(--muted);
    font-weight: 560;
}

.live-stats span {
    color: color-mix(in srgb, var(--text) 72%, var(--muted));
    font-size: 0.82rem;
    font-weight: 560;
    white-space: nowrap;
    padding: 0.2rem 0.44rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    border: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
}

.live-stats span:not(:last-child)::after {
    content: none;
}

#textInput {
    display: block;
    width: 100%;
    min-height: clamp(205px, 21vh, 290px);
    padding: 0.9rem 6.5rem 1.05rem 1.15rem;
    border: 0;
    outline: 0;
    resize: vertical;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, var(--bg-strong)), var(--surface));
    color: var(--text);
    font-size: clamp(1rem, 1.12vw, 1.18rem);
    line-height: 1.72;
    transition: background 0.18s ease;
}

#textInput:focus {
    background:
        linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 96%, var(--bg-strong)));
}

.editor-status {
    position: absolute;
    top: 0.65rem;
    right: 0.75rem;
    z-index: 4;
    display: flex;
    justify-content: flex-end;
    padding: 0;
    background: transparent;
    pointer-events: none;
}

#textInput::placeholder {
    color: color-mix(in srgb, var(--muted) 74%, transparent);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.58rem;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-icon {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--primary);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.tool-icon:hover,
.case-chip:hover,
.tool-group button:hover {
    transform: translateY(-1px);
    border-color: var(--primary-2);
}

.tool-icon:hover {
    background: color-mix(in srgb, var(--primary-2) 9%, var(--surface));
}

.tool-icon.danger {
    color: var(--danger);
}

.tools-board {
    padding: 0.82rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 72%, var(--surface)), var(--surface-muted));
}

.quick-actions {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.68rem 0.72rem;
    border-top: 1px solid var(--line);
    background: var(--surface-soft);
}

.case-chip,
.tool-group button {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    font-weight: 800;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.case-chip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 0.34rem 0.42rem;
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1.15;
    white-space: nowrap;
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, #fff 75%, transparent),
        0 10px 24px rgba(12, 35, 78, 0.08);
}

.case-chip span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 18%, var(--surface));
    color: var(--accent);
    font-weight: 900;
}

.case-chip b {
    display: block;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    font-weight: 650;
}

.case-chip:nth-child(2) span,
.case-chip:nth-child(6) span {
    background: color-mix(in srgb, var(--green) 18%, var(--surface));
    color: var(--green);
}

.case-chip:nth-child(3) span {
    background: color-mix(in srgb, var(--primary-2) 16%, var(--surface));
    color: var(--primary-2);
}

.case-chip:nth-child(4) span,
.case-chip:nth-child(7) span {
    background: color-mix(in srgb, var(--purple) 18%, var(--surface));
    color: var(--purple);
}

.tool-group-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.62rem;
}

.tool-group {
    --tool-accent: var(--primary-2);
    position: relative;
    display: grid;
    grid-template-columns: 184px minmax(0, 1fr);
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
    overflow: visible;
    padding: 0.62rem 0.72rem;
    border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
    border-radius: 10px;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--tool-accent) 7%, transparent), transparent 34%),
        color-mix(in srgb, var(--surface) 94%, var(--surface-muted));
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, #fff 80%, transparent),
        0 10px 26px rgba(12, 35, 78, 0.055);
}

.tool-group::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--tool-accent), color-mix(in srgb, var(--tool-accent) 40%, var(--accent)));
    opacity: 0.95;
}

.tool-group:nth-child(2) {
    --tool-accent: var(--green);
}

.tool-group:nth-child(3) {
    --tool-accent: var(--purple);
}

.tool-group:nth-child(4) {
    --tool-accent: var(--accent);
}

.tool-group h4 {
    display: flex;
    align-items: center;
    gap: 0.58rem;
    min-height: 42px;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 720;
    color: color-mix(in srgb, var(--text) 72%, var(--muted));
}

.tool-group h4::before {
    content: "";
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--tool-accent) 13%, var(--surface));
    color: var(--tool-accent);
    font-size: 0.84rem;
    font-weight: 780;
    box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 72%, transparent);
}

.tool-group:nth-child(1) h4::before {
    content: "{}";
}

.tool-group:nth-child(2) h4::before {
    content: "ws";
}

.tool-group:nth-child(3) h4::before {
    content: "ln";
}

.tool-group:nth-child(4) h4::before {
    content: "ex";
}

.tool-actions {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 0.5rem;
}

.tool-group:nth-child(2) .tool-actions {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.tool-group:nth-child(3) .tool-actions {
    grid-template-columns: repeat(4, minmax(145px, 1fr));
}

.tool-group:nth-child(4) .tool-actions {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.tool-group button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.48rem;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    overflow: visible;
    padding: 0.42rem 0.62rem;
    border-color: color-mix(in srgb, var(--line) 82%, transparent);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 99%, var(--surface-muted)), color-mix(in srgb, var(--surface-muted) 55%, var(--surface)));
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 620;
    line-height: 1.18;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, #fff 80%, transparent),
        0 1px 0 color-mix(in srgb, var(--line) 42%, transparent);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tool-group button::before {
    content: "+";
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--tool-accent) 12%, var(--surface));
    color: var(--tool-accent);
    font-size: 0.8rem;
    font-weight: 740;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.tool-group button::after {
    content: none;
}

.tool-group button:hover {
    background: color-mix(in srgb, var(--tool-accent) 8%, var(--surface));
    color: color-mix(in srgb, var(--tool-accent) 38%, var(--text));
    border-color: color-mix(in srgb, var(--tool-accent) 38%, var(--line));
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, #fff 82%, transparent),
        0 8px 18px rgba(12, 35, 78, 0.075);
}

.tool-group button:hover::before {
    background: var(--tool-accent);
    color: #fff;
    transform: scale(1.04);
}

.ad-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.85fr) minmax(420px, 1.35fr) minmax(260px, 0.85fr);
    gap: 1rem;
    align-items: stretch;
}

.ad-slot {
    display: grid;
    place-items: center;
    min-height: 88px;
    padding: 0.85rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(135deg, color-mix(in srgb, var(--surface-soft) 65%, transparent) 0 12px, transparent 12px 24px),
        var(--surface);
    color: var(--muted);
    text-align: center;
}

.ad-slot span,
.native-ad span {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 760;
    text-transform: uppercase;
}

.ad-slot strong,
.native-ad strong {
    margin-top: 0.2rem;
    color: var(--text);
    font-weight: 680;
    line-height: 1.28;
}

.ad-slot > strong:first-child {
    margin-top: 0;
}

.ad-leaderboard {
    width: min(100%, 970px);
    min-height: 92px;
    margin: 0 auto;
}

.ad-between-tools {
    min-height: 82px;
    margin: 0.72rem auto;
}

.ad-top-compact {
    width: min(100%, 970px);
    min-height: 74px;
    margin: 0 auto;
}

.ad-tall {
    min-height: 250px;
}

.ad-wide-panel {
    min-height: 250px;
}

.native-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    max-width: 1780px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 3.5rem) 3rem;
}

.native-ad {
    position: relative;
    display: grid;
    align-content: start;
    gap: 0.38rem;
    min-height: 118px;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--surface-muted)), var(--surface));
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.native-ad small {
    max-width: 34rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 520;
    line-height: 1.48;
}

.native-ad::after {
    content: "";
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 0.52rem;
    height: 0.52rem;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    color: color-mix(in srgb, var(--primary) 60%, var(--muted));
    opacity: 0.42;
    transform: rotate(45deg);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.native-ad:hover,
.native-ad:focus-visible {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--primary-2) 28%, var(--line));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--primary-2) 5%, var(--surface)), var(--surface));
    box-shadow: 0 18px 44px rgba(12, 35, 78, 0.12);
}

.native-ad:hover::after,
.native-ad:focus-visible::after {
    opacity: 0.9;
    transform: translateX(2px) rotate(45deg);
}

.education-section {
    max-width: 1780px;
    margin: 0 auto 3rem;
    padding: 0 clamp(1rem, 3vw, 3.5rem);
}

.education-tool {
    margin-top: -0.25rem;
}

.education-head {
    max-width: 820px;
    margin-bottom: 1rem;
}

.education-head h2 {
    margin: 0.2rem 0 0;
    color: var(--text);
    font-size: clamp(1.45rem, 2.4vw, 2.25rem);
    line-height: 1.12;
    letter-spacing: 0;
}

.education-head p {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: clamp(0.96rem, 1.3vw, 1.05rem);
    line-height: 1.65;
}

.education-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

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

.education-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 0.85rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
    border-radius: 16px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--surface) 97%, transparent), color-mix(in srgb, var(--surface-muted) 54%, var(--surface)));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 18px 50px rgba(12, 35, 78, 0.07);
}

.education-badge {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background:
        radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.86), transparent 28px),
        color-mix(in srgb, var(--primary-2) 14%, var(--surface-muted));
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 760;
    text-transform: none;
}

.education-card h3 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1rem, 1.3vw, 1.16rem);
    line-height: 1.24;
    letter-spacing: 0;
}

.education-card p {
    margin: 0.42rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.68;
}

.education-example {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    width: fit-content;
    max-width: 100%;
    margin-top: 0.78rem;
    padding: 0.45rem 0.62rem;
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface) 86%, var(--surface-muted));
    color: var(--text);
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.education-compare {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 680px);
}

.education-compare span {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.education-example strong {
    color: var(--accent);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.education-example code {
    color: var(--text);
    font: inherit;
    white-space: pre-wrap;
}

/* FOOTER */

.site-footer {
    max-width: 1780px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 3.5rem) 1.35rem;
    color: var(--muted);
    text-align: center;
    font-size: clamp(0.72rem, 2.7vw, 0.82rem);
    font-weight: 540;
}

.site-footer span {
    display: block;
    padding-top: 1rem;
    border-top: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
    white-space: nowrap;
}

/* RESOURCE PAGES */

.resource-hero .hero-copy {
    max-width: 960px;
}

.resource-workspace {
    gap: 0.85rem;
    padding-bottom: 3rem;
}

.resource-panel {
    width: min(100%, 1180px);
    min-width: 0;
    margin: 0 auto;
    padding: clamp(1rem, 2vw, 1.6rem);
    border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
    border-radius: 18px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface) 98%, transparent), color-mix(in srgb, var(--surface-muted) 58%, var(--surface))),
        var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.78),
        0 26px 72px rgba(12, 35, 78, 0.1);
}

.resource-ad-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    width: min(100%, 1420px);
    margin: 0.25rem auto 0;
}

.resource-ad-card {
    min-height: 250px;
}

.resource-updated {
    display: inline-flex;
    margin: 0 0 1rem;
    padding: 0.35rem 0.62rem;
    border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-muted) 70%, transparent);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 620;
}

.resource-stack {
    display: grid;
    gap: 0.85rem;
}

.resource-section {
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
    border-radius: 14px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-muted) 38%, transparent));
}

.resource-section h2 {
    margin: 0 0 0.45rem;
    color: var(--text);
    font-size: clamp(1.02rem, 1.4vw, 1.2rem);
    line-height: 1.25;
}

.resource-section h2:only-child {
    margin-bottom: 0;
}

.resource-section p,
.resource-section li {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.72;
}

.resource-section p {
    margin: 0.35rem 0 0;
}

.resource-section ul {
    display: grid;
    gap: 0.36rem;
    margin: 0.65rem 0 0;
    padding-inline-start: 1.15rem;
}

.resource-document {
    max-width: 980px;
    margin: 0 auto;
    color: var(--muted);
}

.resource-document-section {
    padding: 0 0 clamp(1rem, 2vw, 1.45rem);
    margin-bottom: clamp(1rem, 2vw, 1.45rem);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 64%, transparent);
}

.resource-document-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.resource-document-section h2 {
    margin: 0 0 0.45rem;
    color: var(--text);
    font-size: clamp(1.05rem, 1.35vw, 1.28rem);
    font-weight: 720;
    line-height: 1.25;
}

.resource-document-section p,
.resource-document-section li {
    color: var(--muted);
    font-size: clamp(0.95rem, 1vw, 1rem);
    line-height: 1.78;
}

.resource-document-section p {
    margin: 0.35rem 0 0;
}

.resource-document-section ul {
    display: grid;
    gap: 0.36rem;
    margin: 0.65rem 0 0;
    padding-inline-start: 1.2rem;
}

.resource-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--primary-2) 22%, var(--line));
    border-radius: 14px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-2) 8%, var(--surface)), color-mix(in srgb, var(--surface) 94%, transparent));
}

.resource-cta strong {
    display: block;
    margin-top: 0.18rem;
    color: var(--text);
    font-size: 1.04rem;
}

.resource-cta p {
    max-width: 48rem;
    margin: 0.32rem 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.resource-cta-button {
    text-decoration: none;
    white-space: nowrap;
}

.contact-form {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.82rem;
    margin-top: 1rem;
    padding: clamp(0.9rem, 1.8vw, 1.25rem);
    border: 1px solid color-mix(in srgb, var(--primary-2) 18%, var(--line));
    border-radius: 16px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-muted) 46%, transparent)),
        var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 16px 40px rgba(12, 35, 78, 0.07);
}

.contact-field {
    display: grid;
    gap: 0.38rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 760;
    text-transform: uppercase;
}

.contact-field-full,
.form-alert,
.contact-actions {
    grid-column: 1 / -1;
}

.contact-field input,
.contact-field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 13px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 99%, var(--surface-muted)), var(--surface));
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 560;
    line-height: 1.55;
    text-transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.contact-field input {
    min-height: 48px;
    padding: 0 0.9rem;
}

.contact-field textarea {
    min-height: 150px;
    padding: 0.9rem;
    resize: vertical;
}

.contact-field input:focus,
.contact-field textarea:focus {
    border-color: color-mix(in srgb, var(--primary-2) 58%, var(--line));
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--focus);
    outline: 0;
}

.contact-field small {
    color: var(--danger);
    font-size: 0.74rem;
    font-weight: 650;
    text-transform: none;
}

.contact-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.2rem;
}

.contact-actions p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.5;
}

.contact-support-note {
    display: grid;
    justify-items: end;
    gap: 0.08rem;
    text-align: end;
}

.contact-direct-email {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.contact-email-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary-2);
    font-weight: 650;
    text-decoration: none;
}

.contact-email-link:hover,
.contact-email-link:focus-visible {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

html[dir="rtl"] .contact-support-note {
    justify-items: start;
    text-align: start;
}

.form-alert {
    padding: 0.78rem 0.9rem;
    border-radius: 13px;
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1.45;
}

.form-alert.success {
    border: 1px solid color-mix(in srgb, var(--green) 28%, var(--line));
    background: color-mix(in srgb, var(--green) 10%, var(--surface));
    color: color-mix(in srgb, var(--green) 72%, var(--text));
}

.form-alert.error {
    border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--line));
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    color: color-mix(in srgb, var(--danger) 74%, var(--text));
}

.contact-honeypot {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* CODE & DATA PAGES */

.code-tool-hero {
    padding-top: 0.35rem;
    padding-bottom: 1.05rem;
}

.code-tool-hero .hero-copy {
    max-width: 980px;
}

.code-tool-hero .hero-copy h1 {
    font-size: clamp(2rem, 4vw, 3.55rem);
}

.code-tool-workspace {
    gap: 1rem;
    padding-top: 0;
}

.code-tool-panel {
    position: relative;
    width: min(100%, 1780px);
    margin: 0 auto;
    padding: clamp(0.85rem, 1.8vw, 1.25rem);
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
    border-radius: 18px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-muted) 70%, var(--surface))),
        var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 28px 80px rgba(12, 35, 78, 0.12);
}

.code-tool-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-2), var(--green), var(--accent));
}

.code-tool-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.code-tool-head.is-compact {
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.code-tool-head h2 {
    margin: 0.16rem 0 0;
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    letter-spacing: 0;
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.34rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-muted) 78%, transparent);
}

.segmented-control button {
    min-height: 42px;
    padding: 0 1rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.segmented-control button:hover,
.segmented-control button.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 10px 22px rgba(12, 35, 78, 0.12);
    transform: translateY(-1px);
}

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

.code-text-box {
    display: grid;
    min-width: 0;
    gap: 0.55rem;
    color: var(--text);
    font-weight: 900;
}

.code-text-box > span {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.code-text-box textarea {
    width: 100%;
    height: 90px;
    min-height: 90px;
    padding: 1rem;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, transparent), color-mix(in srgb, var(--surface-muted) 28%, var(--surface)));
    color: var(--text);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 12px 34px rgba(12, 35, 78, 0.06);
    line-height: 1.65;
}

.code-text-box textarea[readonly] {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface-muted) 52%, var(--surface)), var(--surface));
}

.code-tool-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.code-tool-actions .dialog-primary,
.code-tool-actions .dialog-secondary,
.code-tool-actions select {
    min-height: 46px;
}

.code-tool-actions select {
    min-width: 190px;
    padding: 0 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 850;
}

.ocr-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
    gap: 1rem;
}

.upload-zone,
.ocr-preview {
    min-height: 300px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--surface-muted) 58%, var(--surface)));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.upload-zone {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.6rem;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.upload-zone:hover,
.upload-zone.dragging {
    border-color: color-mix(in srgb, var(--primary-2) 48%, var(--line));
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--primary-2) 8%, var(--surface)), color-mix(in srgb, var(--surface) 96%, transparent));
    box-shadow: 0 18px 42px rgba(12, 35, 78, 0.1);
    transform: translateY(-1px);
}

.upload-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-icon {
    display: inline-grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    color: var(--primary);
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.88), transparent 34px),
        color-mix(in srgb, var(--primary-2) 12%, var(--surface));
}

.upload-zone strong {
    font-size: 1.05rem;
}

.upload-zone small {
    color: var(--muted);
    font-weight: 800;
}

.ocr-preview {
    display: grid;
    place-items: center;
    padding: 0.8rem;
    color: var(--muted);
    font-weight: 900;
    overflow: hidden;
}

.ocr-preview img {
    width: 100%;
    height: 100%;
    max-height: 380px;
    object-fit: contain;
}

.ocr-output-box {
    margin-top: 1rem;
}

.ocr-output-box textarea {
    height: 240px;
    min-height: 200px;
}

/* GENERATORS */

.generator-panel {
    display: grid;
    gap: 1rem;
}

.generator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
    gap: 1rem;
    align-items: stretch;
}

.generator-layout-result {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.qr-generator-layout {
    grid-template-columns: minmax(0, 0.95fr) minmax(320px, 0.75fr);
}

.generator-result-card,
.generator-controls,
.qr-preview-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-muted) 52%, var(--surface)));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.72),
        0 14px 34px rgba(12, 35, 78, 0.06);
}

.generator-result-card {
    display: grid;
    gap: 0.65rem;
}

.generator-output,
.generator-input {
    width: 100%;
    min-height: 160px;
    padding: 1rem;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font-weight: 750;
    line-height: 1.6;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.password-output {
    min-height: 126px;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 1rem;
}

.password-generator-layout {
    align-items: start;
}

.password-generator-layout .generator-result-card,
.password-generator-layout .generator-controls {
    padding: 0.82rem;
}

.password-generator-layout .generator-result-card {
    gap: 0.5rem;
}

.password-generator-layout .password-output {
    min-height: 96px;
    height: 96px;
    padding: 0.78rem 0.9rem;
    font-size: 0.94rem;
    font-weight: 640;
    line-height: 1.52;
}

.password-generator-layout .generator-controls {
    gap: 0.74rem;
}

.password-generator-layout .control-grid,
.password-generator-layout .toggle-grid {
    gap: 0.55rem;
}

.password-generator-layout .control-field {
    font-size: 0.72rem;
    font-weight: 720;
}

.password-generator-layout .control-field input {
    min-height: 40px;
    font-weight: 650;
}

.password-generator-layout .toggle-grid label {
    min-height: 40px;
    padding: 0.52rem 0.66rem;
    font-size: 0.9rem;
    font-weight: 560;
    line-height: 1.22;
}

.password-generator-layout .toggle-grid input {
    width: 16px;
    height: 16px;
}

.generator-panel[data-generator-tool="password"] .code-tool-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.choice-input {
    min-height: 220px;
}

.generator-controls {
    display: grid;
    align-content: start;
    gap: 1rem;
}

.inline-generator-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.control-field {
    display: grid;
    min-width: 0;
    gap: 0.42rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.full-control-field {
    grid-column: 1 / -1;
}

.control-field input,
.control-field select {
    width: 100%;
    min-height: 48px;
    padding: 0 0.85rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    color: var(--text);
    font-weight: 850;
    text-transform: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.control-field input[type="color"] {
    min-height: 48px;
    padding: 0.28rem;
}

.toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.toggle-grid label,
.generator-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 46px;
    padding: 0.72rem 0.78rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: color-mix(in srgb, var(--surface) 92%, var(--surface-muted));
    color: var(--text);
    font-weight: 850;
}

.toggle-grid input,
.generator-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-2);
}

.qr-preview-card {
    display: grid;
    gap: 0.75rem;
}

.qr-canvas-frame {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 360px;
    padding: 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: 16px;
    background:
        repeating-linear-gradient(135deg, color-mix(in srgb, var(--surface-soft) 65%, transparent) 0 12px, transparent 12px 24px),
        var(--surface);
}

.qr-canvas-frame canvas {
    max-width: min(100%, 360px);
    height: auto;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(12, 35, 78, 0.13);
}

.qr-canvas-frame span {
    position: absolute;
    color: var(--muted);
    font-weight: 900;
}

.qr-canvas-frame span[hidden] {
    display: none;
}

.tool-dialog {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        radial-gradient(circle at 50% 18%, rgba(97, 175, 255, 0.2), transparent 26rem),
        rgba(7, 17, 31, 0.42);
    backdrop-filter: blur(18px);
}

.tool-dialog[hidden] {
    display: none;
}

.tool-dialog-card {
    position: relative;
    width: min(100%, 560px);
    border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
    border-radius: 24px;
    background:
        linear-gradient(160deg, color-mix(in srgb, var(--surface) 98%, transparent), color-mix(in srgb, var(--surface-muted) 70%, var(--surface))),
        var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 32px 110px rgba(7, 17, 31, 0.34);
    overflow: hidden;
    animation: dialog-in 0.18s ease-out;
}

.tool-dialog-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-2), var(--green), var(--accent));
}

.tool-dialog-head {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 38px;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1.28rem 1.24rem 1rem;
    border-bottom: 1px solid var(--line);
    background:
        radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--primary-2) 16%, transparent), transparent 15rem),
        var(--surface);
}

.tool-dialog-icon {
    display: inline-grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.92), transparent 34px),
        linear-gradient(145deg, color-mix(in srgb, var(--primary-2) 20%, var(--surface)), color-mix(in srgb, var(--purple) 12%, var(--surface)));
    color: var(--primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 16px 32px rgba(12, 35, 78, 0.13);
}

.tool-dialog-icon svg {
    width: 1.45rem;
    height: 1.45rem;
    stroke-width: 2.15;
}

.tool-dialog-copy {
    min-width: 0;
}

.tool-dialog-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.38rem;
    line-height: 1.2;
}

.tool-dialog-head p:last-child {
    margin: 0.35rem 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.dialog-close {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background:
        linear-gradient(180deg, var(--surface), var(--surface-muted));
    color: var(--primary);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.dialog-close:hover,
.dialog-close:focus-visible {
    transform: translateY(-1px);
    border-color: var(--primary-2);
    background: color-mix(in srgb, var(--primary-2) 8%, var(--surface));
}

.dialog-fields {
    display: grid;
    gap: 0.55rem;
    padding: 1.15rem 1.24rem 0;
}

.dialog-fields[hidden] {
    display: none;
}

.dialog-fields label {
    color: var(--text);
    font-weight: 850;
    font-size: 0.9rem;
}

.dialog-fields input {
    min-height: 52px;
    width: 100%;
    border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
    border-radius: 14px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, var(--surface-muted)), var(--surface-muted));
    color: var(--text);
    padding: 0 0.95rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.dialog-fields input:focus {
    border-color: var(--primary-2);
    background: var(--surface);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 0 0 4px var(--focus);
    outline: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 1.16rem 1.24rem 1.24rem;
    background: color-mix(in srgb, var(--surface-muted) 42%, transparent);
}

.dialog-primary,
.dialog-secondary {
    min-height: 46px;
    border-radius: 13px;
    padding: 0 1.05rem;
    font-weight: 850;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.dialog-primary {
    border: 1px solid var(--primary-2);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    box-shadow: 0 14px 28px color-mix(in srgb, var(--primary-2) 24%, transparent);
}

.dialog-secondary {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--primary);
}

.dialog-primary:hover,
.dialog-secondary:hover {
    transform: translateY(-1px);
}

.dialog-primary:disabled,
.dialog-secondary:disabled {
    cursor: progress;
    opacity: 0.68;
    transform: none;
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    z-index: 2300;
    min-width: min(92vw, 420px);
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--text);
    color: var(--surface);
    text-align: center;
    font-weight: 800;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 18px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    z-index: 20;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    background: var(--text);
    color: var(--surface);
    font-size: 0.78rem;
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-3px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

[dir="rtl"] .topbar,
[dir="rtl"] .brand,
[dir="rtl"] .desktop-nav,
[dir="rtl"] .top-actions,
[dir="rtl"] .editor-footer,
[dir="rtl"] .toolbar,
[dir="rtl"] .quick-actions {
    direction: rtl;
}

[dir="rtl"] .language-list {
    right: auto;
    left: 0;
}

[dir="rtl"] .nav-dropdown {
    right: 0;
    left: auto;
}

[dir="rtl"] .language-list button,
[dir="rtl"] .tool-group button,
[dir="rtl"] .nav-dropdown button,
[dir="rtl"] .nav-dropdown a {
    text-align: right;
}

[dir="rtl"] .native-ad::after {
    right: auto;
    left: 1rem;
    transform: rotate(225deg);
}

[dir="rtl"] .native-ad:hover::after,
[dir="rtl"] .native-ad:focus-visible::after {
    transform: translateX(-2px) rotate(225deg);
}

[dir="rtl"] .education-card {
    text-align: right;
}

[dir="rtl"] .editor-status {
    right: auto;
    left: 0.75rem;
}

[dir="rtl"] #textInput {
    padding: 0.9rem 1.15rem 1.05rem 6.5rem;
}

[dir="rtl"] .tool-group {
    grid-template-columns: minmax(0, 1fr) 184px;
    background:
        linear-gradient(270deg, color-mix(in srgb, var(--tool-accent) 7%, transparent), transparent 34%),
        color-mix(in srgb, var(--surface) 94%, var(--surface-muted));
}

[dir="rtl"] .tool-group::before {
    inset: 0 0 0 auto;
}

[dir="rtl"] .tool-group h4 {
    grid-column: 2;
}

[dir="rtl"] .tool-actions {
    grid-column: 1;
}

@media (max-width: 1180px) {
    .ad-grid,
    .resource-ad-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    :root {
        --topbar-top: 8px;
        --topbar-reserved: 142px;
    }

    .topbar {
        display: flex;
        flex-wrap: wrap;
        width: calc(100% - 20px);
        border-radius: 20px;
        gap: 10px;
    }

    .desktop-nav {
        order: 3;
        flex: 1 0 100%;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .desktop-nav::-webkit-scrollbar {
        display: none;
    }

    .desktop-nav button {
        flex: 0 0 auto;
    }

    .nav-dropdown {
        position: fixed;
        top: 116px;
        left: 12px;
        right: 12px;
        width: auto;
        max-height: min(72vh, 520px);
        overflow: auto;
    }

    .brand small {
        display: none;
    }

    .studio-hero,
    .workspace,
    .native-grid,
    .education-section,
    .site-footer {
        padding-inline: 0.75rem;
    }

    .hero-copy h1 {
        font-size: 2rem;
    }

    .ad-grid,
    .native-grid,
    .education-grid,
    .tool-group-grid,
    .code-tool-grid,
    .ocr-layout,
    .generator-layout,
    .generator-layout-result,
    .qr-generator-layout {
        grid-template-columns: 1fr;
    }

    .control-grid,
    .toggle-grid,
    .education-compare {
        grid-template-columns: 1fr;
    }

    .code-tool-head {
        align-items: stretch;
        flex-direction: column;
    }

    .resource-cta {
        align-items: stretch;
        flex-direction: column;
    }

    .resource-cta-button {
        text-align: center;
    }

    .contact-form {
        grid-template-columns: 1fr;
    }

    .contact-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .contact-actions .dialog-primary {
        width: 100%;
    }

    .segmented-control {
        width: 100%;
    }

    .segmented-control button {
        flex: 1 1 0;
        padding-inline: 0.6rem;
    }

    .code-text-box textarea {
        height: 90px;
        min-height: 90px;
    }

    .ocr-output-box textarea {
        height: 190px;
        min-height: 170px;
    }

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

    .editor-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .tool-group {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    [dir="rtl"] .tool-group {
        grid-template-columns: 1fr;
    }

    [dir="rtl"] .tool-group h4,
    [dir="rtl"] .tool-actions {
        grid-column: auto;
    }

    .tool-actions,
    .tool-group:nth-child(2) .tool-actions,
    .tool-group:nth-child(3) .tool-actions,
    .tool-group:nth-child(4) .tool-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .live-stats {
        justify-content: flex-start;
    }

    #textInput {
        min-height: 245px;
    }
}

@media (max-width: 520px) {
    :root {
        --topbar-reserved: 166px;
    }

    .site-shell,
    main,
    .studio-hero,
    .workspace,
    .native-grid,
    .editor-panel,
    .tools-board,
    .code-tool-panel,
    .ad-slot {
        max-width: 100%;
        min-width: 0;
    }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand actions"
            "nav nav";
        align-items: center;
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        padding: 10px;
        gap: 10px;
        overflow: visible;
    }

    [dir="rtl"] .topbar {
        padding: 10px;
    }

    .brand {
        grid-area: brand;
        min-width: 0;
    }

    .brand strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-actions {
        grid-area: actions;
        position: static;
        display: flex;
        width: auto;
        min-width: 0;
        gap: 7px;
        justify-content: flex-end;
        justify-self: end;
        overflow: visible;
    }

    [dir="rtl"] .top-actions {
        justify-self: end;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
    }

    .language-menu {
        display: block;
        width: 40px;
        min-width: 0;
        position: relative;
    }

    .language-btn {
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        height: 40px;
        overflow: hidden;
        padding: 0;
        justify-content: center;
    }

    .language-globe,
    #languageLabel,
    .language-chevron {
        display: none;
    }

    .language-list {
        position: absolute;
        top: calc(100% + 10px);
        right: 0;
        left: auto;
        width: min(268px, calc(100vw - 24px));
        min-width: 0;
        max-height: min(68vh, 520px);
        z-index: 2100;
    }

    [dir="rtl"] .language-list {
        right: auto;
        left: 0;
    }

    .desktop-nav {
        grid-area: nav;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        gap: 3px;
        padding: 4px;
        justify-content: stretch;
    }

    .nav-menu-item {
        flex: 1 1 0;
        min-width: 0;
    }

    .desktop-nav > button,
    .nav-trigger {
        width: 100%;
        justify-content: center;
        padding: 8px 5px;
        font-size: 0.7rem;
    }

    .nav-trigger svg {
        width: 0.76rem;
        height: 0.76rem;
    }

    .nav-dropdown {
        top: 146px;
    }

    .studio-hero {
        width: 100vw;
        max-width: 100vw;
        margin-inline: 0;
        padding-inline: 12px;
        padding-top: 0.45rem;
    }

    .workspace,
    .native-grid {
        width: 100vw;
        max-width: 100vw;
        margin-inline: 0;
        padding-inline: 12px;
    }

    .hero-copy p:last-child {
        max-width: 340px;
        overflow-wrap: break-word;
    }

    .code-tool-hero .hero-copy h1 {
        font-size: 1.72rem;
        line-height: 1.12;
    }

    .editor-status {
        right: 1.15rem;
    }

    .status-pill {
        min-height: 28px;
        padding: 0 0.52rem;
        font-size: 0.78rem;
    }

    .editor-footer {
        overflow: hidden;
    }

    .live-stats {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .live-stats span {
        width: 100%;
        white-space: normal;
    }

    .quick-actions {
        gap: 0.42rem;
        padding: 0.55rem;
    }

    .case-chip {
        min-height: 44px;
        font-size: 0.75rem;
    }

    .tool-actions,
    .tool-group:nth-child(2) .tool-actions,
    .tool-group:nth-child(3) .tool-actions,
    .tool-group:nth-child(4) .tool-actions {
        grid-template-columns: 1fr;
    }

    .code-tool-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .code-tool-actions .dialog-primary,
    .code-tool-actions .dialog-secondary,
    .code-tool-actions select {
        width: 100%;
    }

    .upload-zone,
    .ocr-preview {
        min-height: 220px;
    }

    .qr-canvas-frame {
        min-height: 280px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
