/* RoutineUp - Dark Minimal Design System */
@font-face {
    font-family: 'IRANYekanX';
    src: url('../font/IRANYekanXVF.woff2') format('woff2'),
         url('../font/IRANYekanXVF.woff') format('woff');
    font-style: normal;
    font-weight: 100 900;
    font-display: block;
}

:root {
    --bg: #0B0F19;
    --card: #141A24;
    --card-hover: #1a2230;
    --primary: #22C55E;
    --primary-hover: #16A34A;
    --success: #22C55E;
    --fire: #33CC89;
    --warning: #F59E0B;
    --danger: #EF4444;
    --text: #E8ECF4;
    --text-muted: #8892A4;
    --border: #1e2530;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --nav-height: 72px;
    --nav-safe-area: env(safe-area-inset-bottom, 0px);
    --nav-total-height: calc(var(--nav-height) + var(--nav-safe-area));
    --app-max-width: 450px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --motion-fast: 160ms;
    --motion-base: 260ms;
    --motion-ease: cubic-bezier(0.22, 0.72, 0.24, 1);
    --font: 'IRANYekanX', Tahoma, Arial, sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
}

/* Persian RTL and minimal visual refinements */
html {
    direction: rtl;
}

body {
    direction: rtl;
    text-align: right;
}

:root {
    --card: #121822;
    --card-hover: #171f2b;
    --border: #252d39;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    --transition: 0.16s ease;
    --font: 'IRANYekanX', Tahoma, Arial, sans-serif;
}

input,
textarea,
select,
button {
    font-family: inherit;
}

input,
textarea,
select,
.form-input,
.install-app-copy,
.feed-card-meta,
.friend-info,
.profile-info,
.routine-card-title,
.notification-body,
.sheet-header,
.status-panel,
.admin-table,
.admin-report,
.pro-feature-content {
    text-align: right;
}

input[type="email"],
input[type="url"],
.profile-username,
.friend-username,
.profile-links-sheet-url,
.pro-link-edit-form input[name="url"] {
    direction: ltr;
    text-align: left;
}

.card,
.install-app-banner,
.bottom-nav,
.bottom-sheet,
.modal-content {
    box-shadow: var(--shadow);
}

.card,
.ai-coach-hero,
.accent-preview,
.accent-option,
.pro-feature {
    background-image: none;
}

.ai-card {
    border-left: 1px solid var(--border);
    border-right: 3px solid var(--primary);
    background: var(--card);
}

.ai-warning { border-right-color: var(--warning); }
.ai-success { border-right-color: var(--success); }
.ai-info { border-right-color: var(--primary); }
.ai-card-status { margin-right: auto; margin-left: 0; }

.page-header > .icon-btn:first-child svg,
.calendar-nav .icon-btn svg,
.pro-feature-link span {
    transform: scaleX(-1);
}

.pro-feature-link:hover span {
    transform: scaleX(-1) translateX(2px);
}

.install-app-copy { text-align: right; }
.moderation-menu-panel { right: auto; left: 0; }
.notification-badge { right: auto; left: -9px; }
.routine-nav-badge { right: auto; left: -9px; }

.btn,
.chip,
.icon-btn,
.form-input,
.card {
    transition-duration: 0.16s;
}

.btn:hover,
.card:hover,
.accent-option:hover,
.ai-card:hover {
    transform: none;
}

:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--primary) 72%, white);
    outline-offset: 2px;
}

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

/* Minimal motion and loading feedback */
.page-progress {
    position: fixed;
    z-index: 2000;
    inset: 0 0 auto;
    height: 2px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-fast) ease;
}

.page-progress span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    box-shadow: 0 0 10px color-mix(in srgb, var(--primary) 45%, transparent);
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 1.2s var(--motion-ease), opacity var(--motion-fast) ease;
}

.page-progress.is-active {
    opacity: 1;
}

.page-progress.is-active span {
    transform: scaleX(.78);
}

.page-progress.is-complete span {
    opacity: 0;
    transform: scaleX(1);
    transition-duration: 140ms;
}

.main-content {
    transition: opacity var(--motion-fast) ease;
}

body.is-navigating .main-content {
    opacity: .78;
}

.motion-item {
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity var(--motion-base) var(--motion-ease),
        transform var(--motion-base) var(--motion-ease);
    transition-delay: calc(var(--motion-order, 0) * 32ms);
}

.motion-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.motion-image {
    opacity: 0;
    transition: opacity 320ms ease;
}

.motion-image.is-loaded {
    opacity: 1;
}

.btn,
.icon-btn,
.chip,
.nav-item,
.calendar-day {
    -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled),
.icon-btn:active:not(:disabled),
.chip:active,
.nav-item:active {
    transform: scale(.975);
}

.nav-item svg,
.nav-item .nav-brand-mark,
.nav-item .notification-icon-wrap,
.nav-item .nav-icon-wrap {
    transition: transform var(--motion-fast) var(--motion-ease);
}

.nav-item.active svg,
.nav-item.active .nav-brand-mark,
.nav-item.active .notification-icon-wrap,
.nav-item.active .nav-icon-wrap {
    transform: translateY(-1px) scale(1.04);
}

.btn[aria-busy="true"],
.chip[aria-busy="true"] {
    pointer-events: none;
}

.loading-state,
.infinite-scroll-loader {
    align-items: center;
    justify-content: center;
    gap: 9px;
}

.loading-state {
    display: flex;
    min-height: 96px;
    color: var(--text-muted);
    background:
        linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .035) 50%, transparent 70%),
        var(--card);
    background-size: 220% 100%;
    animation: loading-sheen 1.4s ease-in-out infinite;
}

.loading-state::before,
.infinite-scroll-loader::before {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid color-mix(in srgb, var(--primary) 30%, var(--border));
    border-top-color: var(--primary);
    border-radius: 50%;
    content: '';
    animation: spin .75s linear infinite;
}

.infinite-scroll-loader:not(.hidden) {
    display: inline-flex;
}

.chart-card {
    position: relative;
}

.chart-card::after {
    position: absolute;
    inset: 46px 12px 12px;
    border-radius: var(--radius-sm);
    background:
        linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .045) 50%, transparent 70%),
        color-mix(in srgb, var(--card) 88%, var(--bg));
    background-size: 220% 100%;
    content: '';
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-fast) ease;
}

.chart-card.is-loading::after {
    opacity: 1;
    animation: loading-sheen 1.2s ease-in-out infinite;
}

.search-loading {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

.search-loading-avatar,
.search-loading-lines i {
    display: block;
    overflow: hidden;
    background:
        linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, .06) 50%, transparent 75%),
        var(--border);
    background-size: 220% 100%;
    animation: loading-sheen 1.2s ease-in-out infinite;
}

.search-loading-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.search-loading-lines {
    display: grid;
    gap: 7px;
}

.search-loading-lines i {
    width: 64%;
    height: 8px;
    border-radius: 999px;
}

.search-loading-lines i:last-child {
    width: 42%;
    opacity: .72;
}

.modal:not(.hidden) .modal-content,
.story-modal:not(.hidden) .story-builder,
.image-lightbox:not(.hidden) img {
    animation: surface-enter var(--motion-base) var(--motion-ease) both;
}

.moderation-menu[open] .moderation-menu-panel,
.ai-actions[open] .ai-actions-panel,
.routine-share-panel:not(.hidden) {
    animation: popover-enter var(--motion-fast) var(--motion-ease) both;
}

@keyframes surface-enter {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popover-enter {
    from { opacity: 0; transform: translateY(-4px) scale(.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes loading-sheen {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    overflow-x: hidden;
}

.install-app-banner {
    position: sticky;
    top: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
    background: rgba(20, 26, 36, 0.98);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(18px);
}

.install-app-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.install-app-brand > img {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    object-fit: contain;
}

.install-app-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
    text-align: left;
}

.install-app-copy strong {
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.35;
}

.install-app-copy span {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.45;
}

.install-app-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.install-app-actions .btn {
    min-height: 34px;
    padding: 7px 12px;
    white-space: nowrap;
}

.install-app-dismiss {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.install-app-dismiss:hover,
.install-app-dismiss:focus-visible {
    border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    color: var(--text);
}

.install-app-dismiss svg {
    width: 17px;
    height: 17px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    display: block;
}

.hidden {
    display: none !important;
}

.pro-badge { --pro-badge-color: #F59E0B; display: inline-flex; align-items: center; padding: 1px 5px; border: 1px solid color-mix(in srgb, var(--pro-badge-color) 48%, transparent); border-radius: 5px; background: color-mix(in srgb, var(--pro-badge-color) 10%, transparent); color: var(--pro-badge-color); font-size: .56rem; font-weight: 700; letter-spacing: .08em; line-height: 1.3; vertical-align: middle; }
.profile-header { border-color: color-mix(in srgb, var(--profile-accent, var(--primary)) 14%, var(--border)); }
.profile-header-actions { display: flex; align-items: center; gap: 8px; }
.profile-edit-label { display: none; }
.profile-links-trigger { display: inline-flex; align-items: center; margin-top: 8px; padding: 0; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
.profile-links-trigger:hover { color: var(--profile-accent, var(--primary)); }
.profile-links-sheet-list { display: grid; gap: 8px; }
.profile-links-sheet-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: .9rem; }
.profile-links-sheet-item:last-child { border-bottom: 0; }
.profile-links-sheet-item:hover { color: var(--primary); }
.profile-links-sheet-copy { display: grid; min-width: 0; gap: 3px; }
.profile-links-sheet-title { font-weight: 700; }
.profile-links-sheet-url { color: var(--text-muted); font-size: .76rem; overflow-wrap: anywhere; }
.profile-links-sheet-item:hover .profile-links-sheet-url { color: color-mix(in srgb, var(--primary) 72%, var(--text-muted)); }
.accent-settings { --active-accent: var(--primary); padding-top: 4px; }
.accent-settings-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.accent-settings-heading label { color: var(--active-accent); }
.accent-settings-heading .form-hint { margin-top: 4px; }
.accent-preview { --accent-preview-color: var(--primary); display: grid; grid-template-columns: 1fr minmax(112px, .55fr); align-items: center; gap: 12px; margin: 12px 0; padding: 14px; border: 1px solid color-mix(in srgb, var(--accent-preview-color) 40%, var(--border)); border-radius: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent-preview-color) 17%, var(--card)), var(--card) 68%); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent-preview-color) 16%, transparent); }
.accent-preview-profile { display: flex; align-items: center; gap: 11px; min-width: 0; }
.accent-preview-avatar { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border: 2px solid color-mix(in srgb, var(--accent-preview-color) 48%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--accent-preview-color) 20%, var(--card)); color: var(--text); font-size: .95rem; font-weight: 800; box-shadow: 0 7px 18px color-mix(in srgb, var(--accent-preview-color) 22%, transparent); }
.accent-preview strong, .accent-preview small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accent-preview strong { font-size: .9rem; }
.accent-preview small { margin-top: 2px; color: var(--text-muted); font-size: .73rem; }
.accent-preview-samples { display: grid; gap: 7px; min-width: 0; }
.accent-preview-pill { justify-self: end; padding: 2px 6px; border: 1px solid color-mix(in srgb, var(--accent-preview-color) 50%, transparent); border-radius: 6px; background: color-mix(in srgb, var(--accent-preview-color) 12%, transparent); color: var(--accent-preview-color); font-size: .58rem; font-weight: 800; line-height: 1.25; }
.accent-preview-progress { display: block; height: 7px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--accent-preview-color) 16%, var(--border)); }
.accent-preview-progress i { display: block; width: 68%; height: 100%; border-radius: inherit; background: var(--accent-preview-color); }
.accent-preview-bars { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 5px; height: 26px; }
.accent-preview-bars i { display: block; border-radius: 5px 5px 3px 3px; background: color-mix(in srgb, var(--accent-preview-color) 78%, #fff); }
.accent-preview-bars i:nth-child(1) { height: 45%; opacity: .55; }
.accent-preview-bars i:nth-child(2) { height: 72%; opacity: .78; }
.accent-preview-bars i:nth-child(3) { height: 100%; }
.accent-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 9px; }
.accent-option { display: grid; grid-template-columns: 40px minmax(0, 1fr) 20px; align-items: center; gap: 10px; min-height: 62px; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 7%, var(--card)), var(--card)); cursor: pointer; transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition); }
.accent-option:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent-color) 64%, var(--border)); background: linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 13%, var(--card)), var(--card)); }
.accent-option.is-selected { border-color: var(--accent-color); background: linear-gradient(135deg, color-mix(in srgb, var(--accent-color) 18%, var(--card)), var(--card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-color) 58%, transparent), 0 8px 20px color-mix(in srgb, var(--accent-color) 12%, transparent); }
.accent-option input { position: absolute; opacity: 0; pointer-events: none; }
.accent-swatch { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent-color) 44%, #fff); border-radius: 13px; background: color-mix(in srgb, var(--accent-color) 18%, var(--card)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.accent-swatch span { display: block; width: 25px; height: 25px; border-radius: 9px; background: var(--accent-color); box-shadow: 0 6px 14px color-mix(in srgb, var(--accent-color) 28%, transparent); }
.accent-option-copy { display: grid; min-width: 0; gap: 1px; }
.accent-option-name { overflow: hidden; font-size: .84rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.accent-option-value { color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .66rem; }
.accent-option-check { position: relative; display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent-color) 44%, var(--border)); border-radius: 50%; background: color-mix(in srgb, var(--accent-color) 10%, transparent); color: #fff; font-size: 0; opacity: .7; transform: scale(.9); transition: opacity var(--transition), transform var(--transition), background var(--transition); }
.accent-option-check::before { width: 5px; height: 9px; margin-top: -1px; border: solid #fff; border-width: 0 2px 2px 0; content: ''; opacity: 0; transform: rotate(45deg) scale(.7); transition: opacity var(--transition), transform var(--transition); }
.accent-option.is-selected .accent-option-check { opacity: 1; transform: scale(1); }
.accent-option.is-selected .accent-option-check { background: var(--accent-color); }
.accent-option.is-selected .accent-option-check::before { opacity: 1; transform: rotate(45deg) scale(1); }
.accent-option:focus-within { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.profile-links-manage { margin-top: 12px; }
.profile-logout-action { margin-top: 12px; }
@media (max-width: 380px) { .accent-preview { grid-template-columns: 1fr; } .accent-preview-samples { grid-template-columns: auto 1fr auto; align-items: end; } .accent-preview-pill { justify-self: start; } .accent-preview-bars { width: 52px; } }
.ai-coach-hero { position: relative; z-index: 5; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 4px 2px 8px; }
.ai-coach-hero-copy { min-width: 0; }
.ai-eyebrow { color: var(--primary); font-size: .62rem; font-weight: 800; letter-spacing: .12em; }
.ai-coach-title-row { display: flex; align-items: center; gap: 8px; }
.ai-coach-title-row .pro-badge { --pro-badge-color: var(--primary); }
.ai-coach-title-row h1 { font-size: 1.35rem; }
.ai-coach-hero-copy p { margin-top: 4px; color: var(--text-muted); font-size: .8rem; }
.ai-actions { position: relative; flex: 0 0 auto; }
.ai-actions summary { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 9px; color: var(--text-muted); background: color-mix(in srgb, var(--card) 75%, transparent); cursor: pointer; list-style: none; font-size: .68rem; font-weight: 700; transition: color var(--transition), border-color var(--transition), background var(--transition); }
.ai-actions summary::-webkit-details-marker { display: none; }
.ai-actions summary:hover, .ai-actions[open] summary { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: color-mix(in srgb, var(--primary) 7%, var(--card)); color: var(--text); }
.ai-actions-chevron { font-size: .8rem; transition: transform var(--transition); }
.ai-actions[open] .ai-actions-chevron { transform: rotate(180deg); }
.ai-actions-panel { position: absolute; z-index: 20; inset-block-start: calc(100% + 7px); inset-inline-end: 0; width: min(280px, calc(100vw - 30px)); max-block-size: min(70vh, 410px); overflow-y: auto; padding: 11px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--card) 96%, var(--bg)); box-shadow: 0 14px 36px rgba(0, 0, 0, .38); }
.ai-actions-panel > p { color: var(--text); font-size: .72rem; font-weight: 700; }
.ai-actions-panel > small { display: block; margin-top: 8px; color: var(--text-muted); font-size: .62rem; }
.ai-action-scroller { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.ai-action-scroller .ai-action { width: 100%; min-height: 32px; justify-content: center; padding: 5px 7px; border-color: var(--border); background: transparent; white-space: nowrap; font-size: .68rem; transition: background var(--transition), border-color var(--transition), color var(--transition); }
.ai-action-scroller .ai-action:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); }
.ai-action-scroller .ai-action:disabled { cursor: wait; opacity: .55; }
.ai-coach-notice { margin: 10px 0; padding: 11px 13px; color: var(--text-muted); font-size: .76rem; line-height: 1.8; }
.ai-coach-notice[hidden] { display: none; }
.ai-notice-insufficient_data, .ai-notice-daily_limit { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: color-mix(in srgb, var(--warning) 8%, var(--card)); color: var(--text); }
.ai-notice-temporarily_unavailable { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 7%, var(--card)); color: var(--text); }
.ai-coach-carousel { min-width: 0; margin: 10px 0 16px; }
.ai-coach-empty-chooser { display: none; min-height: clamp(300px, 52vh, 440px); padding: 24px 14px; text-align: center; }
.ai-coach-carousel.is-empty .ai-coach-empty-chooser { display: grid; align-content: center; justify-items: center; gap: 18px; }
.ai-empty-heading { display: grid; max-width: 380px; justify-items: center; gap: 7px; }
.ai-empty-icon { display: grid; width: 46px; height: 46px; margin-bottom: 3px; place-items: center; border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 15px; background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); font-size: 1.25rem; }
.ai-empty-heading h2 { font-size: 1.05rem; }
.ai-empty-heading p { color: var(--text-muted); font-size: .78rem; line-height: 1.8; }
.ai-empty-actions { display: flex; max-width: 520px; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-empty-actions .ai-action { min-height: 34px; padding: 6px 11px; border-color: color-mix(in srgb, var(--primary) 20%, var(--border)); background: color-mix(in srgb, var(--primary) 4%, transparent); font-size: .7rem; transition: background var(--transition), border-color var(--transition), color var(--transition); }
.ai-empty-actions .ai-action:hover:not(:disabled) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.ai-empty-actions .ai-action:disabled { cursor: wait; opacity: .55; }
.ai-coach-empty-chooser > small { color: var(--text-muted); font-size: .62rem; }
.ai-carousel-header { display: flex; align-items: center; justify-content: space-between; min-height: 34px; margin-bottom: 7px; padding-inline: 2px; }
.ai-carousel-header > span { color: var(--text-muted); font-size: .7rem; font-weight: 700; }
.ai-carousel-controls { display: flex; direction: rtl; gap: 5px; }
.ai-carousel-controls button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: transparent; color: var(--text); cursor: pointer; font-size: .92rem; transition: border-color var(--transition), background var(--transition), opacity var(--transition); }
.ai-carousel-controls button:hover:not(:disabled) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); }
.ai-carousel-controls button:disabled { cursor: default; opacity: .28; }
.ai-carousel-viewport { overflow: hidden; direction: ltr; border-radius: var(--radius); outline: none; touch-action: pan-y; cursor: grab; }
.ai-carousel-viewport:active { cursor: grabbing; }
.ai-carousel-viewport:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 70%, transparent); outline-offset: 3px; }
.ai-coach-track { display: flex; align-items: stretch; width: 100%; transform: translate3d(0, 0, 0); transition: transform .46s cubic-bezier(.22, .75, .22, 1); will-change: transform; }
.ai-coach-track.no-transition { transition: none !important; }
.ai-coach-slide { display: flex; flex: 0 0 100%; min-width: 0; direction: rtl; }
.ai-coach-slide > .card { width: 100%; min-height: 220px; }
.ai-empty-state { display: grid; min-height: 150px !important; padding: 18px 14px; place-items: center; }
.ai-empty-state p { color: var(--text-muted); font-size: .8rem; }
.ai-carousel-footer { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 22px; margin-top: 7px; }
.ai-carousel-dots { display: flex; direction: ltr; gap: 4px; }
.ai-carousel-dots span { width: 5px; height: 5px; border-radius: 999px; background: var(--border); transition: width var(--transition), background var(--transition); }
.ai-carousel-dots span.is-active { width: 15px; background: var(--primary); }
.ai-carousel-count { color: var(--text-muted); font-size: .62rem; }
.ai-coach-carousel.is-empty .ai-carousel-header, .ai-coach-carousel.is-empty .ai-carousel-viewport, .ai-coach-carousel.is-empty .ai-carousel-footer { display: none; }
.ai-card { --ai-accent: var(--primary); position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--ai-accent) 42%, var(--border)); border-inline-start: 3px solid var(--ai-accent); background: linear-gradient(145deg, color-mix(in srgb, var(--ai-accent) 7%, var(--card)), var(--card) 54%); transition: border-color var(--transition), background var(--transition); }
.ai-card::after { position: absolute; inset-block-start: -55px; inset-inline-end: -45px; width: 130px; height: 130px; border-radius: 50%; background: color-mix(in srgb, var(--ai-accent) 7%, transparent); content: ''; pointer-events: none; }
.ai-card:hover { border-color: color-mix(in srgb, var(--ai-accent) 60%, var(--border)); }
.ai-danger { --ai-accent: var(--danger); }
.ai-warning { --ai-accent: var(--warning); }
.ai-success { --ai-accent: var(--success); }
.ai-info { --ai-accent: var(--primary); }
.ai-card-top { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-card-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--ai-accent) 14%, var(--card)); font-size: .95rem; }
.ai-card-label { color: var(--text-muted); font-size: .68rem; font-weight: 800; letter-spacing: .04em; }
.ai-card-status { margin-inline-start: auto; color: var(--ai-accent); font-size: .65rem; font-weight: 800; white-space: nowrap; }
.ai-card-refresh { position: relative; z-index: 2; display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border: 1px solid color-mix(in srgb, var(--ai-accent) 24%, var(--border)); border-radius: 9px; background: color-mix(in srgb, var(--ai-accent) 7%, var(--card)); color: var(--ai-accent); cursor: pointer; transition: background var(--transition), opacity var(--transition), transform var(--transition); }
.ai-card-refresh:hover:not(:disabled) { background: color-mix(in srgb, var(--ai-accent) 14%, var(--card)); transform: rotate(-18deg); }
.ai-card-refresh:disabled { cursor: not-allowed; opacity: .42; }
.ai-card-refresh svg { width: 15px; height: 15px; }
.ai-card-refresh.is-loading { cursor: wait; }
.ai-card h2, .ai-card p { position: relative; z-index: 1; }
.ai-card h2 { font-size: 1rem; }
.ai-card p { margin-top: 5px; }
.ai-insight, .ai-suggestion { margin-top: 10px !important; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--text-muted) 7%, transparent); color: var(--text-muted); font-size: .78rem; }
.ai-suggestion { border: 1px solid color-mix(in srgb, var(--ai-accent) 24%, transparent); background: color-mix(in srgb, var(--ai-accent) 8%, transparent); color: color-mix(in srgb, var(--ai-accent) 82%, var(--text)); }
.ai-card-updated { position: relative; z-index: 1; margin-top: 12px; padding-top: 9px; border-top: 1px solid color-mix(in srgb, var(--ai-accent) 13%, var(--border)); color: var(--text-muted); font-size: .64rem; }
.ai-action.is-loading { cursor: wait; opacity: .8; }
.ai-action-spinner { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ai-action-spin .7s linear infinite; }
@keyframes ai-action-spin { to { transform: rotate(360deg); } }
@media (max-width: 380px) { .ai-coach-hero { align-items: center; } .ai-coach-hero-copy p { max-width: 220px; } .ai-actions summary span:first-child { max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
@media (prefers-reduced-motion: reduce) { .ai-coach-track { transition-duration: .01ms; } }
.pro-links-page { display: grid; gap: 16px; padding-top: 8px; }
.pro-links-header { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 12px; }
.pro-links-header h1 { margin-top: 3px; font-size: 1.4rem; }
.pro-links-header p { margin-top: 4px; color: var(--text-muted); font-size: .84rem; }
.pro-links-overview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; }
.pro-links-overview strong { font-size: 1.05rem; }
.pro-links-overview strong span { color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.pro-links-overview p { margin-top: 4px; color: var(--text-muted); font-size: .76rem; }
.pro-link-form-card h2 { margin-bottom: 12px; font-size: 1rem; }
.pro-link-form { display: grid; gap: 4px; }
.pro-link-list { display: grid; gap: 10px; }
.pro-link-item { display: flex; align-items: start; gap: 8px; padding: 12px; }
.pro-link-edit-form { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.4fr) auto; gap: 7px; flex: 1; }
.pro-link-edit-form .form-input { min-width: 0; padding: 9px 10px; font-size: .8rem; }
.pro-link-delete { width: 34px; height: 34px; color: var(--text-muted); font-size: 1.25rem; line-height: 1; }
.pro-link-delete:hover { color: var(--danger); }
@media (max-width: 420px) { .pro-links-overview { align-items: flex-start; flex-direction: column; } .pro-link-edit-form { grid-template-columns: 1fr; } .pro-link-edit-form .btn { width: 100%; } }
.pro-page { display: grid; gap: 20px; padding: 8px 0 24px; }
.pro-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 8px 2px 0; }
.pro-page-header h1 { margin-top: 10px; font-size: 1.7rem; line-height: 1.15; letter-spacing: -.03em; }
.pro-page-header p { max-width: 300px; margin-top: 8px; color: var(--text-muted); font-size: .9rem; }
.pro-subscription-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid rgba(245, 158, 11, .3); background: linear-gradient(135deg, rgba(245, 158, 11, .1), var(--card) 55%); }
.pro-subscription-card h2 { margin-top: 4px; font-size: 1.15rem; }
.pro-price-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pro-price { color: var(--text); font-size: 1.2rem; font-weight: 800; }
.pro-price span { color: var(--text-muted); font-size: .78rem; font-weight: 500; }
.pro-original-price { color: var(--text-muted); font-size: .8rem; text-decoration: line-through; }
.pro-discount { padding: 2px 6px; border-radius: 5px; background: rgba(34, 197, 94, .12); color: var(--success); font-size: .7rem; font-weight: 700; }
.pro-payment-note { margin-top: 4px; color: var(--text-muted); font-size: .75rem; }
.pro-section-label { color: #F59E0B; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.pro-benefits { display: grid; gap: 10px; }
.pro-section-heading { padding: 4px 2px 8px; }
.pro-section-heading h2 { margin-top: 5px; font-size: 1.15rem; }
.pro-feature { display: grid; grid-template-columns: 38px 1fr; gap: 14px; padding: 16px; }
.pro-feature-number { color: #F59E0B; font-size: .75rem; font-weight: 800; padding-top: 3px; }
.pro-feature h3 { font-size: 1rem; }
.pro-feature p { margin-top: 4px; color: var(--text-muted); font-size: .86rem; }
.pro-feature-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: .82rem; font-weight: 700; }
.pro-feature-link span { transition: transform var(--transition); }
.pro-feature-link:hover span { transform: translateX(3px); }
@media (max-width: 380px) { .pro-subscription-card { align-items: flex-start; flex-direction: column; } .pro-subscription-card .btn { width: 100%; } }

/* Layout */
.main-content {
    max-width: var(--app-max-width);
    margin: 0 auto;
    padding: 20px 16px calc(var(--nav-total-height) + 24px);
    min-height: 100vh;
    min-height: 100dvh;
}

.main-content.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 20px;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: background var(--transition);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: wait;
    opacity: 0.75;
    transform: none;
}

.btn[aria-busy="true"]::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #2a3344;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--card-hover);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

html[dir="rtl"] select.form-input {
    padding-left: 44px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    background-size: 16px;
}

.form-color {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input {
    accent-color: var(--primary);
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 4px;
    display: block;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-card {
    margin-top: 16px;
}

.profile-avatar-field {
    margin-bottom: 22px;
}

.profile-avatar-picker {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary) 5%, var(--bg));
}

.profile-avatar-preview {
    position: relative;
    flex: 0 0 88px;
    width: 88px;
    height: 88px;
}

.profile-avatar-preview > img {
    width: 100%;
    height: 100%;
    border: 3px solid color-mix(in srgb, var(--primary) 28%, var(--border));
    border-radius: 50%;
    background: var(--border);
    object-fit: cover;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 13%, transparent);
}

.profile-avatar-preview-badge {
    position: absolute;
    right: -2px;
    bottom: 2px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 3px solid var(--card);
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
}

.profile-avatar-preview-badge svg {
    width: 13px;
    height: 13px;
}

.profile-avatar-picker-body {
    min-width: 0;
}

.profile-avatar-picker-body > strong {
    display: block;
    color: var(--text);
    font-size: 0.875rem;
}

.profile-avatar-picker-body > p {
    margin: 3px 0 10px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-avatar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-avatar-actions .btn {
    margin: 0;
}

.profile-avatar-actions .profile-avatar-select {
    display: inline-flex;
    margin-bottom: 0;
    color: var(--text);
    cursor: pointer;
}

.profile-avatar-cancel {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
}

.profile-avatar-cancel:hover {
    background: var(--card-hover);
    color: var(--text);
}

.profile-avatar-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.profile-avatar-input:focus-visible + .profile-avatar-hint {
    color: var(--primary);
}

.profile-avatar-field:focus-within .profile-avatar-picker {
    border-color: var(--primary);
}

.profile-avatar-hint {
    margin-top: 7px;
}

@media (max-width: 380px) {
    .profile-avatar-picker {
        align-items: flex-start;
        gap: 12px;
        padding: 12px;
    }

    .profile-avatar-preview {
        flex-basis: 72px;
        width: 72px;
        height: 72px;
    }
}

/* Flash Messages */
.flash-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: calc(100% - 32px);
    max-width: 448px;
}

body.has-install-banner .flash-container {
    top: 88px;
}

.flash {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
    backdrop-filter: blur(12px);
}

.flash-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.flash-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.flash-info {
    background: rgba(34, 197, 94, 0.15);
    color: var(--primary);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.milestone-notification {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: rgba(25, 30, 42, 0.96);
    color: var(--text);
    text-align: right;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.milestone-notification:hover {
    border-color: rgba(245, 158, 11, 0.75);
}

.milestone-notification.is-leaving {
    opacity: 0;
    transform: translateY(-12px);
    transition: all 0.3s ease;
}

.milestone-notification-icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.16);
    color: #f59e0b;
    font-size: 1.25rem;
    font-weight: 800;
}

.milestone-level_up .milestone-notification-icon {
    background: rgba(34, 197, 94, 0.16);
    color: var(--primary);
}

.milestone-notification-copy {
    display: grid;
    gap: 2px;
}

.milestone-notification-copy strong {
    color: var(--text);
    font-size: 0.9rem;
}

.milestone-notification-copy > span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-total-height);
    margin: auto;
    max-width: var(--app-max-width);
    background: rgba(20, 26, 36, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: var(--nav-safe-area);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 8px 16px;
    transition: color var(--transition);
    text-decoration: none;
}

.nav-button {
    background: transparent;
    border: 0;
    font-family: inherit;
    cursor: pointer;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-brand-mark {
    width: 27px;
    height: 27px;
    object-fit: contain;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon-wrap,
.notification-icon-wrap {
    position: relative;
    display: inline-flex;
}

.routine-nav-badge,
.notification-badge {
    position: absolute;
    top: -7px;
    right: -9px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    border: 2px solid var(--card);
    font-size: 0.625rem;
    line-height: 14px;
    font-weight: 800;
    text-align: center;
}

.routine-nav-badge {
    background: var(--warning);
    color: #0B0F19;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    flex: 1;
}

.page-title-stack {
    flex: 1;
    min-width: 0;
}

.page-title-stack h1 {
    margin-bottom: 2px;
}

.page-title-stack p {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Auth */
.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-modern {
    margin-bottom: 22px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.brand-mark,
.brand-wordmark {
    display: block;
    object-fit: contain;
}

.brand-lockup-auth {
    direction: ltr;
    width: min(100%, 245px);
    margin: 0 auto 16px;
}

.brand-lockup-auth .brand-mark {
    width: 64px;
    height: 64px;
}

.brand-lockup-auth .brand-wordmark {
    width: min(165px, calc(100% - 74px));
    height: auto;
}

.home-brand {
    direction: rtl;
    justify-content: flex-start;
    flex: 1;
    min-width: 0;
}

.home-brand .brand-mark {
    width: 42px;
    height: 42px;
}

.home-page-title {
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.auth-form {
    animation: fadeIn 0.4s ease;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 0.875rem;
}

.auth-step-card {
    position: relative;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.auth-step-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #38BDF8, #F59E0B);
}

.auth-progress {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.auth-progress span {
    height: 5px;
    border-radius: 999px;
    background: var(--border);
}

.auth-progress span.active {
    background: var(--primary);
}

.auth-step-kicker {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.auth-input-lg {
    padding: 15px 16px;
    font-size: 1rem;
}

.auth-email-pill {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: #BAE6FD;
    border: 1px solid rgba(56, 189, 248, 0.24);
    font-size: 0.8125rem;
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Avatar */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    background: var(--border);
}

.avatar-sm {
    width: 40px;
    height: 40px;
}

.avatar-lg {
    width: 80px;
    height: 80px;
}

/* Feed */
.feed-filters {
    margin-bottom: 20px;
}

.friend-highlights {
    margin-bottom: 18px;
    padding: 14px;
    border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
    background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 7%, var(--card)), var(--card) 62%);
}

.friend-highlights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.friend-highlights-kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
}

.friend-highlights-header h2 {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.friend-highlights-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 13%, transparent);
}

.friend-highlights-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.friend-highlight-item {
    --friend-accent: var(--primary);
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 9px;
    border: 1px solid color-mix(in srgb, var(--friend-accent) 20%, var(--border));
    border-radius: 12px;
    color: var(--text);
    background: color-mix(in srgb, var(--friend-accent) 5%, var(--card));
}

.friend-highlight-item .avatar {
    width: 38px;
    height: 38px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--friend-accent) 26%, transparent);
}

.friend-highlight-item span {
    min-width: 0;
}

.friend-highlight-item strong,
.friend-highlight-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-highlight-item strong {
    color: color-mix(in srgb, var(--friend-accent) 58%, var(--text));
    font-size: 0.8125rem;
}

.friend-highlight-item small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.71875rem;
}

.guest-feed-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.14), rgba(56, 189, 248, 0.08)), var(--card);
}

.guest-feed-banner h2 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.guest-feed-banner p {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.guest-feed-kicker {
    display: block;
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.filter-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.chip.active, .chip:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.feed-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.infinite-scroll-status {
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.infinite-scroll-sentinel {
    height: 1px;
}

.feed-card {
    --profile-accent: var(--primary);
    animation: fadeIn 0.4s ease;
    border-color: color-mix(in srgb, var(--profile-accent) 24%, var(--border));
    border-inline-start: 2px solid color-mix(in srgb, var(--profile-accent) 68%, var(--border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--profile-accent) 8%, var(--card)), var(--card) 48%);
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
}

.feed-card:hover {
    border-color: color-mix(in srgb, var(--profile-accent) 38%, var(--border));
}

.feed-card-compact {
    padding: 14px;
}

.feed-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}

.feed-card-meta {
    flex: 1;
}

.feed-avatar-link {
    display: block;
    flex-shrink: 0;
    border-radius: 50%;
}

.feed-avatar-link:focus-visible,
.feed-profile-link:focus-visible {
    outline: 2px solid var(--profile-accent);
    outline-offset: 3px;
}

.feed-avatar-link .avatar {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--profile-accent) 38%, var(--border));
}

.feed-profile-link {
    min-width: 0;
    color: var(--text);
}

.feed-profile-link:hover .feed-username {
    color: var(--profile-accent);
}

.feed-username {
    font-weight: 600;
    font-size: 0.9375rem;
    display: block;
}

.feed-category {
    font-size: 0.8125rem;
    color: color-mix(in srgb, var(--profile-accent) 34%, var(--text-muted));
}

.feed-streak {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--fire);
    line-height: 1;
}

.streak-value {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    color: var(--fire);
    line-height: 1;
}

.fire-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 1em;
    object-fit: contain;
    vertical-align: middle;
}

.fire-icon-lg {
    width: 1.5rem;
    height: 1.5rem;
    flex-basis: 1.5rem;
}

.fire-icon-title {
    width: 1.25em;
    height: 1.25em;
    flex-basis: 1.25em;
}

.fire-icon-sm {
    width: 0.9em;
    height: 0.9em;
    flex-basis: 0.9em;
}

.feed-progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    margin: 0;
    padding: 3px 0;
    border: 0;
    border-radius: 999px;
    color: color-mix(in srgb, var(--primary) 76%, var(--text));
    background: transparent;
    font-size: 0.71875rem;
    font-weight: 800;
    line-height: 1.2;
}

.feed-progress-badge.progress-record {
    color: color-mix(in srgb, var(--warning) 82%, var(--text));
}

.feed-progress-badge.progress-comeback {
    color: color-mix(in srgb, #38bdf8 75%, var(--text));
}

.feed-progress-badge.progress-streak {
    color: var(--fire);
}

.feed-card-state-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 9px;
}

.feed-card-state-row .activity-state-line {
    margin: 0;
}

.feed-card-state-row .routine-timer {
    flex-basis: 100%;
    margin: 2px 0 0;
}

.close-rival-card {
    --rival-accent: var(--primary);
    position: relative;
    padding: 14px;
    overflow: hidden;
    border-style: dashed;
    border-color: color-mix(in srgb, var(--rival-accent) 38%, var(--border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--rival-accent) 9%, var(--card)), var(--card) 64%);
}

.close-rival-card::after {
    content: '';
    position: absolute;
    inset: auto -24px -34px auto;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--rival-accent) 7%, transparent);
    pointer-events: none;
}

.close-rival-topline,
.close-rival-main {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
}

.close-rival-topline {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 11px;
}

.close-rival-kicker {
    color: var(--rival-accent);
    font-size: 0.6875rem;
    font-weight: 800;
}

.close-rival-category {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.close-rival-main {
    gap: 10px;
}

.close-rival-avatar {
    flex: 0 0 auto;
    border-radius: 50%;
}

.close-rival-avatar .avatar {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--rival-accent) 34%, transparent);
}

.close-rival-copy {
    min-width: 0;
    flex: 1;
}

.close-rival-name {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.close-rival-copy p {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.65;
}

.close-rival-streak {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    flex: 0 0 auto;
    padding: 6px 8px;
    border-radius: 9px;
    color: var(--fire);
    background: color-mix(in srgb, var(--fire) 9%, transparent);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
}

.feed-routine-title {
    margin: 0;
    color: var(--text);
    font-size: 0.8125rem;
    font-weight: 650;
}

.feed-routine-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 8px;
    padding-top: 9px;
    border-top: 1px solid color-mix(in srgb, var(--profile-accent) 24%, var(--border));
}

.feed-routine-box-label {
    flex: 0 0 auto;
    padding-top: 1px;
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 500;
}

.feed-routine-summary {
    min-width: 0;
    flex: 1;
}

.feed-routine-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 2px;
}

.feed-routine-details span {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.3;
}

.feed-card-compact .feed-card-header {
    margin-bottom: 8px;
}

.feed-card-compact .feed-routine-title {
    font-size: 0.9375rem;
}

.feed-photo {
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 12px;
    aspect-ratio: 4/3;
}

.feed-photo-button {
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: zoom-in;
    display: block;
    font: inherit;
}

.feed-photo-button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.feed-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-photo-placeholder {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    aspect-ratio: auto;
    margin: 0 0 8px;
    border-radius: 50%;
    font-size: 1.5rem;
}

.feed-note {
    min-width: 0;
    margin: 0;
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.feed-note-muted {
    color: var(--text-muted);
}

.feed-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.feed-update-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 0;
}

.feed-time {
    flex-shrink: 0;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.86);
}

.image-lightbox img {
    max-width: min(100%, 960px);
    max-height: 86vh;
    border-radius: var(--radius-sm);
    object-fit: contain;
    box-shadow: var(--shadow);
}

.image-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    color: #fff;
    background: rgba(20, 26, 36, 0.78);
    cursor: pointer;
    transition: background var(--transition);
}

.image-lightbox-close:hover {
    background: rgba(42, 51, 68, 0.9);
}

.image-lightbox-close svg {
    width: 22px;
    height: 22px;
}

/* Calendar */
.calendar-header {
    margin-bottom: 14px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.routine-tab-header[hidden] {
    display: none;
}

.calendar-month {
    font-size: 1.375rem;
    font-weight: 700;
}

.calendar-stats {
    display: flex;
    gap: 8px;
}

.stat-pill {
    flex: 1;
    background: transparent;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0;
}

.stat-value {
    font-size: 0.9375rem;
    font-weight: 700;
}

.routine-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 16px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(20, 26, 36, 0.62);
}

.routine-tab {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 800;
    transition: background var(--transition), color var(--transition);
}

.routine-tab:hover {
    color: var(--text);
}

.routine-tab.active {
    background: var(--primary);
    color: #fff;
}

.routine-tab-panel[hidden] {
    display: none;
}

.section-heading,
.manage-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-kicker {
    display: block;
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.section-heading h2,
.manage-summary h2 {
    font-size: 1rem;
    line-height: 1.25;
}

.today-routines {
    margin-bottom: 20px;
}

.today-open-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 7px 12px;
    transition: background var(--transition), border-color var(--transition);
}

.today-open-btn:hover {
    background: var(--card-hover);
    border-color: rgba(34, 197, 94, 0.45);
}

.today-task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.today-task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(20, 26, 36, 0.62);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background var(--transition), border-color var(--transition);
}

.today-task-row:hover {
    background: var(--card-hover);
    border-color: rgba(34, 197, 94, 0.45);
}

.today-task-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
    flex: 0 0 28px;
}

.today-task-body {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
}

.today-task-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9375rem;
    font-weight: 700;
}

.today-task-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.today-task-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 9px;
    background: rgba(136, 146, 164, 0.14);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 800;
}

.completion-logo {
    display: inline-block;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    object-fit: contain;
}

.today-task-status.status-completed {
    background: rgba(34, 197, 94, 0.14);
    color: var(--success);
}

.today-task-status.status-missed {
    background: rgba(239, 68, 68, 0.14);
    color: var(--danger);
}

.today-task-status.status-skipped {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning);
}

.today-task-status.status-started,
.status-started {
    background: rgba(59, 130, 246, 0.16);
    color: #60A5FA;
}

.today-task-timer,
.routine-row-timer {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 3px;
    color: #60A5FA;
    font-size: 0.6875rem;
}

.today-task-timer strong,
.routine-row-timer strong {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
}

.today-task-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.calendar-grid {
    margin-bottom: 20px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 5px;
}

.calendar-day {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(20, 26, 36, 0.74);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    font-family: inherit;
}

.calendar-day:hover {
    border-color: var(--primary);
    background: var(--card-hover);
    transform: translateY(-1px);
}

.calendar-day.today {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}

.calendar-day.status-completed {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.45);
    color: var(--success);
}

.calendar-day.status-missed {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--danger);
}

.calendar-day.status-partial-missed {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.45);
    color: var(--warning);
}

.calendar-day.empty {
    background: transparent !important;
    border-color: transparent;
    cursor: default;
}

.calendar-day.empty:hover {
    transform: none;
}

.day-number {
    position: relative;
    z-index: 1;
}

.day-task-count {
    position: relative;
    z-index: 1;
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1;
}

.calendar-actions {
    margin-top: 16px;
}

/* Bottom Sheet */
.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    opacity: 0;
    transition: opacity var(--transition);
}

.bottom-sheet-overlay.visible {
    opacity: 1;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: var(--app-max-width);
    margin-inline: auto;
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 201;
    max-height: 85vh;
    transform: translateY(100%);
    transition: transform var(--transition);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-sheet.visible {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto;
}

.bottom-sheet-content {
    padding: 0 20px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(85vh - 40px);
}

.sheet-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.feed-motivation-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
    overflow: hidden;
    border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.13), rgba(56, 189, 248, 0.05)), var(--card);
}

.feed-motivation-card::after {
    content: '';
    position: absolute;
    inset: auto auto -34px -28px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.08);
    pointer-events: none;
}

.feed-motivation-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    color: var(--primary);
    background: rgba(34, 197, 94, 0.12);
}

.feed-motivation-icon svg {
    width: 22px;
    height: 22px;
}

.feed-motivation-content {
    min-width: 0;
    flex: 1;
}

.feed-motivation-label {
    display: block;
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
}

.feed-motivation-card p {
    position: relative;
    z-index: 1;
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.8;
}

.today-active-users {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
}

.today-active-avatars {
    display: flex;
    align-items: center;
    padding-inline-start: 4px;
}

.today-active-avatar {
    display: block;
    width: 25px;
    height: 25px;
    margin-inline-start: -5px;
    border: 2px solid var(--card);
    border-radius: 50%;
    background: var(--card);
}

.today-active-avatar:first-child {
    margin-inline-start: 0;
}

.today-active-avatar .avatar {
    width: 100%;
    height: 100%;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--active-user-accent) 35%, transparent);
}

.sheet-header {
    margin-bottom: 16px;
}

.sheet-kicker {
    display: block;
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sheet-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.notification-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.notification-sheet-header > div {
    min-width: 0;
}

.notification-permission-btn {
    margin-bottom: 12px;
}

.notification-page-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    margin-bottom: 12px;
}

.notification-page-tools p {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    line-height: 1.4;
}

.notification-page-header {
    margin-bottom: 14px;
}

.notification-read-all,
.notification-enable {
    border: 0;
    padding: 4px 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.notification-read-all:hover,
.notification-enable:hover {
    color: var(--primary-hover);
}

.notification-permission-icon {
    display: inline-flex;
    flex: 0 0 auto;
}

.notification-permission-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.notification-page-list {
    padding-bottom: 12px;
}

.notification-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 4px;
    background: transparent;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    transition: opacity var(--transition), background var(--transition);
}

.notification-row:hover {
    background: rgba(255, 255, 255, 0.025);
    color: var(--text);
}

.notification-row.is-unread {
    background: transparent;
}

.notification-row:not(.is-unread) {
    opacity: 0.72;
}

.notification-group {
    border-bottom: 1px solid var(--border);
}

.notification-group:not(.is-unread) {
    opacity: 0.72;
}

.notification-group[open] {
    opacity: 1;
}

.notification-group-summary {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 4px;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    transition: background var(--transition);
}

.notification-group-summary::-webkit-details-marker {
    display: none;
}

.notification-group-summary:hover,
.notification-group[open] > .notification-group-summary {
    background: rgba(255, 255, 255, 0.025);
}

.notification-group-summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.notification-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    margin-top: 6px;
    border-radius: 999px;
    background: rgba(136, 146, 164, 0.14);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1;
}

.notification-group-chevron {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin-top: 10px;
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform var(--transition);
}

.notification-group[open] .notification-group-chevron {
    transform: rotate(180deg);
}

.notification-group-items {
    padding-inline-start: 22px;
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.notification-row--nested {
    padding-inline-end: 4px;
}

.notification-group-items .notification-row:last-child {
    border-bottom: 0;
}

.notification-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex: 0 0 36px;
    color: var(--text-muted);
    background: rgba(136, 146, 164, 0.12);
}

.notification-type-icon svg,
.notification-empty-state .empty-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notification-type--morning_reminder .notification-type-icon,
.notification-type--pending_reminder .notification-type-icon,
.notification-type--achievement .notification-type-icon,
.notification-type--timer_finished .notification-type-icon {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.12);
}

.notification-type--evening_reminder .notification-type-icon,
.notification-type--friend_request .notification-type-icon,
.notification-type--level_up .notification-type-icon {
    color: #60A5FA;
    background: rgba(96, 165, 250, 0.12);
}

.notification-type--friend_accepted .notification-type-icon,
.notification-type--friend_completion .notification-type-icon {
    color: var(--success);
    background: rgba(34, 197, 94, 0.12);
}

.notification-type--admin_warning .notification-type-icon {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

.notification-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary);
    flex: 0 0 auto;
}

.notification-title-line {
    display: flex;
    align-items: center;
    gap: 7px;
}

.notification-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2px;
    min-width: 0;
}

.notification-body strong {
    color: var(--text);
    font-size: 0.9375rem;
}

.notification-body span,
.notification-body time,
.notification-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.notification-body span {
    overflow-wrap: anywhere;
}

.notification-empty {
    padding: 20px 0;
    text-align: center;
}

.notification-empty-state {
    padding: 52px 20px;
}

.notification-empty-state .empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border-radius: 50%;
    color: var(--text-muted);
    background: rgba(136, 146, 164, 0.1);
}

.routine-sheet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.routine-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    border: 1px solid var(--border);
    width: 100%;
    text-align: left;
    color: var(--text);
    font-family: inherit;
}

.routine-row:hover {
    background: var(--card-hover);
    border-color: rgba(34, 197, 94, 0.45);
}

.routine-row.is-selected {
    background: rgba(34, 197, 94, 0.08);
    border-color: var(--primary);
}

.routine-row:disabled {
    cursor: default;
    opacity: 0.72;
}

.routine-row:disabled:hover {
    background: var(--bg);
    border-color: var(--border);
}

.routine-row-icon {
    font-size: 1.5rem;
}

.routine-row-info {
    flex: 1;
}

.routine-row-name {
    font-weight: 600;
    display: block;
}

.routine-row-streak {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.75rem;
    color: var(--fire);
    line-height: 1;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending,
.status-started,
.status-completed,
.status-missed,
.status-skipped {
    background: rgba(136, 146, 164, 0.16);
    color: var(--text-muted);
}

.timer-panel {
    display: grid;
    gap: 14px;
    margin-top: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(11, 15, 25, 0.64);
}

.task-start-section {
    margin-top: 14px;
}

.task-start-trigger {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid rgba(59, 130, 246, 0.28);
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.07);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: border-color var(--transition), background var(--transition);
}

.task-start-trigger:hover,
.task-start-trigger.is-open {
    border-color: rgba(96, 165, 250, 0.62);
    background: rgba(59, 130, 246, 0.12);
}

.task-start-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding-left: 2px;
    border-radius: 50%;
    background: #3B82F6;
    color: white;
    font-size: 0.7rem;
}

.task-start-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
}

.task-start-copy strong {
    font-size: 0.875rem;
}

.task-start-copy small,
.timer-options-heading small,
.timer-panel > small {
    color: var(--text-muted);
    font-size: 0.71875rem;
}

.task-start-chevron {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: transform var(--transition);
}

.task-start-trigger.is-open .task-start-chevron {
    transform: rotate(180deg);
}

.timer-options-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.timer-options-heading strong {
    font-size: 0.8125rem;
}

.active-timer {
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-top: 14px;
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.07);
}

.active-timer strong {
    color: #60A5FA;
    font-size: 1.55rem;
    font-variant-numeric: tabular-nums;
}

.active-timer small {
    grid-column: 1 / -1;
}

.duration-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.duration-presets button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 9px 3px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    transition: border-color var(--transition), background var(--transition);
}

.duration-presets button small {
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 500;
}

.duration-presets button:hover,
.duration-presets button.is-selected {
    border-color: rgba(96, 165, 250, 0.7);
    background: rgba(59, 130, 246, 0.12);
    color: #93C5FD;
}

.timer-duration-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.timer-custom-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
}

.timer-custom-input input {
    width: 52px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    text-align: right;
}

.timer-custom-input small {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.task-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.task-status-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.task-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: rgba(136, 146, 164, 0.12);
    font-size: 0.75rem;
}

.task-status-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.task-status-completed:hover,
.task-status-completed.is-active {
    border-color: rgba(34, 197, 94, 0.52);
    background: rgba(34, 197, 94, 0.09);
    color: var(--success);
}

.task-status-missed:hover,
.task-status-missed.is-active {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
    color: #F87171;
}

.task-secondary-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--border);
}

.task-secondary-actions .task-status-action {
    min-height: auto;
    padding: 3px;
    border: 0;
    color: var(--text-muted);
    font-size: 0.71875rem;
    font-weight: 500;
}

.task-secondary-actions .task-status-action:hover,
.task-secondary-actions .task-status-action.is-active {
    background: transparent;
    color: var(--text);
}

.activity-state-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 2px 0 10px;
}

.activity-state-line time {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.activity-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
}

.routine-timer {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2px 12px;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--text-muted) 20%, var(--border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--text-muted) 7%, transparent);
}

.routine-timer-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.routine-timer-value {
    color: var(--text);
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.routine-timer small {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.routine-timer.is-overtime,
.timer-panel.is-overtime,
.routine-row-timer.is-overtime,
.today-task-timer.is-overtime {
    border-color: rgba(245, 158, 11, 0.4);
    color: var(--warning);
}

.routine-timer.is-overtime .routine-timer-label,
.routine-timer.is-overtime .routine-timer-value,
.active-timer.is-overtime strong {
    color: var(--warning);
}

.routine-timer.is-finished {
    background: rgba(136, 146, 164, 0.07);
}

.activity-status.status-started,
.today-task-status.status-started,
.status-badge.status-started {
    background: rgba(59, 130, 246, 0.16);
    color: #60A5FA;
}

.activity-status.status-completed {
    background: transparent;
    color: var(--success);
}

.status-badge.status-completed {
    background: color-mix(in srgb, var(--success) 14%, transparent);
    color: var(--success);
}

.activity-status.status-missed {
    background: transparent;
    color: var(--danger);
}

.activity-status.status-skipped {
    background: transparent;
    color: var(--warning);
}

.activity-status.status-pending {
    background: transparent;
    color: var(--text-muted);
}

.status-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.status-actions .btn,
.status-option {
    flex: 1;
    min-width: calc(50% - 4px);
    border: 1px solid transparent;
}

.status-actions .btn.is-active,
.status-option.is-active {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
}

.status-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    background: var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background var(--transition), border-color var(--transition);
}

.status-option:hover {
    background: #2a3344;
}

.status-option span {
    font-size: 0.875rem;
    font-weight: 700;
}

.status-option small {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.status-option.is-active small {
    color: var(--text);
}

.complete-form {
    display: grid;
    gap: 12px;
    min-width: 0;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.complete-form textarea {
    resize: vertical;
    min-height: 80px;
}

.complete-form.is-uploading {
    opacity: 0.88;
}

.compact-upload {
    display: block;
    min-width: 0;
    max-width: 100%;
    padding: 10px 11px;
    border: 1px dashed var(--border);
    border-radius: 9px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: border-color var(--transition), color var(--transition);
}

.compact-upload:hover {
    border-color: rgba(96, 165, 250, 0.5);
    color: var(--text);
}

.compact-upload > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.compact-upload small {
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 400;
}

.compact-upload > input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.photo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(34, 197, 94, 0.06);
}

.photo-preview-img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg);
    flex: 0 0 auto;
}

.photo-preview-meta {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
}

.photo-preview-meta strong {
    color: var(--text);
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.photo-preview-meta span {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.status-panel {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(20, 26, 36, 0.72);
}

.status-panel-empty,
.day-empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 18px 12px;
    font-size: 0.875rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.status-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.status-panel-header h3 {
    font-size: 1rem;
    margin-top: 1px;
}

.optional-label {
    color: var(--text-muted);
    font-weight: 400;
}

/* Routines Manage */
.manage-summary {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(20, 26, 36, 0.62);
}

.routine-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.routine-empty-state {
    display: flex;
    min-height: 300px;
    padding: 48px 28px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-color: color-mix(in srgb, var(--border) 72%, transparent);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    text-align: center;
}

.routine-empty-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    color: var(--primary);
}

.routine-empty-icon svg {
    width: 25px;
    height: 25px;
}

.routine-empty-copy {
    max-width: 330px;
}

.routine-empty-copy .section-kicker {
    display: block;
    margin-bottom: 6px;
}

.routine-empty-copy h2 {
    margin-bottom: 8px;
    font-size: 1.125rem;
    font-weight: 650;
}

.routine-empty-copy p {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.8;
}

.routine-empty-state .btn {
    min-width: 150px;
}

.routine-card {
    padding: 16px;
}

.routine-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.routine-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 8px;
    background: var(--bg);
    font-size: 1.35rem;
}

.routine-card-title {
    min-width: 0;
    flex: 1;
}

.routine-card-header h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 600;
}

.routine-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.routine-streak {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--fire);
    line-height: 1;
    white-space: nowrap;
}

.routine-card-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.routine-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
}

.routine-chip.muted {
    background: rgba(136, 146, 164, 0.12);
    color: var(--text-muted);
}

.routine-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
}

.routine-actions .btn,
.routine-actions form {
    flex: 0 0 auto;
}

.routine-actions form {
    display: block;
}

.routine-actions form .btn {
    width: auto;
}

.routine-action-primary,
.routine-action-icon {
    display: inline-flex;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.routine-action-primary {
    gap: 7px;
    padding: 0 11px;
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
    color: color-mix(in srgb, var(--primary) 72%, var(--text));
    font-size: .72rem;
    font-weight: 750;
}

.routine-action-primary svg {
    width: 17px;
    height: 17px;
}

.routine-action-icon {
    width: 36px;
    padding: 0;
}

.routine-action-icon svg {
    width: 17px;
    height: 17px;
}

.routine-action-primary:hover,
.routine-action-primary[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--primary) 52%, var(--border));
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.routine-action-icon:hover {
    border-color: color-mix(in srgb, var(--text-muted) 48%, var(--border));
    color: var(--text);
    background: rgba(255, 255, 255, .035);
}

.routine-action-danger:hover {
    border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 7%, transparent);
}

.weekday-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.weekday-chip {
    cursor: pointer;
}

.weekday-chip input {
    display: none;
}

.weekday-chip span {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.8125rem;
    transition: all var(--transition);
}

.weekday-chip input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.form-hint {
    margin: -4px 0 10px;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.monthday-picker {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.monthday-chip {
    cursor: pointer;
}

.monthday-chip input {
    display: none;
}

.monthday-chip span {
    display: grid;
    place-items: center;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 0.8125rem;
    transition: all var(--transition);
}

.monthday-chip input:checked + span {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.modal-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-heading h2 {
    margin-bottom: 0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

.message-modal-content {
    max-width: 390px;
}

.message-modal {
    z-index: 400;
}

.message-modal-heading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-modal-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 900;
}

.message-modal-danger .message-modal-icon {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    color: var(--danger);
}

.message-modal-text {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.9;
    white-space: pre-line;
}

.message-modal-prompt {
    margin-top: 18px;
}

body.has-message-modal {
    overflow: hidden;
}

/* Profile */
.profile-header {
    padding: 18px;
    margin-bottom: 16px;
}

.profile-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    min-width: 0;
}

.profile-top > .avatar-lg {
    width: 72px;
    height: 72px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--profile-accent, var(--primary)) 18%, transparent);
}

.profile-info {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.profile-name-row {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.profile-info h1 {
    min-width: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-username {
    display: block;
    width: fit-content;
    margin-top: 1px;
    margin-right: 0;
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.profile-bio {
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.profile-edit-action {
    width: 36px;
    height: 36px;
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

.profile-edit-action:hover {
    color: var(--text);
}

.profile-edit-action svg {
    width: 18px;
    height: 18px;
}

.profile-upgrade-action {
    padding: 7px 11px;
    background: transparent;
    color: var(--text-muted);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding-top: 14px;
    border-top: 1px solid color-mix(in srgb, var(--profile-accent, var(--primary)) 10%, var(--border));
}

.profile-stat {
    min-width: 0;
    padding: 2px 4px;
    text-align: center;
}

.profile-stat + .profile-stat {
    border-inline-start: 1px solid color-mix(in srgb, var(--profile-accent, var(--primary)) 8%, var(--border));
}

.profile-stat-link {
    color: inherit;
    text-decoration: none;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.profile-stat-link:hover,
.profile-stat-link:focus-visible {
    background: color-mix(in srgb, var(--profile-accent, var(--primary)) 12%, transparent);
    color: var(--profile-accent, var(--primary));
    transform: translateY(-1px);
}

.profile-stat .stat-value {
    display: block;
    color: var(--text);
    font-weight: 650;
    font-size: 0.9375rem;
    line-height: 1.35;
    white-space: nowrap;
}

.profile-stat .stat-value.streak-value {
    display: inline-flex;
    color: var(--fire);
}

.profile-stat .stat-label {
    display: block;
    margin-top: 2px;
    font-size: 0.625rem;
    color: var(--text-muted);
}

.profile-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.profile-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
}

.profile-tab {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition);
    text-align: center;
}

.profile-tab.active,
.profile-tab:hover {
    background: var(--primary);
    color: #fff;
}

.profile-section {
    margin-bottom: 28px;
}

.profile-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-heading-row h2 {
    margin-bottom: 0;
}

.section-heading-row span {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

.profile-activity-heading-row {
    justify-content: flex-end;
}

.profile-activity-list {
    gap: 12px;
}

.empty-state.profile-empty-state {
    display: flex;
    min-height: 176px;
    padding: 28px 24px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.profile-empty-icon {
    display: grid;
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--profile-accent, var(--primary)) 8%, transparent);
    color: color-mix(in srgb, var(--profile-accent, var(--primary)) 52%, var(--text-muted));
}

.profile-empty-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.empty-state.profile-empty-state h3 {
    margin-bottom: 6px;
    font-size: 0.9375rem;
    font-weight: 700;
}

.empty-state.profile-empty-state p {
    max-width: 360px;
    margin-bottom: 0;
    font-size: 0.8125rem;
    line-height: 1.8;
}

.profile-empty-state .btn {
    margin-top: 16px;
}

.activity-routine-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    font-size: 1.35rem;
}

.streak-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.streak-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.streak-icon {
    font-size: 1.5rem;
}

.streak-card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.streak-count {
    font-size: 0.8125rem;
    color: var(--primary);
    font-weight: 600;
}

.achievement-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.achievement-badge {
    text-align: center;
    padding: 16px 8px;
}

.badge-icon {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 4px;
}

.badge-name {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.achievement-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.achievement-eyebrow {
    display: block;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.achievement-hero h2 {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 8px;
}

.achievement-hero p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.level-ring {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    flex: 0 0 96px;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--primary) var(--progress), var(--border) 0);
    position: relative;
}

.level-ring::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--card);
}

.level-ring span {
    position: relative;
    z-index: 1;
    font-weight: 800;
}

.level-progress,
.achievement-progress {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.level-progress {
    margin-bottom: 24px;
}

.level-progress span,
.achievement-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.xp-ways {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.xp-way {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
}

.xp-way-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: var(--radius-sm);
    background: rgba(34, 197, 94, 0.14);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
}

.xp-way strong {
    display: block;
    font-size: 0.9375rem;
}

.xp-way span:last-child {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.achievement-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-pill .stat-value.streak-value {
    justify-content: center;
    color: var(--fire);
}

.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.achievement-row {
    display: flex;
    gap: 14px;
    padding: 16px;
}

.achievement-row.locked {
    opacity: 0.72;
}

.achievement-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    display: grid;
    place-items: center;
    flex: 0 0 52px;
}

.achievement-row.unlocked .achievement-icon-wrap {
    background: rgba(245, 158, 11, 0.16);
}

.achievement-icon {
    font-size: 1.5rem;
}

.achievement-row-body {
    flex: 1;
    min-width: 0;
}

.achievement-row-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.achievement-row h3 {
    font-size: 0.9375rem;
    margin-bottom: 4px;
}

.xp-reward {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
}

.achievement-row p {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 10px;
}

.achievement-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 6px;
}

.xp-history {
    padding: 8px 16px;
}

.xp-history-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.xp-history-row:last-child {
    border-bottom: none;
}

.xp-history-row strong {
    color: var(--primary);
}

.chart-preview {
    padding: 16px;
}

.chart-card {
    margin-bottom: 16px;
    padding: 16px;
}

.chart-card h3 {
    font-size: 0.9375rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.routine-page-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.routine-page-summary h2 {
    font-size: 1.25rem;
    margin-bottom: 6px;
}

.streak-heading,
.streak-summary-detail {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.streak-heading {
    color: var(--fire);
}

.streak-summary-detail {
    color: color-mix(in srgb, var(--fire) 72%, var(--text-muted));
}

.routine-page-summary p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.routine-page-total {
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
}

.routine-page-list {
    gap: 12px;
}

.routine-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.routine-metric {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}

.routine-metric-value {
    display: block;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
}

.routine-metric-value.streak-value {
    display: inline-flex;
    color: var(--fire);
}

.ai-action .fire-icon,
.ai-card-icon .fire-icon {
    width: 1em;
    height: 1em;
}

.routine-metric-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Stats */
.stats-overview {
    text-align: center;
    padding: 24px;
    margin-bottom: 16px;
}

.consistency-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

.consistency-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.period-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.heatmap {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.heatmap-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--border);
}

/* Friends */
.search-box {
    position: relative;
    z-index: 60;
    margin-bottom: 20px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    margin-top: 4px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
}

.search-result-item:hover {
    background: var(--card-hover);
}

.friends-section {
    margin-bottom: 24px;
}

.friends-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
}

.friend-info {
    flex: 1;
}

.friend-name {
    font-weight: 600;
    display: block;
    color: var(--text);
    text-decoration: none;
}

.friend-username {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Admin */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.admin-stat {
    text-align: center;
    padding: 16px;
}

.admin-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-section {
    margin-top: 24px;
}

.admin-filter-nav {
    margin-bottom: 14px;
}

.admin-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.admin-row-action {
    margin-inline-start: auto;
}

.admin-create-form {
    margin-top: 22px;
}

.admin-user-card {
    display: grid;
    gap: 14px;
    margin-bottom: 10px;
}

.admin-user-main,
.admin-user-actions,
.admin-user-meta,
.admin-inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-user-main {
    justify-content: space-between;
}

.admin-user-main > div:first-child {
    display: grid;
    gap: 3px;
}

.admin-user-actions {
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.admin-days-input {
    width: 86px;
    min-height: 34px;
    padding: 7px 9px;
}

.admin-table {
    display: grid;
    gap: 0;
    overflow-x: auto;
}

.admin-table-row {
    display: grid;
    grid-template-columns: 56px minmax(150px, 1.4fr) minmax(100px, 1fr) minmax(86px, .8fr) minmax(94px, .8fr) minmax(120px, 1fr) minmax(130px, 1fr);
    gap: 10px;
    align-items: center;
    min-width: 820px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.84rem;
}

.admin-table-row-compact {
    grid-template-columns: 56px minmax(150px, 1.4fr) minmax(100px, 1fr) minmax(86px, .8fr) minmax(94px, .8fr);
    min-width: 560px;
}

.admin-table-row:last-child {
    border-bottom: 0;
}

.admin-table-head {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.74rem;
    text-transform: uppercase;
}

.admin-table-row small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
}

.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;
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.moderation-menu {
    position: relative;
    flex: 0 0 auto;
}

.moderation-menu summary {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    list-style: none;
    opacity: 0.55;
    transition: opacity var(--transition), background var(--transition);
}

.moderation-menu summary::-webkit-details-marker {
    display: none;
}

.moderation-menu summary:hover,
.moderation-menu summary:focus-visible,
.moderation-menu[open] summary {
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
}

.moderation-menu summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.moderation-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    min-width: 142px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--card-hover);
    box-shadow: var(--shadow);
}

.moderation-menu-panel a,
.moderation-menu-panel button,
.moderation-menu-panel .routine-join-menu-status {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    color: var(--text-muted);
    background: transparent;
    font: inherit;
    font-size: 0.78rem;
    text-align: start;
    white-space: nowrap;
}

.admin-fake-master,
.admin-fake-master form,
.admin-fake-card-profile,
.admin-fake-avatar-preview,
.admin-percent-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-fake-master {
    justify-content: space-between;
}

.admin-fake-master h2,
.admin-fake-form-section h2 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.admin-fake-master p {
    margin: 0;
}

.admin-fake-master .admin-fake-ai-state {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.admin-fake-card {
    display: grid;
    gap: 14px;
    margin-bottom: 10px;
}

.admin-fake-card-profile > div {
    display: grid;
    gap: 3px;
}

.admin-fake-card-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary) 7%, transparent);
    color: var(--text-muted);
    font-size: .8rem;
}

.admin-fake-form-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 360px), 1fr)
    );
    gap: 12px;
    margin-bottom: 14px;
}

.admin-fake-form-section {
    min-width: 0;
}

.main-content.admin-wide-page {
    max-width: 980px;
}

.admin-fake-check {
    margin: 10px 0;
}

.admin-category-checks,
.admin-probability-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 180px), 1fr)
    );
    gap: 8px 12px;
}

.admin-probability-grid .form-group {
    min-width: 0;
}

.admin-percent-input {
    width: 100%;
}

.admin-percent-input .form-input {
    width: 100%;
    min-width: 0;
}

.admin-percent-input span {
    flex: 0 0 auto;
    color: var(--text-muted);
}

.admin-pause-input {
    width: 190px;
    min-height: 34px;
    padding: 7px 9px;
}

.admin-fake-activity-row {
    display: grid;
    grid-template-columns:
        minmax(120px, .8fr)
        minmax(150px, 1fr)
        90px
        minmax(320px, 2.2fr)
        minmax(190px, 1.1fr);
    gap: 10px;
    align-items: start;
    min-width: 980px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .84rem;
}

.admin-fake-activity-row:last-child {
    border-bottom: 0;
}

.admin-fake-activity-result {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.admin-fake-activity-result > strong {
    color: var(--text);
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.admin-fake-activity-meta,
.admin-fake-activity-times {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    color: var(--text-muted);
    font-size: .75rem;
}

.admin-fake-activity-times {
    display: grid;
}

.admin-worker-debug summary {
    width: fit-content;
    color: var(--primary);
    cursor: pointer;
    font-size: .76rem;
}

.admin-worker-debug pre {
    max-height: 320px;
    margin: 8px 0 0;
    padding: 10px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-muted);
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: .72rem/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 760px) {
    .admin-fake-master {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-fake-form-grid {
        grid-template-columns: 1fr;
    }

    .admin-category-checks,
    .admin-probability-grid {
        grid-template-columns: repeat(
            auto-fit,
            minmax(min(100%, 180px), 1fr)
        );
    }
}

@media (max-width: 430px) {
    .admin-category-checks,
    .admin-probability-grid {
        grid-template-columns: 1fr;
    }
}

.moderation-menu-panel form {
    margin: 0;
}

.moderation-menu-panel button {
    cursor: pointer;
}

.moderation-menu-panel button:hover,
.moderation-menu-panel button:focus-visible,
.moderation-menu-panel .routine-join-menu-invite:hover,
.moderation-menu-panel .routine-join-menu-invite:focus-visible {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.moderation-menu-panel .routine-join-menu-status {
    opacity: .7;
    cursor: default;
}

.moderation-menu-panel a:hover,
.moderation-menu-panel a:focus-visible {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.profile-moderation-menu summary {
    width: 34px;
    height: 34px;
}

.report-form-card,
.admin-report-list {
    display: grid;
    gap: 12px;
}

.report-target-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.report-target-summary span,
.admin-report-header span,
.admin-report-activity span {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.admin-report {
    display: grid;
    gap: 14px;
}

.admin-report-header,
.admin-report-target {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-report-header > div,
.admin-report-activity {
    display: flex;
    flex-direction: column;
}

.admin-report-target,
.admin-report-activity {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
}

.admin-report-reason {
    white-space: pre-wrap;
}

.admin-report-actions,
.admin-warning-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-warning-form {
    width: 100%;
}

.admin-warning-form textarea {
    flex: 1 1 220px;
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 24px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 0.9375rem;
}

/* Responsive */
@media (min-width: 451px) {
    .main-content {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 480px) {
    .profile-header {
        padding: 16px 14px;
    }

    .profile-top {
        display: grid;
        grid-template-columns: 60px minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        margin-bottom: 14px;
    }

    .profile-top > .avatar-lg {
        width: 60px;
        height: 60px;
    }

    .profile-info {
        min-width: 0;
    }

    .profile-header-actions {
        width: auto;
        margin: 0;
    }

    .profile-top > .profile-actions {
        grid-column: 1 / -1;
        width: 100%;
        margin-top: 2px;
    }

    .profile-header-actions > .btn,
    .profile-header-actions > .profile-edit-action,
    .profile-top > .profile-actions > .btn {
        flex: 0 0 auto;
        min-width: 0;
        min-height: 36px;
    }

    .profile-edit-action {
        width: 36px;
        height: 36px;
        padding: 0;
    }
}

@media (max-width: 380px) {
    .calendar-stats {
        flex-direction: column;
    }

    .profile-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .achievement-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .profile-header {
        padding: 14px 12px;
    }

    .profile-top {
        grid-template-columns: 52px minmax(0, 1fr) auto;
        gap: 8px;
    }

    .profile-top > .avatar-lg {
        width: 52px;
        height: 52px;
    }

    .profile-info h1 {
        font-size: .9375rem;
    }

    .profile-username {
        font-size: .8rem;
    }

    .profile-header-actions > .btn,
    .profile-header-actions > .profile-edit-action {
        padding-right: 7px;
        padding-left: 7px;
        font-size: .6875rem;
    }

    .profile-stats {
        gap: 0;
    }

    .profile-stat {
        padding-right: 1px;
        padding-left: 1px;
    }

    .profile-stat .stat-value {
        font-size: .8125rem;
    }

    .profile-stat .stat-label {
        font-size: .5625rem;
    }
}

/* Final RTL overrides stay last so legacy physical properties cannot win. */
html[dir="rtl"] body,
html[dir="rtl"] .install-app-copy,
html[dir="rtl"] .form-input,
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] .profile-username,
html[dir="rtl"] .friend-username,
html[dir="rtl"] .profile-links-sheet-url,
html[dir="rtl"] .pro-link-edit-form input[name="url"] {
    direction: ltr;
    text-align: left;
}

html[dir="rtl"] .ai-card {
    border-left: 1px solid var(--border);
    border-right: 3px solid var(--ai-accent, var(--primary));
}

html[dir="rtl"] .ai-card-status {
    margin-right: auto;
    margin-left: 0;
}

html[dir="rtl"] .moderation-menu-panel {
    right: auto;
    left: 0;
}

html[dir="rtl"] .notification-badge,
html[dir="rtl"] .routine-nav-badge {
    right: auto;
    left: -9px;
}

html[dir="rtl"] .page-header > .icon-btn:first-child svg,
html[dir="rtl"] .calendar-nav .icon-btn svg {
    transform: scaleX(-1);
}

html[dir="rtl"] .today-task-row,
html[dir="rtl"] .routine-row,
html[dir="rtl"] .task-start-trigger,
html[dir="rtl"] .status-option {
    text-align: right;
}

html[dir="rtl"] .card,
html[dir="rtl"] .accent-preview,
html[dir="rtl"] .accent-option,
html[dir="rtl"] .pro-feature {
    background-image: none;
    box-shadow: var(--shadow);
}

html[dir="rtl"] .feed-card {
    background-image: linear-gradient(135deg, color-mix(in srgb, var(--profile-accent) 8%, var(--card)), var(--card) 48%);
}

html[dir="rtl"] .accent-option:hover,
html[dir="rtl"] .pro-feature:hover {
    transform: none;
    box-shadow: var(--shadow);
}

html[dir="rtl"] .ai-actions,
html[dir="rtl"] .ai-card,
html[dir="rtl"] .ai-card:hover {
    box-shadow: none;
}

/* Shared routines */
.shared-routine-guide {
    margin-bottom: 20px;
    padding: 18px;
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
    background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 38%),
        var(--card);
}

.shared-routine-guide-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}

.shared-routine-guide-header::-webkit-details-marker,
.join-routine-help summary::-webkit-details-marker,
.story-builder-explanation summary::-webkit-details-marker {
    display: none;
}

.shared-routine-guide-icon {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 13px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 13%, transparent);
    font-size: 1.45rem;
}

.shared-routine-guide-header strong {
    display: block;
    margin: 3px 0 4px;
    font-size: 1rem;
}

.shared-routine-guide-header small {
    display: block;
    color: var(--text-muted);
    font-size: .74rem;
    line-height: 1.75;
}

.shared-routine-guide-chevron {
    margin-inline-start: auto;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.shared-routine-guide[open] .shared-routine-guide-chevron {
    transform: rotate(180deg);
}

.shared-routine-guide-content {
    display: grid;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.shared-routine-steps {
    display: grid;
    gap: 9px;
    list-style: none;
}

.shared-routine-steps li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
    border-radius: 11px;
    background: rgba(5, 10, 16, .22);
}

.shared-routine-steps li > span {
    display: grid;
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    place-items: center;
    border-radius: 8px;
    color: #07120B;
    background: var(--primary);
    font-size: .72rem;
    font-weight: 900;
}

.shared-routine-steps strong,
.shared-routine-steps small {
    display: block;
}

.shared-routine-steps strong {
    margin-bottom: 2px;
    font-size: .78rem;
}

.shared-routine-steps small {
    color: var(--text-muted);
    font-size: .68rem;
    line-height: 1.65;
}

.shared-routine-guide-note {
    display: flex;
    gap: 9px;
    padding: 11px 12px;
    border-radius: 11px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.shared-routine-guide-note p {
    color: var(--text-muted);
    font-size: .69rem;
    line-height: 1.7;
}

.shared-routine-guide-note strong {
    display: block;
    color: var(--text);
    font-size: .73rem;
}

.shared-invitations {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.shared-count,
.shared-routine-label,
.inline-shared-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
    border-radius: 999px;
    color: color-mix(in srgb, var(--primary) 76%, var(--text));
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    font-size: .6875rem;
    font-weight: 800;
    line-height: 1;
}

.shared-count {
    width: 28px;
    height: 28px;
}

.shared-routine-label,
.inline-shared-badge {
    padding: 4px 7px;
    margin-inline-start: 5px;
    vertical-align: middle;
}

.shared-invite-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--card)), var(--card));
}

.shared-invite-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 13px;
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    font-size: 1.35rem;
}

.shared-invite-copy {
    min-width: 0;
}

.shared-invite-copy strong,
.shared-invite-copy span {
    display: block;
}

.shared-invite-copy strong {
    overflow: hidden;
    font-size: .9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shared-invite-copy span {
    color: var(--text-muted);
    font-size: .72rem;
}

.shared-invite-actions {
    display: flex;
    gap: 6px;
}

.shared-invite-details {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
}

.shared-invite-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
    list-style: none;
}

.shared-invite-details summary::-webkit-details-marker {
    display: none;
}

.shared-invite-details summary svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition);
}

.shared-invite-details[open] summary {
    color: var(--text);
}

.shared-invite-details[open] summary svg {
    transform: rotate(180deg);
}

.shared-invite-detail-body {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding: 11px;
    border-radius: 10px;
    background: rgba(5, 10, 16, .25);
}

.shared-invite-facts {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.shared-invite-facts span {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: .66rem;
}

.shared-invite-detail-body > p {
    color: var(--text-muted);
    font-size: .7rem;
    line-height: 1.8;
}

.shared-invite-detail-body > .shared-invite-warning {
    margin: 0;
    padding: 8px 9px;
    border-inline-start: 2px solid #f5a524;
    border-radius: 7px;
    color: color-mix(in srgb, #f5a524 78%, var(--text));
    background: color-mix(in srgb, #f5a524 8%, transparent);
}

.shared-invite-warning strong,
.routine-share-note strong {
    color: color-mix(in srgb, #f5a524 82%, var(--text));
}

.shared-invite-detail-body .shared-invite-actions {
    justify-content: flex-end;
}

.btn-ghost {
    border-color: transparent;
    color: var(--text-muted);
    background: transparent;
}

.btn-share {
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
    color: color-mix(in srgb, var(--primary) 76%, var(--text));
    background: color-mix(in srgb, var(--primary) 9%, transparent);
}

.routine-member-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 2px;
    padding: 9px 10px;
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary) 5%, transparent);
    color: var(--text-muted);
    font-size: .72rem;
}

.member-avatar-stack {
    display: flex;
    padding-inline-start: 7px;
}

.avatar-xs {
    width: 28px;
    height: 28px;
}

.member-avatar-stack .avatar {
    margin-inline-start: -7px;
    border: 2px solid var(--card);
}

.routine-owner-note {
    align-self: center;
    margin-inline-end: auto;
    color: var(--text-muted);
    font-size: .72rem;
}

.routine-merge-panel {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
}

.routine-merge-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
    list-style: none;
}

.routine-merge-panel summary::-webkit-details-marker {
    display: none;
}

.routine-merge-panel summary svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition);
}

.routine-merge-panel[open] summary {
    color: var(--text);
}

.routine-merge-panel[open] summary svg {
    transform: rotate(180deg);
}

.routine-merge-panel form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 11px;
    border-radius: 10px;
    background: rgba(5, 10, 16, .25);
}

.routine-merge-panel label,
.routine-merge-panel small {
    color: var(--text-muted);
    font-size: .7rem;
    line-height: 1.7;
}

.routine-merge-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.routine-merge-controls .form-input {
    min-width: 0;
    flex: 1;
}

.routine-merge-controls .btn {
    flex: 0 0 auto;
}

@media (max-width: 430px) {
    .routine-merge-controls {
        align-items: stretch;
        flex-direction: column;
    }
}

.routine-share-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.routine-share-panel-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.routine-share-panel-heading strong {
    font-size: .85rem;
}

.routine-share-panel-heading span,
.routine-share-empty {
    color: var(--text-muted);
    font-size: .72rem;
}

.routine-share-note {
    margin: -3px 0 11px;
    padding: 9px 10px;
    border-inline-start: 2px solid var(--primary);
    color: var(--text-muted);
    background: color-mix(in srgb, var(--primary) 5%, transparent);
    font-size: .68rem;
    line-height: 1.75;
}

.routine-share-note strong {
    display: block;
    margin-top: 2px;
    font-weight: 600;
}

.friend-picker {
    display: grid;
    gap: 6px;
    max-height: 220px;
    margin-bottom: 10px;
    overflow-y: auto;
}

.friend-pick {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
}

.friend-pick:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.friend-pick.is-disabled {
    cursor: default;
    opacity: .52;
}

.friend-pick span {
    overflow: hidden;
    font-size: .8rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-pick small {
    color: var(--text-muted);
    font-size: .68rem;
}

/* Shared progress in feed */
.shared-feed-progress {
    margin: 9px 0 0;
    padding: 10px 0;
    border-block: 1px solid var(--border);
}

.shared-feed-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
}

.shared-feed-symbol {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    flex: 0 0 22px;
    border-radius: 7px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 9%, transparent);
    font-size: .9rem;
}

.shared-feed-heading div {
    min-width: 0;
}

.shared-feed-heading strong,
.shared-feed-heading small {
    display: block;
}

.shared-feed-heading strong {
    font-size: .76rem;
}

.shared-feed-heading small,
.shared-feed-total {
    color: var(--text-muted);
    font-size: .64rem;
}

.shared-feed-total {
    margin-inline-start: auto;
    white-space: nowrap;
}

.shared-member-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.shared-member-state {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: color-mix(in srgb, var(--text-muted) 6%, transparent);
}

.shared-member-state.is-actor {
    border-color: color-mix(in srgb, var(--primary) 28%, transparent);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.shared-member-avatar {
    position: relative;
    flex: 0 0 auto;
}

.shared-member-avatar i {
    position: absolute;
    inset-inline-end: -4px;
    bottom: -3px;
    display: grid;
    width: 15px;
    height: 15px;
    place-items: center;
    border: 2px solid var(--card);
    border-radius: 50%;
    color: #06110A;
    background: var(--text-muted);
    font-size: .55rem;
    font-style: normal;
    font-weight: 900;
}

.shared-member-state.state-completed .shared-member-avatar i { background: var(--success); }
.shared-member-state.state-started .shared-member-avatar i { background: #38BDF8; }
.shared-member-state.state-missed .shared-member-avatar i { background: var(--danger); }
.shared-member-state.state-skipped .shared-member-avatar i { background: var(--warning); }

.shared-member-state > span:last-child {
    min-width: 0;
}

.shared-member-state strong,
.shared-member-state small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shared-member-state strong {
    font-size: .72rem;
}

.shared-member-state small {
    color: var(--text-muted);
    font-size: .63rem;
}

/* Shareable story builder */
.story-create-trigger {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, #A78BFA 38%, var(--border));
    border-radius: 11px;
    color: #DDD6FE;
    background: linear-gradient(135deg, rgba(124, 58, 237, .14), rgba(34, 197, 94, .06));
    cursor: pointer;
    text-align: right;
    transition:
        border-color var(--transition),
        background var(--transition),
        transform var(--transition);
}

.story-create-trigger:hover {
    border-color: color-mix(in srgb, #A78BFA 62%, var(--border));
    background: linear-gradient(135deg, rgba(124, 58, 237, .20), rgba(34, 197, 94, .09));
}

.story-create-trigger:active {
    transform: scale(.985);
}

.story-create-trigger > span:first-child {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: rgba(167, 139, 250, .14);
    box-shadow: inset 0 0 0 1px rgba(167, 139, 250, .18);
}

.story-create-trigger > span:nth-child(2) {
    flex: 1;
}

.story-create-trigger strong,
.story-create-trigger small {
    display: block;
}

.story-create-trigger strong { font-size: .78rem; }
.story-create-trigger small { color: var(--text-muted); font-size: .66rem; }
.story-create-trigger i { font-style: normal; }

.story-modal {
    position: fixed;
    z-index: 1300;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
}

.story-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 5, 10, .84);
    backdrop-filter: blur(9px);
}

.story-builder {
    position: relative;
    display: grid;
    width: min(100%, 430px);
    max-height: calc(100dvh - 36px);
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    border-color: color-mix(in srgb, var(--primary) 26%, var(--border));
    background:
        radial-gradient(circle at 85% 0, color-mix(in srgb, var(--primary) 12%, transparent), transparent 32%),
        var(--card);
}

.story-builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.story-builder-header h2 {
    margin-top: 2px;
    font-size: 1.05rem;
}

.story-preview-shell {
    width: min(100%, 260px);
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 22px;
    background:
        linear-gradient(#07131A, #07131A) padding-box,
        linear-gradient(145deg, color-mix(in srgb, var(--primary) 60%, #fff), rgba(255,255,255,.10)) border-box;
    box-shadow:
        0 18px 50px rgba(0,0,0,.42),
        0 0 40px color-mix(in srgb, var(--primary) 10%, transparent);
}

#story-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 9 / 16;
}

.story-builder-hint {
    color: var(--text-muted);
    font-size: .72rem;
    line-height: 1.75;
    text-align: center;
}

.story-builder-explanation {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(5, 10, 16, .24);
}

.story-builder-explanation summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 750;
    list-style: none;
}

.story-builder-explanation summary span,
.join-routine-help summary span {
    color: var(--text-muted);
    transition: transform var(--transition);
}

.story-builder-explanation[open] summary span,
.join-routine-help[open] summary span {
    transform: rotate(180deg);
}

.story-builder-explanation > div {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.story-builder-explanation p,
.story-builder-explanation small {
    display: block;
}

.story-builder-explanation p,
.story-builder-explanation small {
    color: var(--text-muted);
    font-size: .66rem;
    line-height: 1.7;
}

.story-builder-explanation small {
    margin-top: 5px;
    color: color-mix(in srgb, var(--warning) 62%, var(--text-muted));
}

.story-builder-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.story-builder-actions .btn {
    min-height: 44px;
}

@media (max-width: 480px) {
    .story-modal {
        place-items: end center;
        padding: 0;
    }

    .story-builder {
        width: 100%;
        max-height: 94dvh;
        padding: 16px 16px max(18px, env(safe-area-inset-bottom));
        border-radius: 24px 24px 0 0;
    }

    .story-preview-shell {
        width: min(100%, 248px);
    }
}

/* Public routine invitation */
.join-routine-page {
    position: relative;
    display: grid;
    min-height: calc(100dvh - var(--nav-total-height) - 36px);
    place-items: center;
    overflow: hidden;
}

.join-routine-glow {
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    filter: blur(60px);
}

.join-routine-card {
    position: relative;
    width: 100%;
    padding: 28px 22px;
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
    text-align: center;
}

.join-brand {
    direction: ltr;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 28px;
}

.join-brand .brand-mark {
    width: 34px;
    height: 34px;
}

.join-brand .brand-wordmark {
    width: 128px;
    height: auto;
}

.join-routine-icon {
    margin-bottom: 12px;
    font-size: 3.6rem;
}

.join-routine-card h1 {
    margin: 7px 0 8px;
    font-size: 1.55rem;
}

.join-routine-card > p {
    color: var(--text-muted);
    font-size: .86rem;
}

.join-routine-meta {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin: 18px 0;
    flex-wrap: wrap;
}

.join-routine-meta span {
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: .68rem;
}

.join-routine-promise {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    padding: 12px;
    border-radius: 12px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    text-align: right;
}

.join-routine-promise p {
    color: var(--text-muted);
    font-size: .72rem;
}

.join-routine-promise strong {
    display: block;
    color: var(--text);
    font-size: .78rem;
}

.join-routine-warning {
    display: grid;
    gap: 2px;
    margin: -8px 0 18px;
    padding: 10px 11px;
    border-inline-start: 2px solid #f5a524;
    border-radius: 9px;
    color: var(--text-muted);
    background: color-mix(in srgb, #f5a524 8%, transparent);
    font-size: .68rem;
    line-height: 1.7;
    text-align: right;
}

.join-routine-warning strong {
    color: color-mix(in srgb, #f5a524 82%, var(--text));
    font-size: .72rem;
}

.join-routine-details {
    display: grid;
    gap: 8px;
    margin: 10px 0 0;
    list-style: none;
    text-align: right;
}

.join-routine-help {
    margin: 0 0 20px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(5, 10, 16, .18);
}

.join-routine-help summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
    list-style: none;
}

.join-routine-help .join-routine-details {
    padding: 0 10px 10px;
}

.join-routine-details li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(5, 10, 16, .22);
}

.join-routine-details li > span {
    color: var(--primary);
    font-size: .75rem;
    font-weight: 900;
}

.join-routine-details p {
    color: var(--text-muted);
    font-size: .67rem;
    line-height: 1.65;
}

.join-routine-details strong {
    display: block;
    color: var(--text);
    font-size: .72rem;
}

.join-skip {
    display: inline-block;
    margin-top: 13px;
    color: var(--text-muted);
    font-size: .75rem;
}

@media (max-width: 380px) {
    .shared-invite-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .shared-invite-actions {
        grid-column: 1 / -1;
    }

    .shared-member-grid {
        grid-template-columns: 1fr;
    }
}

/* First-visit page guide */
body.has-page-guide {
    overflow: hidden;
}

.page-guide {
    position: fixed;
    z-index: 1400;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
}

.page-guide-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(2, 6, 12, .78);
    backdrop-filter: blur(5px);
    cursor: default;
}

.page-guide-card {
    position: relative;
    width: min(100%, 390px);
    padding: 24px;
    border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
    border-radius: 18px;
    background:
        radial-gradient(circle at 88% 0%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 42%),
        var(--card);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .48);
    text-align: right;
    animation: page-guide-enter .24s ease-out both;
}

.page-guide-icon {
    display: grid;
    width: 44px;
    height: 44px;
    margin-bottom: 16px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 32%, transparent);
    border-radius: 14px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.page-guide-icon svg {
    width: 24px;
    height: 24px;
}

.page-guide-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 800;
}

.page-guide-card h2 {
    margin-bottom: 8px;
    font-size: 1.25rem;
}

.page-guide-card p {
    margin-bottom: 22px;
    color: var(--text-muted);
    font-size: .88rem;
    line-height: 1.9;
}

@keyframes page-guide-enter {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .page-guide-card {
        animation: none;
    }
}
