:root {
    color-scheme: dark;
    --background: #0b0f14;
    --surface: #11161d;
    --surface-raised: #171d26;
    --surface-soft: #0b0f14;
    --text: #f4f4f5;
    --muted: #94a3b8;
    --border: #232b36;
    --accent: #f4f4f5;
    --accent-text: #0b0f14;
    --danger: #ffb2ba;
    --success: #a9e5c6;
    --focus: #94a3b8;
    --radius: 22px;
    --shadow: 0 20px 60px rgb(0 0 0 / 22%);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-underline-offset: 3px;
}

a:hover {
    color: #c3ccd6;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a,
input,
textarea,
select,
summary {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 4px;
}

button {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 11px 18px;
    cursor: pointer;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        transform 160ms ease,
        opacity 160ms ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 650;
}

.primary:hover:not(:disabled) {
    background: #e4e4e7;
}

.secondary {
    background: var(--surface-raised);
    color: var(--text);
    border-color: #2f3b4a;
}

.secondary:hover:not(:disabled) {
    background: #1d2430;
}

.quiet {
    background: transparent;
    color: var(--muted);
    border-color: var(--border);
}

.quiet:hover:not(:disabled) {
    color: var(--text);
    border-color: #53617a;
}

.hidden {
    display: none !important;
}

.header {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
    min-height: auto;
    padding: 4px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid rgb(166 175 191 / 12%);
}

.brand {
    display: flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 750;
    letter-spacing: 0.12em;
}

.site-logo {
  height: 120px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: -22px 0;
}

@media (max-width: 600px) {
  .site-logo {
    height: 88px;
    margin: -14px 0;
  }
}

.eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.layout {
    width: min(940px, calc(100% - 48px));
    margin: 42px auto 60px;
}

.card {
    margin-bottom: 22px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.intro {
    max-width: 660px;
    margin: 0 auto;
    padding: 36px;
}

h1,
h2,
h3 {
    color: var(--text);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

h1 {
    margin: 10px 0 22px;
    font-size: clamp(28px, 4.4vw, 44px);
    font-weight: 650;
    letter-spacing: -0.035em;
}

h2 {
    margin: 0 0 16px;
    font-size: clamp(21px, 3vw, 27px);
    font-weight: 650;
    letter-spacing: -0.02em;
}

h3 {
    margin: 24px 0 12px;
    font-size: 18px;
}

p {
    margin: 0 0 16px;
}

p:last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
    line-height: 1.65;
}

form {
    display: grid;
    gap: 18px;
}

#profileForm {
    margin-top: 28px;
}

label:not(.check) {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

input:not([type="checkbox"]),
textarea,
select {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease;
}

input:not([type="checkbox"]),
select {
    min-height: 48px;
}

textarea {
    resize: vertical;
    min-height: 104px;
    max-height: 420px;
    line-height: 1.6;
}

#message {
    padding-right: 54px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgb(148 163 184 / 14%);
}

input::placeholder,
textarea::placeholder {
    color: #6b7686;
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

input[type="date"] {
    color-scheme: dark;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    font-weight: 400;
    cursor: pointer;
}

.check input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
    accent-color: var(--accent);
}

#profileForm > .primary {
    margin-top: 4px;
    width: 100%;
}

#modeNotice {
    margin-top: 20px;
    font-size: 12px;
}

.workspace-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.workspace-top h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 4vw, 36px);
}

.workspace-top .eyebrow {
    margin-bottom: 6px;
}

.topics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 0 0 4px;
}

.topic-button {
    position: relative;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    border-radius: 10px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.topic-button[aria-pressed="true"] {
    background: #f4f4f5;
    color: #0b0f14;
    border-color: #f4f4f5;
    font-weight: 650;
}

.topic-button:hover:not(:disabled) {
    border-color: #94a3b8;
    color: var(--text);
}

.topic-button[aria-pressed="true"]:hover:not(:disabled) {
    color: #0b0f14;
}

.topic-button.is-discussed::after {
    content: "✓";
    margin-left: 4px;
    font-size: 10px;
    font-weight: 700;
}

.topic-button[aria-pressed="true"].is-discussed::after {
    color: #0b0f14;
}

.topic-button.is-discussed:not([aria-pressed="true"])::after {
    color: var(--success, #a9e5c6);
}

@media (min-width: 420px) {
    .topic-button {
        font-size: 12px;
        padding: 6px 6px;
    }
}

.chat {
    padding: 0;
    overflow: visible;
}

/* Диалог растёт вниз естественно: без собственной прокрутки —
   страница скроллится единым скроллом (без «залипания» на мобильных).
   Высота по содержимому, обрезка запрещена; снизу запас, чтобы
   липкая панель ввода не перекрывала последнюю строку сообщения. */
#messages {
    height: auto;
    min-height: 260px;
    max-height: none;
    overflow: visible;
    padding: 26px 26px 40px;
}

.message {
    max-width: 92%;
    margin-bottom: 22px;
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.message:last-child {
    margin-bottom: 0;
}

.message-assistant {
    margin-right: auto;
    background: var(--surface-raised);
}

.message-user {
    margin-left: auto;
    background: #1a2028;
    border-color: #2f3b4a;
}

.message-author {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.message-content {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.75;
    font-size: 15px;
}

.chat-form {
    position: relative;
    z-index: 10;
    padding: 22px 26px;
    border-top: 1px solid #232b36;
    background: #11161d;
    gap: 10px;
}

.chat-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

#quota {
    font-size: 12px;
}

.chat > .small {
    padding: 0 26px 22px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

#offer {
    border-color: #2f3b4a;
    background: var(--surface);
}

#offer > label,
#offer > .actions {
    margin-top: 18px;
}

#paidPanel {
    border-color: #385b4c;
}

#paidPanel h2 {
    color: var(--success);
}

.tools h2 {
    margin-bottom: 8px;
}

details {
    padding: 19px 0;
    border-top: 1px solid var(--border);
}

details:first-of-type {
    margin-top: 16px;
}

details:last-child {
    padding-bottom: 0;
}

summary {
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    line-height: 1.5;
}

summary::marker {
    color: var(--muted);
}

details[open] > summary {
    margin-bottom: 18px;
}

details > p {
    color: var(--muted);
    font-size: 14px;
}

details form {
    margin: 18px 0;
}

.matrix {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    max-width: 430px;
    margin: 20px 0;
}

.matrix-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 88px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.matrix-label {
    color: var(--muted);
    font-size: 10px;
}

.matrix-cell strong {
    color: var(--accent);
    font-size: 20px;
    font-weight: 600;
    overflow-wrap: anywhere;
    letter-spacing: 0.03em;
}

pre {
    margin: 18px 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: #d4d4d8;
    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;
    font-size: 12px;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

pre:empty {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}

caption {
    padding: 0 0 12px;
    text-align: left;
    color: var(--muted);
    font-size: 12px;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    color: #e4e4e7;
    font-weight: 600;
}

td {
    color: var(--muted);
}

thead th {
    background: var(--surface-soft);
    font-size: 11px;
}

#lineList table {
    max-width: 600px;
}

#lineList td {
    text-align: right;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.table-scroll table {
    min-width: 620px;
}

.tool-result {
    margin-top: 20px;
}

.payment-panel {
    border-color: #3f4a5a;
}

.payment-panel button {
    margin-top: 12px;
}

.app-status {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 100;
    width: min(640px, calc(100% - 32px));
    transform: translateX(-50%);
    padding: 15px 18px;
    border: 1px solid #2f3b4a;
    border-radius: 14px;
    background: #171d26;
    color: #f4f4f5;
    box-shadow: 0 14px 45px rgb(0 0 0 / 45%);
    font-size: 13px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.app-status.error {
    border-color: #8b4a55;
    background: #301b23;
    color: var(--danger);
}

.app-status.success {
    border-color: #477862;
    background: #142b22;
    color: var(--success);
}

.legal-footer {
    width: min(940px, calc(100% - 48px));
    margin: 0 auto 32px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.legal-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 14px;
}

.legal-footer a {
    color: var(--muted);
    font-size: 11px;
}

.legal {
    width: min(820px, calc(100% - 40px));
    margin: 36px auto 80px;
}

.legal > a {
    display: inline-block;
    margin-bottom: 24px;
}

.legal h1 {
    font-size: clamp(28px, 5vw, 42px);
    margin-bottom: 34px;
}

.legal section {
    margin: 0 0 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.legal section h2 {
    margin-bottom: 12px;
    font-size: 19px;
}

.legal section p {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.is-busy .chat-form button[type="submit"] {
    cursor: progress;
}

@media (max-width: 700px) {
    .header {
        width: calc(100% - 32px);
        min-height: 80px;
        padding: 4px 0;
    }

    .header > .eyebrow {
        display: none;
    }

    .layout {
        width: calc(100% - 28px);
        margin-top: 24px;
        margin-bottom: 40px;
    }

    .card {
        padding: 22px;
        border-radius: 18px;
    }

    .intro {
        padding: 25px 22px;
    }

    .workspace-top {
        align-items: flex-start;
    }

    #deleteButton {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .chat {
        padding: 0;
    }

    #messages {
        padding: 18px;
    }

    .message {
        max-width: 97%;
        padding: 15px;
    }

    .message-content {
        font-size: 14px;
        line-height: 1.75;
    }

    .chat-form {
        padding: 18px;
    }

    .chat > .small {
        padding: 0 18px 18px;
    }

    .chat-bottom {
        align-items: flex-start;
    }

    .chat-bottom .primary {
        flex: 0 0 auto;
    }

    .topics {
        gap: 5px;
    }

    .topic-button {
        font-size: 11px;
        padding: 6px 4px;
    }

    .legal-footer {
        width: calc(100% - 32px);
    }

    .matrix-cell {
        min-height: 78px;
    }
}

@media (max-width: 600px) {
    .site-logo {
        height: 68px;
    }
}

@media (max-width: 420px) {
    .chat-bottom {
        flex-direction: column;
        gap: 12px;
    }

    .chat-bottom button {
        width: 100%;
    }

    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .actions button {
        width: 100%;
    }

    .workspace-top {
        flex-direction: column;
        gap: 14px;
    }

    h1 {
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    body {
        background: white;
        color: black;
    }

    .header,
    .topics,
    .chat-form,
    .legal-footer,
    #deleteButton,
    #offer,
    #paidPanel,
    .app-status,
    .tools {
        display: none !important;
    }

    .layout {
        width: 100%;
        margin: 0;
    }

    .card,
    .message {
        background: white;
        color: black;
        box-shadow: none;
        border-color: #cccccc;
    }

    #messages {
        max-height: none;
        overflow: visible;
    }

    .message-author,
    .message-content {
        color: black;
    }
}
/* амочки платных разделов и витрина аспорта */
details.is-locked > summary { cursor: pointer; opacity: .85; }
.advanced-analysis.is-locked { opacity: .8; cursor: pointer; }
.passport-teaser { min-height: 280px; }
.passport-teaser-lock .primary { max-width: 520px; white-space: normal; }
.date-filter { margin: 8px 0; }

/* Тонкие монохромные SVG-иконки замка вместо эмодзи 🔒 */
.lock-icon {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--muted);
}

.lock-icon svg {
    display: block;
}

/* Форматирование ответов ИИ: абзацы по \n\n в <p> с отступами
   и выравниванием по левому краю. */
.message-content p {
    margin: 0 0 12px;
    text-align: left;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Компактная шапка разбора вместо крупного заголовка. */
.profile-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 18px;
    font-size: 14px;
    color: var(--muted);
}

.profile-summary strong {
    color: var(--text);
    font-weight: 650;
}

.profile-summary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.profile-summary-actions button {
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.profile-summary-actions button:hover:not(:disabled) {
    color: var(--text);
    transform: none;
}

/* Заблокированные плашки дополнительных инструментов до оплаты. */
.tool-lock-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.tool-lock-row:hover:not(:disabled) {
    border-color: var(--platinum, #94a3b8);
    color: var(--text);
    transform: none;
}

.tool-lock-row + .tool-lock-row {
    margin-top: 10px;
}

.tool-lock-row .lock-icon {
    margin-left: auto;
}

/* Компактный спойлер «Посмотреть содержание 9 разделов Паспорта». */
.passport-sections-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.passport-sections-list li {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}

.passport-sections-list li strong {
    display: block;
    margin-bottom: 2px;
    color: var(--text);
}

/* Компактный аккордеон оплаты: короткие пункты вместо длинной простыни. */
.offer-points {
    display: grid;
    gap: 8px;
    margin: 14px 0;
    padding: 0;
    list-style: none;
}

.offer-points li {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    font-size: 14px;
    line-height: 1.5;
}

/* Плашка возврата к оплаченному разбору без кодов. */
.share-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.share-box .small {
    width: 100%;
    margin: 0;
}

@media (max-width: 700px) {
    .profile-summary {
        gap: 6px 12px;
        font-size: 13px;
    }
}


