:root {
    --page: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #17202a;
    --muted: #637083;
    --line: #d8dee8;
    --line-strong: #b9c3d2;
    --teal: #0f766e;
    --teal-dark: #0b5d57;
    --blue: #315efb;
    --purple: #645bff;
    --amber: #d97706;
    --shadow: 0 18px 48px rgba(23, 32, 42, 0.12);
    --sans: Arial, Helvetica, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
}

html.theme-dark {
    --page: #0c111d;
    --surface: #111827;
    --surface-soft: #172033;
    --ink: #e6edf7;
    --muted: #96a3b8;
    --line: rgba(148, 163, 184, 0.24);
    --line-strong: rgba(148, 163, 184, 0.42);
    --teal: #2dd4bf;
    --teal-dark: #5eead4;
    --blue: #60a5fa;
    --amber: #f59e0b;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(244, 246, 249, 0.97)),
        radial-gradient(circle at 16% 10%, rgba(15, 118, 110, 0.14), transparent 26%),
        radial-gradient(circle at 88% 8%, rgba(217, 119, 6, 0.12), transparent 24%),
        var(--page);
    font-family: var(--sans);
}

html.theme-dark body {
    background:
        linear-gradient(180deg, rgba(12, 17, 29, 0.96), rgba(15, 23, 42, 0.98)),
        radial-gradient(circle at 16% 10%, rgba(45, 212, 191, 0.12), transparent 28%),
        radial-gradient(circle at 88% 8%, rgba(96, 165, 250, 0.1), transparent 24%),
        var(--page);
}

a {
    color: inherit;
    text-decoration: none;
}

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

button {
    cursor: pointer;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
}

html.theme-dark .app-header {
    background: rgba(15, 23, 42, 0.92);
}

.header-inner {
    width: min(1480px, 100%);
    min-height: 68px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 900;
}

.brand-logo {
    display: block;
    width: clamp(160px, 24vw, 260px);
    max-width: 100%;
    height: auto;
    max-height: 48px;
    flex: 0 0 auto;
    aspect-ratio: 360 / 88;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}

.header-search {
    min-width: 250px;
    height: 40px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    flex: 0 1 auto;
}

.header-search input {
    width: 100%;
    height: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    padding: 0 11px;
    color: var(--ink);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search input::placeholder {
    color: var(--muted);
}

.search-submit,
.theme-toggle,
.menu-toggle {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: var(--surface);
    font-weight: 800;
}

.search-submit {
    width: 40px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.search-submit:hover {
    color: var(--ink);
    background: var(--surface-soft);
    box-shadow: none;
    transform: none;
}

.menu-toggle {
    display: none;
    width: 42px;
    padding: 0;
    position: relative;
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
}

.menu-toggle span {
    position: absolute;
    width: 19px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.menu-toggle span:nth-child(1) {
    transform: translateY(-6px);
}

.menu-toggle span:nth-child(3) {
    transform: translateY(6px);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg);
}

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

.tool-shell {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 64px;
}

.page {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 64px;
}

.tool-hero,
.tool-card {
    border-radius: 26px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34%),
        rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.theme-dark .tool-hero,
.theme-dark .tool-card {
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34%),
        rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.14);
}

.tool-hero {
    padding: clamp(24px, 4vw, 44px);
}

.tool-about {
    margin-top: 18px;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
    display: grid;
    gap: 8px;
}

.tool-about__eyebrow {
    color: var(--teal-dark);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tool-about h2 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.15;
}

.tool-about p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
    max-width: 78ch;
}

.tool-about__list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
    color: var(--ink);
    line-height: 1.6;
}

.tool-about__list li {
    padding-left: 4px;
}

html.theme-dark .tool-about {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.14);
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 30px 0 14px;
}

.title-row h1 {
    margin: 0;
    font-size: clamp(2.2rem, 6vw, 4.3rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--teal-dark);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero-copy {
    margin: 14px 0 0;
    max-width: 68ch;
    color: #475569;
    font-size: 1.04rem;
    line-height: 1.75;
}

.title-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
}

.meta-chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(15, 118, 110, 0.15);
    background: rgba(15, 118, 110, 0.08);
    color: var(--teal-dark);
    font-size: 0.84rem;
    font-weight: 800;
}

.toolbar {
    margin-top: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.theme-dark .toolbar {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.14);
}

.toolbar-inner {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.control-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.control {
    min-height: 52px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    display: grid;
    align-content: center;
    gap: 2px;
}

.control label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.control strong {
    font-size: 0.92rem;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.primary-button,
.file-button,
.icon-button,
.danger-button {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font-weight: 800;
}

.primary-button {
    color: #fff;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
}

.file-button,
.icon-button,
.danger-button {
    background: rgba(15, 118, 110, 0.08);
    color: #0f766e;
}

.theme-dark .file-button,
.theme-dark .icon-button,
.theme-dark .danger-button {
    background: rgba(20, 184, 166, 0.12);
    color: #7ee7dc;
}

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

.editor-panel {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.theme-dark .editor-panel {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.14);
}

.panel-header,
.panel-footer {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-header {
    border-bottom: 1px solid var(--line);
}

.panel-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.panel-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
}

.panel-title i {
    color: var(--teal-dark);
}

.panel-tools {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.editor-shell {
    padding: 18px;
}

.editor-shell .tool-fields {
    margin-top: 0;
}

.output-box {
    width: 100%;
    min-height: 312px;
    font-family: var(--mono);
}

.status-bar {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.theme-dark .status-bar {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.14);
}

.status-copy {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.status-light {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.progress {
    margin-top: 14px;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 118, 110, 0.1);
}

.progress span {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.tool-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: #0f766e;
    font-weight: 700;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.theme-dark .tool-kicker {
    background: rgba(20, 184, 166, 0.14);
    color: #7ee7dc;
}

.tool-title {
    margin: 0;
    font-size: clamp(2.2rem, 7vw, 4.6rem);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

.tool-lead {
    margin: 16px 0 0;
    max-width: 68ch;
    color: #475569;
    font-size: 1.05rem;
    line-height: 1.75;
}

.theme-dark .tool-lead,
.theme-dark .tool-card p,
.theme-dark .tool-note {
    color: #cbd5e1;
}

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

.tool-card {
    padding: 24px;
}

.tool-card h2 {
    margin: 0 0 10px;
    font-size: 1.12rem;
}

.tool-fields {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.tool-field {
    display: grid;
    gap: 8px;
}

.tool-field label {
    font-weight: 700;
    color: #0f172a;
}

.theme-dark .tool-field label {
    color: #e2e8f0;
}

.tool-field textarea,
.tool-field input,
.tool-field select {
    width: 100%;
    min-height: 50px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(15, 118, 110, 0.18);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.tool-field textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.6;
}

.tool-actions {
    display: flex;
    flex-wrap: wrap;
    margin-top: 8px;
    gap: 10px;
}

.tool-button {
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tool-button.primary {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: white;
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
}

.tool-button.ghost {
    background: rgba(15, 118, 110, 0.08);
    color: #0f766e;
}

.theme-dark .tool-button.ghost {
    background: rgba(20, 184, 166, 0.12);
    color: #7ee7dc;
}

.tool-status {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.tool-status-bar {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(15, 118, 110, 0.08);
    color: #0f172a;
    font-weight: 600;
}

.theme-dark .tool-status-bar {
    background: rgba(20, 184, 166, 0.12);
    color: #e2e8f0;
}

.tool-note {
    margin-top: 14px;
    padding: 18px 20px;
    border-radius: 18px;
    background: rgba(15, 118, 110, 0.06);
    border: 1px solid rgba(15, 118, 110, 0.12);
    color: #475569;
}

.tool-summary {
    margin-top: 18px;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid rgba(15, 118, 110, 0.12);
    background: rgba(15, 118, 110, 0.04);
    white-space: pre-wrap;
    line-height: 1.7;
}

.theme-dark .tool-summary {
    background: rgba(20, 184, 166, 0.06);
    border-color: rgba(20, 184, 166, 0.14);
}

@media (max-width: 960px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .title-row {
        flex-direction: column;
    }
}

@media (max-width: 1320px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .primary-nav {
        flex: 1 1 100%;
        margin-left: 0;
        order: 3;
        width: 100%;
        justify-content: flex-start;
        gap: 4px;
    }

    .header-actions {
        width: 100%;
        margin-left: 0;
        order: 4;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-search {
        min-width: min(100%, 280px);
        flex: 1 1 280px;
    }
}

@media (max-width: 640px) {
    .header-inner,
    .tool-shell {
        width: calc(100% - 28px);
    }

    .header-inner {
        padding: 12px 0;
        flex-wrap: wrap;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .tool-hero,
    .tool-card {
        border-radius: 16px;
    }

    .page {
        width: calc(100% - 28px);
    }

    .toolbar-inner,
    .panel-header,
    .panel-footer {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 860px) {
    .header-inner,
    .page {
        padding-left: 16px;
        padding-right: 16px;
    }

    .header-inner {
        flex-wrap: wrap;
    }

    .brand-logo {
        width: clamp(136px, 42vw, 200px);
        max-height: 40px;
    }

    .primary-nav {
        position: absolute;
        left: 16px;
        right: 16px;
        top: 68px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: var(--surface);
        box-shadow: var(--shadow);
        width: auto;
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 96px);
        overflow-y: auto;
        overscroll-behavior: contain;
        box-sizing: border-box;
    }

    .primary-nav.open {
        display: flex;
    }

    .nav-link,
    .nav-trigger {
        justify-content: space-between;
        width: 100%;
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        min-width: 0;
        max-width: 100%;
        margin-top: 4px;
        padding: 6px;
        background: var(--surface-soft);
    }

    .dropdown-menu a::after {
        content: "";
    }

    .header-search {
        min-width: 0;
        flex: 1;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .header-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        min-height: 86px;
        align-content: flex-start;
    }

    .title-row {
        flex-direction: column;
        align-items: start;
    }

    .title-row > div {
        width: 100%;
    }

    .title-meta {
        justify-content: flex-start;
    }

    .toolbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
    }

    .toolbar-actions > * {
        flex: 1 1 150px;
        min-width: 0;
    }

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

    .tool-summary__figure img {
        margin-left: 0;
        max-width: 100%;
    }
}
