:root {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --text: #172033;
    --muted: #657084;
    --line: #d9e0ec;
    --primary: #1769e0;
    --primary-dark: #0f55b8;
    --success: #15803d;
    --warning: #b7791f;
    --danger: #c53030;
    --shadow: 0 18px 45px rgba(23, 32, 51, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 0%, rgba(23, 105, 224, 0.12), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 46%, #eaf0f7 100%);
    color: var(--text);
    font-family: Tahoma, Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

.topbar {
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}

.nav {
    width: min(1180px, calc(100% - 32px));
    min-height: 66px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
}

.nav a {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    padding: 8px 12px;
    border-radius: 999px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.nav-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.15;
}

.nav-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
}

.nav a:hover,
.nav a.active {
    background: #eaf2ff;
    color: var(--primary);
    transform: translateY(-1px);
}

.nav a:hover .nav-subtitle,
.nav a.active .nav-subtitle {
    color: var(--primary);
}

.page {
    width: min(900px, calc(100% - 48px));
    margin: 16px auto;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas: "main";
    gap: 20px;
}

.ad-column {
    display: none;
    min-height: 280px;
    visibility: hidden;
}

.ad-left { grid-area: left; }
.ad-right { grid-area: right; }

.tool {
    grid-area: main;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(217, 224, 236, 0.92);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: clamp(14px, 1.7vw, 20px);
}

h1 {
    margin: 0 0 7px;
    font-size: clamp(24px, 2.8vw, 34px);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.intro {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 14px;
    max-width: 900px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
    font: inherit;
    outline: none;
    box-shadow: 0 1px 0 rgba(23, 32, 51, 0.03);
}

input,
select {
    min-height: 38px;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

textarea[readonly] {
    background: var(--surface-soft);
}

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

button,
.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 0 15px;
    cursor: pointer;
    color: #fff;
    background: var(--primary);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

button:hover:not(:disabled),
.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(23, 105, 224, 0.18);
}

.btn-primary {
    color: #fff;
    background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-light {
    color: var(--text);
    background: #eef2f7;
}

.btn-light:hover:not(:disabled) {
    background: #e0e6ef;
    box-shadow: 0 10px 20px rgba(23, 32, 51, 0.08);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #a52727;
}

.field {
    margin-bottom: 14px;
}

.status {
    min-height: 22px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.status.success {
    color: var(--success);
    font-weight: 700;
}

.status.error {
    color: var(--danger);
    font-weight: 700;
}

.status.warning {
    color: var(--warning);
    font-weight: 700;
}

.notice {
    margin: 14px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
}

.notice.success {
    color: var(--success);
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
}

.notice.error,
.notice.danger {
    color: var(--danger);
    background: #fff1f2;
    border: 1px solid #fecdd3;
}

.empty {
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 18px;
    background: var(--surface-soft);
}

.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
}

.theme-toggle {
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    padding: 0 14px;
    cursor: pointer;
    color: var(--text);
    background: #eef2f7;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: #e0e6ef;
}

body.theme-dark {
    --bg: #0f172a;
    --surface: #162033;
    --surface-soft: #111b2d;
    --text: #e5edf8;
    --muted: #9fb0c8;
    --line: #2d3b54;
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #fb7185;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
    background: radial-gradient(circle at top left, rgba(96, 165, 250, 0.14), transparent 34%), var(--bg);
}

body.theme-dark .topbar,
body.theme-dark .tool,
body.theme-dark .result-row,
body.theme-dark .result-box,
body.theme-dark .stat,
body.theme-dark .feedback-item,
body.theme-dark .tool-card,
body.theme-dark .file-item {
    background: var(--surface);
    border-color: var(--line);
}

body.theme-dark .topbar {
    background: rgba(22, 32, 51, 0.88);
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
    background: #0b1220;
    color: var(--text);
    border-color: var(--line);
}

body.theme-dark textarea[readonly],
body.theme-dark .empty {
    background: #111b2d;
}

body.theme-dark .nav a:hover,
body.theme-dark .nav a.active {
    background: rgba(96, 165, 250, 0.16);
    color: var(--primary);
}

body.theme-dark .btn-light,
body.theme-dark button.theme-toggle {
    background: #22304a;
    color: var(--text);
}

body.theme-dark .btn-light:hover:not(:disabled),
body.theme-dark button.theme-toggle:hover {
    background: #2c3d5d;
}

body.theme-dark .share-box {
    background: rgba(21, 128, 61, 0.16);
    border-color: rgba(74, 222, 128, 0.42);
}

body.theme-dark .notice,
body.theme-dark .notice.error {
    background: rgba(251, 113, 133, 0.12);
    border-color: rgba(251, 113, 133, 0.42);
}

body.theme-dark .notice.success {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.38);
}

@media (min-width: 1100px) {
    .page {
        width: min(1080px, calc(100% - 40px));
        grid-template-columns: 90px minmax(0, 1fr) 90px;
        grid-template-areas: "left main right";
        align-items: start;
    }

    .ad-column {
        display: block;
    }
}

@media (min-width: 1440px) {
    .page {
        width: min(1240px, calc(100% - 40px));
        grid-template-columns: 120px minmax(0, 1fr) 120px;
    }
}

@media (max-height: 820px) and (min-width: 900px) {
    .nav {
        min-height: 58px;
    }

    .page {
        margin: 14px auto;
    }

    .tool {
        padding: 14px;
        border-radius: 16px;
    }

    h1 {
        font-size: clamp(24px, 2.8vw, 34px);
    }

    .intro {
        margin-bottom: 12px;
        font-size: 14px;
    }

    input,
    select {
        min-height: 36px;
    }

    button,
    .btn {
        min-height: 38px;
    }
}

@media (max-width: 720px) {
    .nav {
        width: min(100% - 20px, 1180px);
        min-height: 64px;
        justify-content: flex-start;
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin: 14px auto;
    }

    .tool {
        padding: 18px;
        border-radius: 18px;
    }

    .theme-toggle {
        min-height: 36px;
    }
}
