/* ============================================================
   Veyo Tracker — палитра Aurora, мобильный интерфейс Telegram
   ============================================================ */

:root {
    --bg: #EFF5FB;
    --bg-2: #E4EFF9;
    --surface: #FFFFFF;
    --surface-2: #F4F8FC;
    --text: #12283E;
    --muted: #6C879F;
    --border: #E1EBF4;
    --primary: #1E9BF0;
    --primary-2: #3FC8F5;
    --primary-soft: rgba(30, 155, 240, 0.12);
    --success: #16B981;
    --success-soft: rgba(22, 185, 129, 0.12);
    --danger: #F0644B;
    --danger-soft: rgba(240, 100, 75, 0.12);

    --shadow: 0 6px 20px rgba(20, 90, 150, 0.08);
    --shadow-lg: 0 14px 36px rgba(20, 90, 150, 0.18);
    --scrim: rgba(11, 30, 48, 0.45);

    --r-card: 18px;
    --r-md: 14px;
    --r-sm: 10px;
    --r-pill: 999px;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --t: 0.2s ease;

    --tabbar-h: 62px;
}

[data-theme="dark"] {
    --bg: #0D1724;
    --bg-2: #0A1220;
    --surface: #162434;
    --surface-2: #1D2E42;
    --text: #E9F2FA;
    --muted: #8AA3BC;
    --border: #23374C;
    --primary: #35A9F5;
    --primary-2: #5CD3FF;
    --primary-soft: rgba(53, 169, 245, 0.18);
    --success: #22C48D;
    --success-soft: rgba(34, 196, 141, 0.18);
    --danger: #F57A62;
    --danger-soft: rgba(245, 122, 98, 0.18);

    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    --scrim: rgba(3, 9, 16, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif,
        'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
    background: var(--bg);
    background-image: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--t), color var(--t);
}

button,
input,
select,
textarea {
    font-family: inherit;
    color: inherit;
}

body.modal-open {
    overflow: hidden;
}

/* атрибут hidden должен побеждать любые display: flex/grid ниже по файлу */
[hidden] {
    display: none !important;
}

.icon-sprite {
    display: none;
}

/* иконки: обводка, без заливки — единый стиль всего интерфейса */
.ico {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 16px calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Верхняя строка ---------- */
.topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.topline-date {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topline-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 5px 11px 5px 9px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow);
}

.streak-chip .ico {
    width: 16px;
    height: 16px;
    color: #F5A524;
    fill: rgba(245, 165, 36, 0.18);
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: color var(--t), border-color var(--t), transform var(--t);
}

.icon-btn .ico {
    width: 17px;
    height: 17px;
}

.icon-btn:active {
    transform: scale(0.93);
}

/* ---------- Блок дня ---------- */
.hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 17px 18px;
    margin-bottom: 22px;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-2) 0%, var(--primary) 100%);
    box-shadow: var(--shadow-lg);
}

.hero-main {
    flex: 1;
    min-width: 0;
}

.hero-num {
    font-size: 29px;
    font-weight: 800;
    letter-spacing: -0.6px;
    line-height: 1.05;
}

.hero-sub {
    font-size: 13px;
    opacity: 0.92;
    margin-top: 3px;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 11.5px;
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    border: 0;
    border-radius: var(--r-pill);
    padding: 4px 9px;
    cursor: pointer;
    transition: background var(--t), transform var(--t);
}

.hero-chip .ico {
    width: 14px;
    height: 14px;
}

.hero-chip b {
    font-weight: 700;
}

.hero-chip:active {
    transform: scale(0.96);
}

.hero-chip-static {
    background: rgba(255, 255, 255, 0.13);
    cursor: default;
}

.hero-ring {
    width: 68px;
    height: 68px;
    flex: none;
}

.ring-track,
.ring-value {
    fill: none;
    stroke-width: 4.5;
}

.ring-track {
    stroke: rgba(255, 255, 255, 0.28);
}

.ring-value {
    stroke: #fff;
    stroke-linecap: round;
    stroke-dasharray: 113.1;
    stroke-dashoffset: 113.1;
    transition: stroke-dashoffset 0.7s var(--ease);
}

.ring-text {
    fill: #fff;
    font-size: 12.5px;
    font-weight: 700;
}

/* ---------- Секции ---------- */
.main {
    display: flex;
    flex-direction: column;
}

.section {
    margin-bottom: 26px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 0 2px 11px;
}

.section-head h2 {
    font-size: 16.5px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.section-sub {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
}

.habits-list,
.plans-list,
.plan {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Карточка задачи + свайп ---------- */
.swipe {
    position: relative;
    border-radius: var(--r-card);
    overflow: hidden;
    animation: cardIn 0.32s var(--ease) both;
}

.swipe-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-radius: var(--r-card);
    background: linear-gradient(90deg, var(--success) 0%, var(--success) 50%, var(--danger) 50%, var(--danger) 100%);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.swipe.swiping .swipe-bg {
    opacity: 1;
}

.swipe-bg .ico {
    width: 22px;
    height: 22px;
    stroke-width: 2.2;
}

.habit-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 14px;
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    cursor: pointer;
    overflow: hidden;
    touch-action: pan-y;
    transition: transform 0.28s var(--ease), background-color var(--t), box-shadow var(--t);
}

.swipe.dragging .habit-card {
    transition: none;
}

/* полоса прогресса периода по нижней кромке карточки */
.habit-card::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: var(--pct, 0%);
    background: var(--c, var(--primary));
    border-radius: 0 3px 3px 0;
    opacity: 0.9;
    transition: width 0.5s var(--ease);
}

.habit-card.no-progress::after {
    display: none;
}

.habit-card:active {
    background: var(--surface-2);
}

.habit-emoji {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    line-height: 1;
    background: var(--c-soft, var(--primary-soft));
}

.habit-emoji.no-emoji {
    background: none;
}

.habit-emoji.no-emoji::before {
    content: '';
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--c, var(--primary));
}

.habit-info {
    flex: 1;
    min-width: 0;
}

.habit-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-meta .ico {
    width: 13px;
    height: 13px;
}

.habit-meta .sep {
    opacity: 0.45;
}

.habit-card.completed .habit-name {
    color: var(--muted);
}

.habit-card.finished {
    opacity: 0.75;
}

.btn-check {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--t), border-color var(--t), color var(--t), transform 0.18s var(--ease);
}

.btn-check .ico {
    width: 18px;
    height: 18px;
    stroke-width: 2.6;
}

.btn-check:active {
    transform: scale(0.9);
}

.btn-check.checked {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    animation: pop 0.32s var(--ease);
}

.btn-check:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- Группа плана в списке задач ---------- */
.plan-group {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: cardIn 0.32s var(--ease) both;
}

.plan-group-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px 11px;
}

.plan-group-emoji {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
    background: var(--c-soft, var(--primary-soft));
}

.plan-group-name {
    flex: 1;
    min-width: 0;
    font-size: 14.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pct-badge {
    flex: none;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--c, var(--primary));
    background: var(--c-soft, var(--primary-soft));
    border-radius: var(--r-pill);
    padding: 3px 9px;
}

.plan-group-items .swipe {
    border-radius: 0;
    animation: none;
}

.plan-group-items .habit-card {
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--border);
}

.plan-group-items .swipe-bg {
    border-radius: 0;
}

/* ---------- Лента «План на период» ---------- */
.plan-strip {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    padding: 12px 0 12px 14px;
    animation: cardIn 0.32s var(--ease) both;
}

.plan-strip-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 14px;
    margin-bottom: 10px;
}

.plan-strip-emoji {
    font-size: 15px;
    line-height: 1;
    flex: none;
}

.plan-strip-emoji.no-emoji {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c, var(--primary));
}

.plan-strip-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-strip-to {
    flex: none;
    font-size: 11.5px;
    color: var(--muted);
}

.plan-cells {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 2px 14px 4px 0;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.plan-cells::-webkit-scrollbar {
    height: 4px;
}

.plan-cells::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.plan-cell {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: transform 0.18s var(--ease), background-color var(--t), color var(--t);
}

.plan-cell:active {
    transform: scale(0.88);
}

.plan-cell.done {
    background: var(--c, var(--primary));
    border-color: transparent;
    color: #fff;
}

.plan-cell.today {
    box-shadow: 0 0 0 2px var(--primary);
}

.plan-cell.future {
    border-style: dashed;
    opacity: 0.7;
}

.plan-cell.week-end {
    margin-right: 7px;
}

/* группа плана в ленте */
.plan-strip-group {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: cardIn 0.32s var(--ease) both;
}

.plan-strip-group .plan-strip {
    background: none;
    box-shadow: none;
    border-radius: 0;
    border-top: 1px solid var(--border);
    animation: none;
}

.plan-strip-group-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
}

.plan-strip-group-head .name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Вкладка «Планы» ---------- */
.plan-card {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: cardIn 0.32s var(--ease) both;
}

.plan-card-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px 14px 10px;
}

.plan-card-emoji {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    line-height: 1;
    background: var(--c-soft, var(--primary-soft));
}

.plan-card-title {
    flex: 1;
    min-width: 0;
}

.plan-card-name {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-card-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.plan-card-actions {
    display: flex;
    gap: 4px;
    flex: none;
}

.mini-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    border: 0;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--t), color var(--t);
}

.mini-btn .ico {
    width: 17px;
    height: 17px;
}

.mini-btn:active {
    background: var(--surface-2);
}

.mini-btn.danger:active {
    color: var(--danger);
    background: var(--danger-soft);
}

.plan-card-bar {
    height: 4px;
    margin: 0 14px 12px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.plan-card-bar span {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--c, var(--primary));
    transition: width 0.5s var(--ease);
}

.plan-items {
    border-top: 1px solid var(--border);
}

.plan-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.plan-item-emoji {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    background: var(--surface-2);
}

.plan-item-info {
    flex: 1;
    min-width: 0;
}

.plan-item-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-item.done .plan-item-name {
    color: var(--muted);
}

.plan-item-sub {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 1px;
}

.plan-item-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
}

.plan-item-check {
    width: 32px;
    height: 32px;
    flex: none;
    margin-left: 4px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--t), border-color var(--t), color var(--t), transform 0.18s var(--ease);
}

.plan-item-check .ico {
    width: 15px;
    height: 15px;
    stroke-width: 2.6;
}

.plan-item-check.checked {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.plan-item-check:active {
    transform: scale(0.9);
}

.plan-add-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 13px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--t);
}

.plan-add-item .ico {
    width: 16px;
    height: 16px;
}

.plan-add-item:active {
    background: var(--surface-2);
}

/* ---------- Пустые состояния ---------- */
.empty-state {
    text-align: center;
    padding: 34px 20px;
    color: var(--muted);
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
}

.empty-state p {
    font-size: 13.5px;
    max-width: 260px;
    margin: 0 auto;
}

.empty-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    box-shadow: 0 8px 20px var(--primary-soft);
    cursor: pointer;
    transition: transform 0.2s var(--ease);
}

.empty-icon .ico {
    width: 26px;
    height: 26px;
    stroke-width: 2.2;
}

.empty-icon:active {
    transform: scale(0.94);
}

/* ---------- Нижняя навигация ---------- */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 8px;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    /* на широком экране кнопки держатся у центра, а не разъезжаются по краям */
    padding: 0 max(26px, calc((100% - 460px) / 2)) env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--border);
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 74px;
    padding: 6px 4px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--t);
}

.tab .ico {
    width: 22px;
    height: 22px;
}

.tab.active {
    color: var(--primary);
}

.fab {
    width: 54px;
    height: 54px;
    flex: none;
    margin-bottom: 18px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    box-shadow: 0 8px 22px rgba(30, 155, 240, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s var(--ease), box-shadow var(--t);
}

.fab .ico {
    width: 26px;
    height: 26px;
    stroke-width: 2.4;
}

.fab:active {
    transform: scale(0.92);
}

.app-version {
    text-align: right;
    padding: 6px 2px 0;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.5;
    user-select: none;
}

/* ---------- Модальные окна (bottom sheet) ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease, background-color 0.28s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform 0.4s var(--ease);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.sheet-handle {
    width: 38px;
    height: 4px;
    margin: 4px auto 12px;
    border-radius: 2px;
    background: var(--border);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.btn-close {
    width: 32px;
    height: 32px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color var(--t), background-color var(--t);
}

.btn-close .ico {
    width: 16px;
    height: 16px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

/* ---------- Формы ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group > label:not(.switch-row) {
    display: block;
    margin-bottom: 9px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--muted);
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 15px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-error {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--danger);
}

.btn-primary {
    border: 0;
    border-radius: var(--r-md);
    padding: 11px 20px;
    font-size: 14.5px;
    font-weight: 650;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    box-shadow: 0 6px 18px rgba(30, 155, 240, 0.3);
    cursor: pointer;
    transition: transform 0.18s var(--ease), box-shadow var(--t);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.99);
}

.btn-full {
    display: block;
    width: 100%;
    padding: 15px;
    font-size: 15.5px;
}

.btn-cancel,
.btn-danger {
    border: 0;
    border-radius: var(--r-md);
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--t);
}

.btn-cancel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

/* действия внутри модалки редактирования */
.modal-actions {
    display: flex;
    gap: 8px;
    margin: -6px 0 20px;
}

.ghost-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--t), color var(--t), background-color var(--t);
}

.ghost-btn .ico {
    width: 16px;
    height: 16px;
}

.ghost-btn.danger {
    color: var(--danger);
}

.ghost-btn.danger:active {
    background: var(--danger-soft);
    border-color: var(--danger);
}

/* ---------- Чипы (пресеты периода, времени) ---------- */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chip-row-center {
    justify-content: center;
}

.chip {
    flex: 1 0 auto;
    min-width: 58px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--t), color var(--t), background-color var(--t);
}

.chip[data-selected="true"],
.chip.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

/* ---------- Эмодзи и цвета ---------- */
.emoji-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.emoji-picker {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.emoji-picker::-webkit-scrollbar {
    display: none;
}

.emoji-btn,
.p-emoji-btn,
.i-emoji-btn {
    width: 46px;
    height: 46px;
    flex: none;
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: border-color var(--t), background-color var(--t), transform 0.18s var(--ease);
}

.emoji-btn.selected,
.p-emoji-btn.selected,
.i-emoji-btn.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.no-emoji-btn {
    position: relative;
}

.no-emoji-btn::after {
    content: '';
    width: 17px;
    height: 17px;
    border: 2px solid var(--muted);
    border-radius: 4px;
}

.no-emoji-btn::before {
    content: '';
    position: absolute;
    width: 23px;
    height: 2px;
    border-radius: 1px;
    background: var(--muted);
    transform: rotate(-45deg);
}

.emoji-input {
    width: 100%;
    height: 50px;
    border: 2px dashed var(--border);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 20px;
    text-align: center;
    outline: none;
    padding: 0;
    transition: border-color var(--t);
}

.emoji-input:focus {
    border-style: solid;
    border-color: var(--primary);
}

.emoji-input::placeholder {
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
}

.color-btn,
.p-color-btn {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    border: 3px solid transparent;
    background: var(--c);
    cursor: pointer;
    transition: transform 0.18s var(--ease), box-shadow var(--t);
}

.color-btn.selected,
.p-color-btn.selected {
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c);
}

/* ---------- Период ---------- */
.period-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 13px;
    padding: 13px 15px;
    border-radius: var(--r-md);
    border: 1px solid var(--primary);
    background: var(--primary-soft);
    cursor: pointer;
    transition: box-shadow var(--t);
}

.period-display-soft {
    border-color: var(--border);
    background: var(--surface-2);
}

.period-value {
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -0.4px;
    color: var(--primary);
}

.period-display-soft .period-value {
    font-size: 17px;
    font-weight: 650;
    color: var(--text);
}

.period-label {
    margin-left: auto;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
}

.period-slider {
    width: 100%;
    height: 5px;
    margin-bottom: 14px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.period-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(30, 155, 240, 0.4);
    cursor: pointer;
}

.period-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

#periodGroup.no-period-active .period-slider,
#periodGroup.no-period-active #periodPresets {
    display: none;
}

#periodGroup.no-period-active .period-display {
    cursor: default;
    border-color: var(--border);
    background: var(--surface-2);
}

#periodGroup.no-period-active .period-value {
    color: var(--text);
}

/* переключатель «Без периода» */
.switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
}

.switch-text {
    flex: 1;
    font-size: 14px;
}

.switch-text small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.switch-row input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch {
    position: relative;
    width: 44px;
    height: 26px;
    flex: none;
    border-radius: var(--r-pill);
    background: var(--border);
    transition: background-color var(--t);
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.22s var(--ease);
}

.switch-row input:checked ~ .switch {
    background: var(--primary);
}

.switch-row input:checked ~ .switch::after {
    transform: translateX(18px);
}

/* ---------- Таймпикер ---------- */
.time-body {
    padding-bottom: 4px;
}

.time-wheel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 14px 0 16px;
}

.time-wheel::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 44px;
    transform: translate(-50%, -50%);
    border-radius: var(--r-md);
    background: var(--primary-soft);
    pointer-events: none;
}

.wheel-col {
    width: 84px;
    height: 176px;
    padding: 66px 0;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
    mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.wheel-col::-webkit-scrollbar {
    display: none;
}

.wheel-item {
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    scroll-snap-align: center;
    transition: color 0.15s ease, font-size 0.15s ease;
}

.wheel-item.selected {
    color: var(--text);
    font-size: 19px;
    font-weight: 700;
}

.wheel-colon {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.time-manual {
    display: flex;
    gap: 10px;
    align-items: center;
}

.time-manual input {
    flex: 1;
    min-width: 0;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
}

/* ---------- История ---------- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 58vh;
    overflow-y: auto;
    padding-bottom: 4px;
}

.history-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.history-emoji {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    background: var(--surface);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.history-empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--muted);
    font-size: 13.5px;
}

/* ---------- Подтверждение и ввод периода ---------- */
.confirm-overlay,
.period-input-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.period-input-overlay {
    z-index: 1300;
}

.confirm-overlay.active,
.period-input-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirm-box,
.period-input-box {
    width: 100%;
    max-width: 330px;
    padding: 22px;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    transform: translateY(14px) scale(0.97);
    transition: transform 0.32s var(--ease);
}

.confirm-overlay.active .confirm-box,
.period-input-overlay.active .period-input-box {
    transform: none;
}

.confirm-text {
    font-size: 15px;
    line-height: 1.45;
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.period-input-box h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.period-input-hint {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.period-input-field {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 15px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
}

.period-input-field:focus {
    border-color: var(--primary);
}

.period-input-result {
    min-height: 18px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Перенос задачи в план ---------- */
.move-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--scrim);
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.move-overlay.active {
    opacity: 1;
}

.move-hint {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 18px);
    left: 50%;
    z-index: 62;
    max-width: 92vw;
    padding: 10px 20px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s var(--ease);
}

.move-overlay.active .move-hint {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.move-hint-text {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.move-hint-cancel {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--muted);
}

body.move-mode .plan-group {
    position: relative;
    z-index: 61;
    transition: transform 0.35s var(--ease), box-shadow 0.35s ease;
}

body.move-mode .plan-group:not(.chosen) {
    box-shadow: 0 0 0 2px var(--c, var(--primary)), 0 12px 36px rgba(0, 0, 0, 0.35);
    transform: translateY(-3px) scale(1.012);
    cursor: pointer;
}

body.move-mode .plan-group.chosen {
    animation: planChosen 0.8s var(--ease) both;
}

body.move-mode .swipe.leaving {
    opacity: 0.15;
    transform: translateX(-26px) scale(0.96);
    transition: opacity 0.38s ease, transform 0.38s var(--ease);
}

.plan-group.just-chosen {
    animation: planChosen 0.9s var(--ease);
}

/* ---------- Тост ---------- */
#toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px));
    z-index: 1100;
    max-width: 88vw;
    padding: 11px 18px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--r-pill);
    font-size: 13.5px;
    font-weight: 500;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 14px);
    transition: opacity var(--t), transform 0.3s var(--ease);
}

#toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- Приветствие ---------- */
.welcome-modal {
    text-align: center;
}

.welcome-logo {
    width: 64px;
    height: 64px;
    margin: 6px auto 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-2), var(--primary));
    box-shadow: 0 10px 24px rgba(30, 155, 240, 0.35);
}

.welcome-logo .ico {
    width: 32px;
    height: 32px;
}

.welcome-title {
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -0.4px;
}

.welcome-subtitle {
    margin: 3px 0 20px;
    font-size: 13.5px;
    color: var(--muted);
}

.welcome-features {
    list-style: none;
    margin: 0 0 22px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 13px;
    text-align: left;
}

.welcome-features li {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    line-height: 1.4;
}

.welcome-features .wf-ico {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background: var(--primary-soft);
}

.welcome-features .wf-ico .ico {
    width: 18px;
    height: 18px;
}

/* ---------- Анимации ---------- */
@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes planChosen {
    0% { transform: translateY(-3px) scale(1.012); }
    35% { transform: scale(1.05); }
    100% { transform: translateY(-3px) scale(1.012); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Указатель мыши ---------- */
@media (hover: hover) and (pointer: fine) {
    .habit-card:hover {
        box-shadow: var(--shadow-lg);
    }

    .btn-check:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

    .btn-check.checked:hover {
        color: #fff;
    }

    .icon-btn:hover,
    .mini-btn:hover,
    .btn-close:hover {
        color: var(--primary);
    }

    .mini-btn.danger:hover {
        color: var(--danger);
        background: var(--danger-soft);
    }

    .chip:hover,
    .emoji-btn:hover,
    .p-emoji-btn:hover,
    .i-emoji-btn:hover {
        border-color: var(--primary);
    }

    .plan-cell:hover {
        transform: scale(1.12);
    }

    .tab:hover {
        color: var(--text);
    }

    .plan-add-item:hover,
    .empty-icon:hover {
        filter: brightness(1.04);
    }

    .ghost-btn:hover {
        border-color: var(--primary);
    }

    .ghost-btn.danger:hover {
        border-color: var(--danger);
        background: var(--danger-soft);
    }
}

/* ---------- Фокус с клавиатуры ---------- */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.emoji-btn:focus-visible,
.p-emoji-btn:focus-visible,
.i-emoji-btn:focus-visible {
    outline: none;
    border-color: var(--primary);
}

/* ---------- Широкий экран ---------- */
@media (min-width: 620px) {
    .modal-overlay {
        align-items: center;
        padding: 24px;
    }

    .modal {
        border-radius: 24px;
        max-height: 88vh;
        transform: translateY(24px) scale(0.97);
    }

    .modal-overlay.active .modal {
        transform: none;
    }

    .sheet-handle {
        display: none;
    }

    .modal {
        padding-top: 22px;
    }
}
