
:root {
    color-scheme: dark;

    --background: #0b1014;
    --surface: #111a20;
    --surface-secondary: #17232b;
    --surface-hover: #1d2b34;
    --border: #2a3942;
    --border-strong: #40535d;

    --primary: #65d6c4;
    --primary-hover: #8ae4d6;
    --primary-soft: rgba(101, 214, 196, 0.12);

    --button-bg: #32b8a5;
    --button-hover: #65d6c4;
    --button-text: #071411;

    --text: #f1f5f7;
    --text-secondary: #c0cbd1;
    --text-muted: #9aaab3;

    --success: #4ade80;
    --focus: #38bdf8;

    --radius: 12px;
}

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

    --background: #f5f7f8;
    --surface: #ffffff;
    --surface-secondary: #f5f7f8;
    --surface-hover: #e7efef;
    --border: #d5dfe2;
    --border-strong: #b9c9ce;

    --primary: #087f70;
    --primary-hover: #066b5e;
    --primary-soft: rgba(8, 127, 112, 0.09);

    --button-bg: #087f70;
    --button-hover: #066b5e;
    --button-text: #ffffff;

    --text: #182329;
    --text-secondary: #394950;
    --text-muted: #52646d;

    --success: #15803d;
    --focus: #087ca7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.6;
    transition: background 0.2s, color 0.2s;
}

button,
textarea,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

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

.app {
    width: min(100% - 40px, 820px);
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.header {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    text-decoration: none;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 1px;
    transition: color 0.2s;
}

.logo:hover {
    color: var(--primary);
}

.logo-icon {
    color: var(--primary);
    font-size: 25px;
}

.version {
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-size: 10px;
    letter-spacing: 0;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 19px;
    transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.main {
    flex: 1;
    padding: 55px 0 40px;
}

.intro {
    margin-bottom: 30px;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
}

.intro h1 {
    margin-top: 12px;
    font-size: clamp(30px, 6vw, 44px);
    line-height: 1.15;
    letter-spacing: -1.5px;
}

.intro h1 span {
    color: var(--primary);
}

.intro p {
    max-width: 580px;
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 15px;
}

.reader,
.reading-time {
    padding: 25px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    transition: background 0.2s, border-color 0.2s;
}

.section-heading {
    margin-bottom: 17px;
}

.section-heading h2,
.time-heading h2 {
    font-size: 19px;
}

.section-heading p {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 13px;
}

#text-input {
    width: 100%;
    min-height: 190px;
    padding: 15px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-secondary);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    transition: background 0.2s, border-color 0.2s;
}

#text-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

#text-input:focus {
    border-color: var(--primary);
}

.text-actions {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#input-feedback {
    color: var(--text-secondary);
    font-size: 12px;
}

.clear-button {
    min-height: 36px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-secondary);
    color: var(--text);
    font-size: 12px;
    transition: background 0.2s, border-color 0.2s;
}

.clear-button:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.clear-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

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

.metric-card {
    min-width: 0;
    min-height: 112px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-secondary);
    transition: background 0.2s, border-color 0.2s;
}

.metric-icon {
    color: var(--primary);
    font-size: 17px;
    font-weight: 700;
}

.metric-label {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.metric-card strong {
    max-width: 100%;
    margin-top: 2px;
    overflow-wrap: anywhere;
    font-size: 23px;
    line-height: 1.3;
}

.reading-time {
    margin-top: 20px;
}

.time-heading h2 {
    margin-top: 5px;
}

.time-result {
    min-height: 105px;
    margin-top: 17px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-secondary);
}

.clock-icon {
    color: var(--primary);
    font-size: 34px;
    line-height: 1;
}

.time-result strong {
    color: var(--primary);
    font-size: clamp(25px, 5vw, 34px);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.speed-control {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-control label {
    font-size: 13px;
    font-weight: 700;
}

.speed-control select {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-secondary);
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.2s, background 0.2s;
}

.speed-control select:hover {
    border-color: var(--border-strong);
}

.time-description {
    min-height: 24px;
    margin-top: 13px;
    color: var(--text-secondary);
    font-size: 12px;
}

.info {
    display: flex;
    gap: 14px;
    margin-top: 22px;
    padding: 19px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.info-icon {
    flex-shrink: 0;
    color: var(--primary);
    font-size: 22px;
}

.info h2 {
    margin-bottom: 4px;
    font-size: 14px;
}

.info p {
    color: var(--text-secondary);
    font-size: 12px;
}

.footer {
    min-height: 65px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
}

.footer span:first-child {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1px;
}

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

@media (max-width: 600px) {
    .app {
        width: min(100% - 28px, 820px);
    }

    .main {
        padding-top: 40px;
    }

    .reader,
    .reading-time {
        padding: 19px 15px;
    }

    .metrics {
        gap: 7px;
    }

    .metric-card {
        min-height: 100px;
        padding: 10px 8px;
    }

    .metric-label {
        font-size: 11px;
    }

    .metric-card strong {
        font-size: 19px;
    }

    .footer {
        padding: 16px 0;
        flex-wrap: wrap;
    }
}

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

    .metric-card {
        min-height: 85px;
    }

    .text-actions {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 0;
    }
}

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