:root {
    --bg: #ffffff;
    --bg-alt: #f3f7f8;
    --text: #1d2a30;
    --muted: #5d6e76;
    --accent: #0f8a7e;
    --accent-dark: #0b6c63;
    --border: #d9e3e6;
    --error: #b3261e;
    --radius: 12px;

    /* Градиенты */
    --grad-accent: linear-gradient(135deg, #1bb3a2 0%, #0f8a7e 55%, #0b6c63 100%);
    --grad-accent-hover: linear-gradient(135deg, #17a193 0%, #0b7a70 55%, #095a52 100%);
    --grad-soft: linear-gradient(180deg, #f3f9f8 0%, #eef5f7 100%);
    --grad-card: linear-gradient(180deg, #ffffff 0%, #f7fbfb 100%);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: clamp(24px, 3.5vw, 32px); }
h3 { font-size: 19px; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

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

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: linear-gradient(90deg, #ffffff 0%, #f4faf9 100%); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 80px; gap: 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo-mark { display: block; width: 64px; height: 64px; object-fit: contain; background: none; border-radius: 0; }
.nav { display: flex; gap: 20px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover { color: var(--accent); }
.nav { align-items: center; }
.nav .nav-profile { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.nav .nav-profile:hover { color: var(--accent); }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; background: var(--grad-accent); color: #fff; font-size: 14px; font-weight: 700; text-transform: uppercase; }
.cabinet-page { padding: 48px 16px; }
.cabinet-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.cabinet-actions form { margin: 0; }
.profile { max-width: 560px; margin: 24px 0 32px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--grad-card); padding: 8px 24px; }
.profile div { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.profile div:last-child { border-bottom: 0; }
.profile dt { flex: 0 0 140px; color: var(--muted); }
.profile dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
    .profile div { flex-direction: column; gap: 2px; }
    .profile dt { flex: none; }
}
.auth-page { padding: 48px 16px; }

/* Hero */
.hero {
    padding: 56px 0 48px;
    background:
        radial-gradient(900px 420px at 12% 0%, rgba(27, 179, 162, .20), transparent 70%),
        radial-gradient(700px 380px at 95% 20%, rgba(64, 150, 214, .14), transparent 70%),
        linear-gradient(180deg, #eaf6f4 0%, var(--bg) 100%);
}
.hero h1 {
    color: var(--text);
    background: linear-gradient(90deg, #1d2a30 0%, #0f6f66 60%, #0f8a7e 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.lead { font-size: 19px; color: var(--muted); margin: 0 0 28px; }

.decoder {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: 0 10px 34px rgba(15, 90, 90, .10);
}
.decoder textarea {
    width: 100%; border: 0; resize: vertical; font: inherit; color: inherit;
    min-height: 150px; outline: none; background: transparent;
}
.decoder-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.decoder-footer .hint { flex: 1 1 240px; }
.decoder-footer .btn { flex: none; margin-left: auto; }
.hint { font-size: 14px; color: var(--muted); }

.btn {
    background: var(--accent); background-image: var(--grad-accent); color: #fff; border: 0; border-radius: 10px;
    padding: 12px 28px; font: inherit; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 138, 126, .28); transition: box-shadow .2s, transform .2s;
}
.btn:hover { background-image: var(--grad-accent-hover); box-shadow: 0 6px 20px rgba(15, 138, 126, .36); transform: translateY(-1px); }
.btn:focus-visible, .decoder:focus-within { outline: 3px solid rgba(15, 138, 126, .3); outline-offset: 2px; }

/* Result */
.result {
    max-width: 760px; margin-top: 24px; background: var(--grad-card); border: 1px solid var(--border);
    border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 20px 24px;
}
.result-title { font-size: 22px; }
.terms { margin: 0; }
.term { padding: 12px 0; border-bottom: 1px solid var(--border); }
.term:last-child { border-bottom: 0; }
.term dt { font-weight: 700; }
.term dd { margin: 4px 0 0; }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }

.ai-answer h3, .ai-answer h4, .ai-answer h5, .ai-answer h6 { font-size: 18px; margin: 1.2em 0 .4em; }
.ai-answer > :first-child { margin-top: 0; }
.ai-answer p { margin: 0 0 .8em; }
.ai-answer ul, .ai-answer ol { margin: 0 0 .8em; padding-left: 1.3em; }
.ai-answer li { margin-bottom: .35em; }
.alert-note { background: #fff6e0; border-radius: 8px; padding: 10px 14px; font-size: 15px; }

.disclaimer { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.alert-error { margin-top: 16px; color: var(--error); }

/* Sections */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-alt); background-image: var(--grad-soft); }
.section-blue {
    background:
        radial-gradient(700px 360px at 90% 0%, rgba(64, 150, 214, .16), transparent 70%),
        linear-gradient(180deg, #eaf4fb 0%, #f4f9fd 100%);
}

/* Картинка слева, текст справа */
.media { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; align-items: center; }
.media-right { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.media-img { display: block; width: 100%; height: auto; border-radius: var(--radius); }
.media-body > :last-child { margin-bottom: 0; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.step { background: var(--grad-card); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(15, 60, 70, .05); }
.step p { margin: 0; color: var(--muted); }
.step-num {
    display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); background-image: var(--grad-accent); color: #fff; font-weight: 700; margin-bottom: 12px;
    box-shadow: 0 3px 10px rgba(15, 138, 126, .3);
}

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.card {
    position: relative; overflow: hidden; background: var(--grad-card);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
    transition: box-shadow .2s, transform .2s;
}
.card::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--grad-accent);
    opacity: .5; transition: opacity .2s;
}
.card:hover { box-shadow: 0 10px 28px rgba(15, 90, 90, .10); transform: translateY(-2px); }
.card:hover::before { opacity: 1; }
.card p { margin: 0; color: var(--muted); }

.checklist { list-style: none; padding: 0; margin: 20px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checklist li { padding-left: 28px; position: relative; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* Последние посты блога: горизонтальная лента «иконка + название» */
.posts-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: .6em; }
.posts-head h2 { margin: 0; }
.posts-arrows { display: flex; gap: 8px; }
.posts-arrow {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: #fff;
    color: var(--accent); font-size: 24px; line-height: 1; cursor: pointer; transition: background .2s, color .2s;
}
.posts-arrow:hover { background: var(--accent); background-image: var(--grad-accent); color: #fff; border-color: transparent; }
.posts {
    list-style: none; margin: 0 -16px; padding: 6px 16px 14px;
    display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.posts li { flex: 0 0 250px; scroll-snap-align: start; }
.post-chip {
    display: flex; flex-direction: column; height: 100%; overflow: hidden;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); text-decoration: none; transition: box-shadow .2s, border-color .2s;
}
.post-chip:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(15, 90, 90, .10); color: var(--accent); }
.post-icon { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.post-title {
    padding: 12px 14px 14px; font-size: 15px; font-weight: 600; line-height: 1.35;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}

.faq-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item p { margin: 10px 0 0; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; font-size: 15px; color: var(--muted); background: linear-gradient(180deg, #ffffff 0%, #eef6f5 100%); }
.footer-title { margin: 0 0 12px; font-size: 18px; color: var(--text); }
.footer-disclaimer { margin: 0 0 16px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 16px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }
.copy { margin-bottom: 0; }

@media (max-width: 900px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
    .steps, .cards, .checklist, .media { grid-template-columns: 1fr; }
    .posts-arrows { display: none; }
    .posts li { flex-basis: 220px; }
    .media { gap: 24px; }
    .hero { padding: 36px 0 32px; }
    .section { padding: 44px 0; }
    .nav { display: none; }
}

/* Страница расшифровки */
.container-wide { max-width: 1440px; margin: 0 auto; padding: 0 16px; }
.result-page {
    padding: 32px 0 56px; background: var(--bg-alt);
    background-image: radial-gradient(800px 300px at 10% 0%, rgba(27, 179, 162, .12), transparent 70%), var(--grad-soft);
}
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.result-head h1 { font-size: clamp(24px, 3vw, 32px); margin: 0; }

.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); text-decoration: none; padding: 10px 20px; box-shadow: none; }
.btn-outline:hover { background: var(--accent); background-image: var(--grad-accent); color: #fff; border-color: transparent; }

.result-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    grid-template-areas: "source answer terms";
    gap: 20px;
    align-items: start;
}
.col { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.col h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 14px; }
.col-source { grid-area: source; position: sticky; top: 16px; }
.col-answer { grid-area: answer; position: relative; overflow: hidden; padding-top: 24px; }
.col-answer::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--grad-accent); }
.col-terms  { grid-area: terms; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }

.source-text { font-size: 16px; white-space: normal; overflow-wrap: anywhere; }
.term-mark {
    color: inherit; text-decoration: none; background: #fff1c2;
    border-bottom: 2px solid #f0c419; border-radius: 3px; padding: 0 2px;
}
.term-mark.is-active, .term-mark:hover { background: #ffe07a; }

.col-terms .term { font-size: 15px; border-radius: 8px; padding: 10px; margin: 0 -10px; border-bottom: 0; transition: background .15s; }
.col-terms .term + .term { border-top: 1px solid var(--border); }
.col-terms .term.is-active, .col-terms .term:target { background: #fff6d6; }
.terms-note { font-size: 14px; color: var(--muted); margin: -6px 0 10px; }

@media (max-width: 1100px) {
    .result-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "answer answer" "source terms";
    }
    .col-source, .col-terms { position: static; max-height: none; }
}
@media (max-width: 680px) {
    .result-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "source" "answer" "terms"; }
}

/* Клик по термину: вспышка в колонке терминов и всплывающая подсказка */
@keyframes term-flash { from { background: #ffe07a; } to { background: transparent; } }
.col-terms .term.is-flash { animation: term-flash 1.6s ease-out; }
.col-terms { scroll-padding-top: 56px; }

.term-popover {
    position: absolute; z-index: 20; width: min(340px, calc(100vw - 16px));
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 60, 70, .18); padding: 12px 14px; font-size: 15px;
}
.term-popover p { margin: 4px 0 0; color: var(--text); }

/* Предупреждение о cookie */
.cookie-banner {
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50;
    max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 12px 40px rgba(15, 60, 70, .18);
    padding: 18px 20px; font-size: 15px;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0 0 8px; }
.cookie-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.cookie-actions .btn { padding: 10px 24px; }
@media (max-width: 680px) {
    .cookie-banner { left: 8px; right: 8px; bottom: 8px; padding: 16px; }
    .cookie-actions .btn { flex: 1; }
}

/* Мои расшифровки */
.history-page { padding: 48px 16px; }
.breadcrumbs { margin: 0 0 8px; font-size: 14px; }
.history-note { background: var(--bg-alt); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 0 0 24px; }
.history-status { color: var(--muted); }
.history-list { list-style: none; margin: 0 0 24px; padding: 0; }
.history-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--grad-card); padding: 14px 18px; margin-bottom: 12px; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history-title-box { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.history-title { font-weight: 700; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.history-title:hover { color: var(--accent); }
.history-date { font-size: 14px; color: var(--muted); }
.history-tools { display: flex; gap: 16px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--accent); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-danger, .btn-danger { color: var(--error); border-color: var(--error); }
.btn-outline.btn-danger:hover { background: var(--error); background-image: none; color: #fff; }
.history-rename { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1 1 100%; }
.history-rename input { flex: 1 1 220px; font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.btn.btn-sm { padding: 6px 14px; font-size: 14px; }
.history-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.history-saved { margin: -12px 0 20px; font-size: 14px; color: var(--muted); }
