:root {
    color-scheme: light;
    --ink: #16211d;
    --muted: #68756f;
    --paper: #f5f4ee;
    --card: #fffef9;
    --line: #dedfd7;
    --green: #176b50;
    --green-dark: #10513d;
    --green-soft: #e4f2eb;
    --red: #a4433e;
    --shadow: 0 18px 55px rgba(33, 48, 42, 0.10);
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; }

body {
    margin: 0;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 8%, rgba(183, 213, 194, 0.55), transparent 27rem),
        radial-gradient(circle at 92% 90%, rgba(225, 205, 159, 0.38), transparent 25rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 64px 0; }
.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(42px, 7vw, 70px); font-weight: 500; letter-spacing: -.045em; }
.subtitle { max-width: 590px; margin: 13px 0 0; color: var(--muted); font-size: 17px; line-height: 1.6; }
.status { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; margin-top: 12px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.65); }
.status span { width: 10px; height: 10px; border-radius: 50%; background: #c16a61; box-shadow: 0 0 0 4px rgba(193,106,97,.13); }
.status.online span { background: #36a675; box-shadow: 0 0 0 4px rgba(54,166,117,.13); }

.notice { margin: 0 0 18px; padding: 13px 16px; border-radius: 12px; font-size: 14px; }
.notice.success { border: 1px solid #b7dac7; background: var(--green-soft); color: var(--green-dark); }
.notice.error { border: 1px solid #e0b9b5; background: #f8eae8; color: #7d302c; }

.page-tabs { display: flex; gap: 6px; margin: 0 0 20px; padding: 5px; width: fit-content; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.68); }
.page-tab { display: flex; align-items: center; gap: 8px; padding: 10px 15px; border-radius: 10px; background: transparent; color: var(--muted); }
.page-tab:hover { transform: none; background: #edf0eb; color: var(--ink); }
.page-tab.active { background: var(--ink); color: white; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: #c16a61; }
.tab-dot.connected { background: #46bd83; box-shadow: 0 0 0 3px rgba(70,189,131,.14); }
.tab-count { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.15); font-size: 11px; }
.overflow-menu { position: relative; }
.menu-button { min-width: 42px; padding: 10px 13px; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.menu-button:hover, .menu-button[aria-expanded="true"] { transform: none; background: #edf0eb; color: var(--ink); }
.overflow-menu-list { position: absolute; z-index: 30; top: calc(100% + 9px); right: 0; min-width: 215px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 14px 35px rgba(33,48,42,.16); }
.overflow-menu-list[hidden] { display: none; }
.overflow-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 12px; background: transparent; color: var(--ink); text-align: left; }
.overflow-menu-item:hover, .overflow-menu-item.active { transform: none; background: var(--green-soft); color: var(--green-dark); }
.overflow-menu-link { border-radius: 12px; text-decoration: none; font-size: 14px; font-weight: 800; }
.overflow-user { display: grid; gap: 2px; margin-top: 5px; padding: 11px 12px 7px; border-top: 1px solid var(--line); }
.overflow-user small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; }
.overflow-logout button { width: 100%; padding: 9px 12px; background: transparent; color: var(--red); text-align: left; }
.overflow-logout button:hover { transform: none; background: #f8eae8; }
[data-tab-panel][hidden] { display: none !important; }
.mobile-tabbar, .settings-menu { display: none; }
.settings-menu[hidden] { display: none !important; }

.composer, .chat-panel, .dialogs-panel, .tasks-section, .habits-section, .integrations-panel, .profile-panel, .news-panel, .notifications-settings-panel { border: 1px solid rgba(211,214,205,.92); border-radius: 22px; background: rgba(255,254,249,.90); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.composer { padding: 24px; }
.composer label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 800; }
.input-row { display: flex; gap: 10px; }
input { width: 100%; min-width: 0; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: white; color: var(--ink); font: inherit; font-size: 16px; transition: border-color .2s, box-shadow .2s; }
input:focus { border-color: #65a78c; box-shadow: 0 0 0 4px rgba(23,107,80,.10); }
select { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); font: inherit; }
button { border: 0; border-radius: 12px; padding: 14px 19px; background: var(--green); color: white; font: inherit; font-size: 14px; font-weight: 800; white-space: nowrap; cursor: pointer; transition: transform .15s, background .15s; }
button:hover { background: var(--green-dark); transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.notification-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 22px; padding: 22px 24px; border-radius: 20px; background: var(--ink); color: white; box-shadow: var(--shadow); }
.notification-panel h2 { margin: 3px 0 7px; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.notification-panel button { background: #d9b86c; color: #1f2a25; }
.notification-panel button:hover { background: #e5c982; }
.panel-kicker { margin: 0; color: #a7cab9; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.notification-hint { margin: 0; color: #bdc8c2; font-size: 13px; }
.notification-hint.success { color: #9ce0bc; }
.notification-hint.error { color: #f1aaa3; }

.chat-panel { padding: 24px; }
.dialogs-panel { padding: 24px; }
.dialogs-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #f5f6f1; }
.conversation-list { display: flex; flex-direction: column; gap: 5px; padding: 10px; overflow-y: auto; border-right: 1px solid var(--line); background: #eef1ec; }
.conversation-item { display: grid; gap: 4px; width: 100%; padding: 11px; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; white-space: normal; }
.conversation-item:hover, .conversation-item.active { transform: none; background: white; color: var(--ink); }
.conversation-item strong, .conversation-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item strong { font-size: 13px; }
.conversation-item small { color: var(--muted); font-size: 10px; font-weight: 500; }
.conversation-view { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.conversation-toolbar { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.72); }
.conversation-toolbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-messages { display: flex; min-height: 350px; max-height: 530px; flex-direction: column; gap: 10px; overflow-y: auto; padding: 17px; }
.conversation-bubble { max-width: 78%; padding: 11px 13px; border-radius: 15px; background: white; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.conversation-bubble.user { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--green); color: white; }
.conversation-bubble.assistant { align-self: flex-start; border-bottom-left-radius: 4px; }
.conversation-bubble.loading { color: var(--muted); font-style: italic; }
.conversation-empty { display: grid; place-items: center; align-content: center; height: 100%; padding: 35px; color: var(--muted); text-align: center; }
.conversation-empty span { margin-bottom: 8px; color: var(--green); font-size: 28px; }
.conversation-empty strong { color: var(--ink); }
.conversation-empty p { max-width: 330px; margin: 6px 0 0; font-size: 12px; line-height: 1.5; }
.conversation-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 11px; border-top: 1px solid var(--line); background: white; }
.conversation-form input { padding: 12px 14px; }
.conversation-form button { padding: 11px 14px; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.chat-heading h2 { margin: 4px 0 0; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.panel-kicker.green { color: var(--green); }
.ghost { padding: 9px 12px; background: transparent; color: var(--muted); font-size: 12px; }
.ghost:hover { background: #edf0eb; color: var(--ink); }
.chat-messages { display: grid; gap: 12px; max-height: 420px; min-height: 170px; overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #f5f6f1; }
.chat-message { max-width: min(78%, 620px); }
.chat-message span { display: block; margin: 0 0 5px 3px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.chat-message p { margin: 0; padding: 12px 14px; border-radius: 14px; background: white; font-size: 15px; line-height: 1.5; white-space: pre-wrap; box-shadow: 0 3px 12px rgba(33,48,42,.05); }
.chat-message.user { justify-self: end; }
.chat-message.user span { text-align: right; }
.chat-message.user p { background: var(--green); color: white; border-bottom-right-radius: 4px; }
.chat-message.assistant { justify-self: start; }
.chat-message.assistant p { border-bottom-left-radius: 4px; }
.chat-message.loading p { color: var(--muted); font-style: italic; }
.chat-message.error p { border: 1px solid #e0b9b5; background: #f8eae8; color: #7d302c; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 12px; }
.chat-input-wrap { position: relative; min-width: 0; }
.chat-input-wrap input { padding-right: 54px; }
.voice-button { position: absolute; top: 50%; right: 7px; width: 40px; height: 40px; padding: 0; transform: translateY(-50%); border-radius: 50%; background: transparent; color: var(--green); }
.voice-button:hover { transform: translateY(-50%); background: var(--green-soft); }
.voice-button span { display: block; font-size: 17px; line-height: 1; }
.voice-button.listening { background: #f7dedb; color: var(--red); animation: voice-pulse 1.2s infinite; }
.voice-button:disabled { background: transparent; color: #aeb6b1; }
.voice-status { min-height: 18px; margin: 6px 2px 0; color: var(--muted); font-size: 12px; }
.voice-status.error { color: var(--red); }
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 7px rgba(164,67,62,.12); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.tasks-section { margin-top: 22px; padding: 24px; }
.tasks-section[data-tab-panel="planning"] { margin-top: 0; }
.habits-section { margin-top: 22px; padding: 24px; }
.integrations-panel { padding: 24px; }
.profile-panel { padding: 24px; }
.profile-form { display: grid; gap: 16px; }
.profile-form label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 800; }
.profile-form label small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; }
.profile-form button { width: fit-content; margin-top: 2px; }
.privacy-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.news-panel { padding: 24px; }
.notifications-settings-panel { padding: 24px; }
.notification-channel { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.channel-heading { display: flex; align-items: center; gap: 12px; }
.channel-heading > div:nth-child(2) { min-width: 0; }
.channel-heading h3 { margin: 0; font-size: 16px; }
.channel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.channel-icon { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 13px; background: #dff2ff; color: #1688c9; font-weight: 900; }
.channel-icon.max { background: #eee9ff; color: #6550c7; }
.channel-status { margin-left: auto; padding: 6px 9px; border-radius: 999px; background: #f1f2ef; color: var(--muted); font-size: 10px; font-weight: 800; }
.channel-status.on { background: var(--green-soft); color: var(--green-dark); }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.channel-actions button { padding: 9px 12px; }
.danger-button { background: transparent; color: var(--red); }
.activation-box { display: grid; gap: 10px; margin-top: 15px; padding: 14px; border-radius: 14px; background: var(--green-soft); }
.activation-box p, .activation-box small { margin: 0; }
.activation-box code { padding: 10px; border-radius: 9px; background: white; font-size: 16px; font-weight: 800; user-select: all; }
.activation-link { color: var(--green-dark); font-weight: 800; text-decoration: none; }
.channel-connect-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-top: 15px; }
.channel-connect-form label { display: grid; gap: 6px; font-size: 12px; font-weight: 750; }
.news-heading { align-items: center; }
.secondary-button { padding: 10px 14px; background: var(--green-soft); color: var(--green-dark); }
.secondary-button:hover { background: #d4e9de; }
.news-settings { margin-bottom: 22px; padding: 17px; border-radius: 16px; background: #f1f4ef; }
.news-settings h3 { margin: 0 0 4px; font-size: 16px; }
.news-settings p { margin: 0; color: var(--muted); font-size: 13px; }
.interest-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 14px; }
.interest-toggle { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; font-size: 13px; font-weight: 700; }
.interest-toggle input { width: 17px; height: 17px; min-width: 17px; margin: 0; accent-color: var(--green); }
.news-status { min-height: 18px; margin-top: 10px !important; color: var(--green) !important; }
.news-status.error { color: var(--red) !important; }
.news-meta { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.news-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.news-card { display: flex; flex-direction: column; min-height: 250px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.news-category { width: fit-content; padding: 5px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 10px; font-weight: 850; }
.news-card h3 { margin: 12px 0 10px; font-size: 17px; line-height: 1.35; }
.news-card ul { margin: 0 0 17px; padding-left: 19px; color: #47544e; font-size: 13px; line-height: 1.55; }
.news-card li + li { margin-top: 6px; }
.news-source { margin-top: auto; color: var(--green); font-size: 13px; font-weight: 800; text-decoration: none; }
.news-source:hover { text-decoration: underline; }
.news-empty { padding-block: 38px; }
.integrations-panel .section-heading h2 { margin-top: 4px; }
.settings-help { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.settings-form { display: grid; grid-template-columns: 1fr 1.4fr 1.2fr auto; align-items: end; gap: 10px; }
.settings-form.compact { grid-template-columns: 1fr auto; }
.settings-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.settings-form input { padding: 12px 13px; font-size: 14px; }
.integration-connected { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px; border-radius: 14px; background: var(--green-soft); }
.integration-connected small { display: block; margin-top: 4px; color: var(--muted); }
.integration-connected .delete, .contact-list .delete { padding: 8px 10px; background: transparent; color: var(--red); }
.contacts-block { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.contacts-block h3 { margin: 0 0 5px; font-size: 17px; }
.contact-form { grid-template-columns: 1fr 1.5fr auto; }
.contact-list { display: grid; gap: 7px; margin-top: 14px; }
.contact-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 13px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 2px 18px; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.section-heading span { color: var(--muted); font-size: 13px; }
.task-list { display: grid; gap: 10px; }
.task-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: white; transition: transform .15s, border-color .15s; }
.task-card:hover { transform: translateY(-1px); border-color: #bfcac2; }
.task-card.done { opacity: .62; }
.task-card.done h3 { text-decoration: line-through; }
.task-id { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; font-weight: 900; }
.task-content h3 { margin: 0 0 6px; font-size: 16px; font-weight: 750; }
.task-content time { color: var(--muted); font-size: 13px; }
.task-content small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.edit-details { margin-top: 9px; }
.edit-details summary { width: fit-content; color: var(--green); font-size: 12px; font-weight: 800; cursor: pointer; }
.inline-edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; padding: 12px; border-radius: 12px; background: #f4f6f2; }
.inline-edit-form label, .habit-create-form label, .habit-edit-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.inline-edit-form button { align-self: end; }
.actions { display: flex; align-items: center; gap: 7px; }
.actions form { margin: 0; }
.actions button { padding: 9px 12px; border-radius: 9px; font-size: 12px; }
.actions .secondary { background: var(--green-soft); color: var(--green-dark); }
.actions .delete { background: transparent; color: var(--red); }
.done-label { padding: 7px 10px; border-radius: 9px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; }
.empty-state { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 22px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); }
.empty-state p { margin: 0; }
.habit-create-form { display: grid; grid-template-columns: 1.5fr 1fr .7fr auto; align-items: end; gap: 10px; margin-bottom: 16px; padding: 15px; border-radius: 14px; background: var(--green-soft); }
.habit-create-form input, .habit-edit-form input { padding: 11px 12px; font-size: 14px; }
.habit-list { display: grid; gap: 10px; }
.habit-card { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.habit-card.inactive { opacity: .58; }
.habit-edit-form { display: grid; grid-template-columns: 1.5fr 1fr .7fr .8fr auto; align-items: end; gap: 9px; }
.habit-card .delete { padding: 10px; background: transparent; color: var(--red); }
.task-content small a { color: var(--green); text-decoration: none; }
.task-content small a:hover { text-decoration: underline; }

.auth-body { display: grid; place-items: center; padding: 24px; }
.auth-shell { width: min(460px, 100%); }
.auth-card, .admin-panel { border: 1px solid var(--line); border-radius: 24px; background: rgba(255,254,249,.94); box-shadow: var(--shadow); }
.auth-card { padding: clamp(25px, 6vw, 42px); }
.auth-card h1 { font-size: clamp(38px, 8vw, 54px); }
.auth-intro { margin: 14px 0 23px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 800; }
.auth-form button { margin-top: 4px; }
.auth-footer { margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.auth-footer a, .secondary-link { color: var(--green); font-weight: 800; text-decoration: none; }
.admin-shell { width: min(1080px, calc(100% - 32px)); }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.admin-panel { padding: 24px; }
.user-list { display: grid; gap: 10px; }
.user-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.user-card > div:first-child { display: grid; gap: 4px; }
.user-card span, .user-card small { color: var(--muted); font-size: 12px; }
.user-access { display: flex; align-items: center; gap: 12px; }
.user-access form { display: flex; gap: 7px; }
.user-access button { padding: 8px 10px; font-size: 12px; }
.user-access .delete { background: transparent; color: var(--red); }
.access-badge { padding: 6px 9px; border-radius: 999px; font-weight: 800; }
.access-badge.active { background: var(--green-soft); color: var(--green-dark); }
.access-badge.pending { background: #f4ead0; color: #765d21; }
.access-badge.blocked { background: #f8eae8; color: var(--red); }

@media (max-width: 700px) {
    .shell {
        width: 100%;
        padding: max(24px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
    }
    .hero { position: relative; flex-direction: column; gap: 12px; margin-bottom: 24px; padding-right: 36px; }
    h1 { font-size: clamp(42px, 14vw, 58px); line-height: .98; }
    .subtitle { font-size: 16px; line-height: 1.5; }
    .hero .status { position: absolute; top: 2px; right: 2px; }
    .status { margin-top: 0; }
    .input-row { flex-direction: column; }
    .notification-panel { align-items: stretch; flex-direction: column; gap: 17px; padding: 20px; }
    .notification-panel h2 { font-size: 23px; line-height: 1.15; }
    .notification-panel button { width: 100%; padding-inline: 12px; white-space: normal; }
    .composer, .chat-panel, .tasks-section, .habits-section, .integrations-panel, .profile-panel, .news-panel, .notifications-settings-panel { border-radius: 18px; }
    .chat-panel, .tasks-section, .habits-section, .integrations-panel, .profile-panel, .news-panel, .notifications-settings-panel { padding: 18px; }
    .chat-heading { align-items: flex-start; gap: 10px; }
    .chat-heading h2 { font-size: 25px; }
    .chat-messages { min-height: 150px; padding: 12px; }
    .chat-form { grid-template-columns: 1fr; }
    .chat-message { max-width: 96%; min-width: 0; }
    .chat-message p { overflow-wrap: anywhere; }
    .chat-form > button { width: 100%; }
    .task-card { grid-template-columns: 38px 1fr; }
    .actions { grid-column: 2; flex-wrap: wrap; }
    .settings-form, .settings-form.compact, .contact-form { grid-template-columns: 1fr; }
    .habit-create-form, .habit-edit-form, .inline-edit-form { grid-template-columns: 1fr; }
    .habit-card { grid-template-columns: 1fr; }
    .page-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) 46px;
        width: 100%;
        padding: 4px;
        overflow: visible;
    }
    .page-tab { justify-content: center; min-width: 0; padding: 10px 6px; font-size: 12px; }
    .page-tab .tab-count { min-width: 18px; height: 18px; padding-inline: 5px; }
    .overflow-menu { position: static; }
    .menu-button { width: 100%; min-width: 0; height: 100%; padding: 10px 8px; }
    .overflow-menu-list {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        left: 0;
        width: 100%;
        min-width: 0;
        max-height: min(70vh, 430px);
        overflow-y: auto;
    }
    .interest-list, .news-grid { grid-template-columns: 1fr; }
    .news-heading { align-items: flex-start; flex-direction: column; }
    .admin-heading, .user-card, .user-access { align-items: stretch; flex-direction: column; }
    .user-access form { flex-wrap: wrap; }
}

@media (min-width: 701px) {
    .settings-menu { position: fixed; z-index: 300; inset: 0; display: block; }
    .settings-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; background: rgba(8,17,13,.32); }
    .settings-backdrop:hover { transform: none; background: rgba(8,17,13,.32); }
    .settings-sheet { position: absolute; top: 50%; left: 50%; width: min(440px, calc(100% - 40px)); max-height: 80vh; overflow-y: auto; padding: 24px; border-radius: 24px; background: #fffefb; box-shadow: var(--shadow); transform: translate(-50%, -50%); }
    .sheet-handle { display: none; }
    .sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
    .sheet-heading h2 { margin: 3px 0 0; }
    .sheet-close { width: 38px; height: 38px; padding: 0; border-radius: 50%; background: #edf0eb; color: var(--ink); font-size: 24px; }
    .settings-links { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; }
    .settings-link { display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 11px; width: 100%; padding: 12px; border-radius: 0; border-bottom: 1px solid var(--line); background: white; color: var(--ink); text-align: left; text-decoration: none; white-space: normal; }
    .settings-link:last-child { border-bottom: 0; }
    .settings-link-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--green-soft); color: var(--green-dark); }
    .settings-link > span:nth-child(2) { display: grid; gap: 2px; }
    .settings-link small { color: var(--muted); }
    .settings-link b { color: #9ba49f; font-size: 22px; }
    .sheet-account { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 15px; padding: 13px; border-radius: 14px; background: #eff2ed; }
    .sheet-account > div { display: grid; gap: 2px; min-width: 0; }
    .sheet-account small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
    .sheet-account button { padding: 8px 10px; background: transparent; color: var(--red); }
}

@media (max-width: 430px) {
    .page-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)) 42px; }
    .page-tab { gap: 4px; font-size: 11px; }
    .page-tab .tab-count { display: none; }
    .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
    .actions { align-items: stretch; flex-direction: column; }
    .actions form, .actions button { width: 100%; }
}

/* Новый мобильный интерфейс: отдельная компоновка, а не уменьшенная версия десктопа. */
@media (max-width: 700px) {
    :root {
        --mobile-gutter: 16px;
        --mobile-radius: 22px;
        --mobile-tabbar-height: 64px;
    }

    body {
        min-height: 100dvh;
        padding-bottom: calc(var(--mobile-tabbar-height) + env(safe-area-inset-bottom) + 18px);
        background: #f3f4ef;
        -webkit-text-size-adjust: 100%;
    }
    body.menu-open { overflow: hidden; touch-action: none; }

    .shell {
        width: 100%;
        max-width: none;
        padding: 0 var(--mobile-gutter) 24px;
    }

    .hero {
        min-height: auto;
        margin: 0 calc(-1 * var(--mobile-gutter)) 16px;
        padding: calc(22px + env(safe-area-inset-top)) 52px 24px var(--mobile-gutter);
        border-bottom: 1px solid rgba(22, 33, 29, .08);
        background: linear-gradient(140deg, #e0eee5 0%, #f7f6f1 78%);
    }
    .hero .eyebrow { margin-bottom: 5px; font-size: 11px; }
    .hero h1 { font-family: inherit; font-size: 29px; font-weight: 850; line-height: 1.12; letter-spacing: -.035em; }
    .hero .subtitle { max-width: 340px; margin-top: 8px; font-size: 14px; line-height: 1.42; }
    .hero .status { top: calc(24px + env(safe-area-inset-top)); right: 18px; width: 24px; height: 24px; }
    body:not([data-active-tab="main"]) .hero { padding-bottom: 14px; }
    body:not([data-active-tab="main"]) .hero .eyebrow,
    body:not([data-active-tab="main"]) .hero .subtitle { display: none; }
    body:not([data-active-tab="main"]) .hero h1 { font-size: 21px; }

    .desktop-tabs { display: none; }
    .mobile-tabbar {
        position: fixed;
        z-index: 100;
        right: 10px;
        bottom: 8px;
        left: 10px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: var(--mobile-tabbar-height);
        padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
        border: 1px solid rgba(22, 33, 29, .12);
        border-radius: 22px;
        background: rgba(255, 255, 252, .94);
        box-shadow: 0 12px 35px rgba(22, 33, 29, .18);
        -webkit-backdrop-filter: blur(22px);
        backdrop-filter: blur(22px);
    }
    .mobile-tab {
        display: flex;
        min-width: 0;
        min-height: 50px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
        padding: 5px 2px;
        border-radius: 16px;
        background: transparent;
        color: #728078;
        font-size: 10px;
        font-weight: 750;
        line-height: 1.1;
    }
    .mobile-tab:hover { transform: none; background: transparent; color: #728078; }
    .mobile-tab.active { background: var(--green-soft); color: var(--green-dark); }
    .mobile-tab-icon { height: 22px; font-size: 20px; font-weight: 800; line-height: 20px; }

    .settings-menu {
        position: fixed;
        z-index: 300;
        inset: 0;
        display: block;
    }
    .settings-backdrop {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border-radius: 0;
        background: rgba(8, 17, 13, .38);
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
    }
    .settings-backdrop:hover { transform: none; background: rgba(8, 17, 13, .38); }
    .settings-sheet {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        max-height: min(82dvh, 680px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 9px 18px calc(20px + env(safe-area-inset-bottom));
        border-radius: 26px 26px 0 0;
        background: #fffefb;
        box-shadow: 0 -20px 60px rgba(22, 33, 29, .22);
        animation: sheet-in .2s ease-out;
    }
    @keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } }
    .sheet-handle { width: 42px; height: 5px; margin: 0 auto 14px; border-radius: 999px; background: #d0d4cf; }
    .sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
    .sheet-heading h2 { margin: 2px 0 0; font-size: 27px; }
    .sheet-close { width: 38px; height: 38px; padding: 0; border-radius: 50%; background: #edf0eb; color: var(--ink); font-size: 25px; font-weight: 400; }
    .sheet-close:hover { transform: none; background: #e3e7e1; }
    .settings-links { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: white; }
    .settings-link {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) auto auto;
        width: 100%;
        min-height: 66px;
        align-items: center;
        gap: 11px;
        padding: 10px 13px;
        border-radius: 0;
        border-bottom: 1px solid var(--line);
        background: white;
        color: var(--ink);
        text-align: left;
        text-decoration: none;
        white-space: normal;
    }
    .settings-link:last-child { border-bottom: 0; }
    .settings-link:hover { transform: none; background: #f7f8f4; }
    .settings-link-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green-soft); color: var(--green-dark); font-size: 19px; }
    .settings-link > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
    .settings-link strong { font-size: 14px; }
    .settings-link small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
    .settings-link b { color: #9ba49f; font-size: 24px; font-weight: 400; }
    .settings-link i { justify-self: end; }
    .sheet-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 14px; border-radius: 17px; background: #eff2ed; }
    .sheet-account > div { display: grid; min-width: 0; gap: 2px; }
    .sheet-account small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
    .sheet-account button { padding: 9px 12px; background: transparent; color: var(--red); }

    .notice { margin: 12px 0; }
    .notification-panel,
    .chat-panel,
    .dialogs-panel,
    .tasks-section,
    .habits-section,
    .integrations-panel,
    .profile-panel,
    .news-panel {
        width: 100%;
        margin: 0 0 14px;
        padding: 18px;
        border-radius: var(--mobile-radius);
        box-shadow: 0 7px 22px rgba(33, 48, 42, .07);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .notifications-settings-panel { width: 100%; margin: 0 0 14px; padding: 18px; border-radius: var(--mobile-radius); box-shadow: 0 7px 22px rgba(33,48,42,.07); }
    .notification-channel { padding: 14px; }
    .channel-heading { align-items: flex-start; }
    .channel-status { max-width: 92px; text-align: center; }
    .channel-actions { display: grid; grid-template-columns: 1fr; }
    .channel-actions form, .channel-actions button { width: 100%; }
    .channel-connect-form { grid-template-columns: 1fr; }

    .section-heading { display: flex; align-items: flex-start; flex-direction: row; gap: 10px; padding: 0 0 16px; }
    .section-heading > div { min-width: 0; }
    .section-heading h2 { margin-top: 2px; font-family: inherit; font-size: 25px; font-weight: 850; letter-spacing: -.025em; }
    .section-heading > span { flex: 0 0 auto; padding-top: 4px; font-size: 12px; }
    .panel-kicker { font-size: 10px; letter-spacing: .1em; }

    .notification-panel { gap: 16px; background: #14251e; }
    .notification-panel h2 { margin-top: 5px; font-family: inherit; font-size: 21px; font-weight: 820; }
    .notification-panel button { min-height: 48px; }

    .chat-heading { margin-bottom: 14px; }
    .chat-heading h2 { font-family: inherit; font-size: 24px; font-weight: 850; }
    .chat-heading .ghost { padding: 7px 5px; font-size: 11px; }
    .chat-messages { max-height: 48dvh; min-height: 230px; padding: 11px; border: 0; border-radius: 16px; }
    .chat-message { max-width: 92%; }
    .chat-message p { padding: 11px 12px; font-size: 14px; line-height: 1.45; }
    .chat-form { position: relative; display: block; margin-top: 10px; }
    .chat-input-wrap input { min-height: 52px; padding: 12px 50px 12px 14px; font-size: 16px; }
    .chat-form > #chat-submit { width: 100%; min-height: 46px; margin-top: 8px; }

    .dialogs-panel { padding: 14px; }
    .dialogs-panel .section-heading { align-items: center; }
    .dialogs-panel .section-heading button { width: auto; padding: 9px 11px; }
    .dialogs-layout { display: grid; grid-template-columns: 1fr; min-height: calc(100dvh - 205px); border: 0; background: transparent; }
    .conversation-list { display: flex; height: auto; flex-direction: row; gap: 7px; padding: 0 0 10px; overflow-x: auto; border: 0; background: transparent; scrollbar-width: none; }
    .conversation-list::-webkit-scrollbar { display: none; }
    .conversation-item { flex: 0 0 150px; padding: 9px 10px; border: 1px solid var(--line); background: #f2f4ef; }
    .conversation-item.active { border-color: #b7d8c7; background: var(--green-soft); }
    .conversation-view { min-height: calc(100dvh - 300px); overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #f5f6f1; }
    .conversation-messages { min-height: 300px; max-height: calc(100dvh - 370px); padding: 12px; }
    .conversation-bubble { max-width: 91%; font-size: 14px; }
    .conversation-form { grid-template-columns: minmax(0, 1fr) auto; padding: 8px; }
    .conversation-form input { min-height: 46px; font-size: 16px; }
    .conversation-form button { padding-inline: 11px; font-size: 12px; }

    .task-list { gap: 10px; }
    .task-card {
        position: relative;
        display: block;
        min-width: 0;
        padding: 16px;
        border-radius: 18px;
    }
    .task-id { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 10px; font-size: 11px; }
    .task-content { min-width: 0; padding-right: 36px; }
    .task-content h3 { margin-bottom: 7px; font-size: 16px; line-height: 1.32; overflow-wrap: anywhere; }
    .task-content time { display: inline-block; padding: 5px 8px; border-radius: 8px; background: #f1f3ef; color: #536159; font-size: 12px; font-weight: 750; }
    .edit-details summary { padding: 8px 0 2px; }
    .inline-edit-form { padding: 10px; }
    .actions { display: grid; grid-template-columns: 1fr auto; grid-column: auto; gap: 7px; margin-top: 13px; padding-top: 12px; border-top: 1px solid #eceee9; }
    .actions form, .actions button { width: 100%; }
    .actions .delete { width: auto; }

    .habit-create-form { display: grid; gap: 11px; margin: 0 0 14px; padding: 14px; border-radius: 17px; }
    .habit-create-form label, .habit-edit-form label, .inline-edit-form label { font-size: 12px; }
    .habit-create-form input, .habit-edit-form input, .inline-edit-form input, select { min-height: 46px; font-size: 16px; }
    .habit-create-form button { width: 100%; min-height: 46px; }
    .habit-card { display: block; padding: 13px; }
    .habit-edit-form { display: grid; gap: 10px; }
    .habit-card > form:last-child button { width: 100%; margin-top: 8px; }

    .profile-form button, .settings-form button, .contact-form button { width: 100%; min-height: 46px; }
    .profile-form input, .settings-form input, .contact-form input { font-size: 16px; }
    .integration-connected { align-items: stretch; flex-direction: column; }
    .integration-connected button { width: 100%; }
    .contact-list > div { align-items: flex-start; flex-direction: column; overflow-wrap: anywhere; }

    .news-heading { align-items: stretch; }
    .news-heading button { width: 100%; }
    .news-settings { padding: 14px; }
    .interest-toggle { align-items: flex-start; font-size: 12px; line-height: 1.35; }
    .news-card { min-height: 0; padding: 15px; }
    .news-card h3 { font-size: 16px; }

    input, select, button { max-width: 100%; }
    input, select { font-size: 16px; }
}
