:root {
    --bg: #f4f4f4;
    --shell: #ffffff;
    --ink: #111111;
    --muted: #6b6b6b;
    --line: #e6e6e6;
    --chip: #f3f3f3;
    --red: #e53935;
    --green: #7cb342;
    --blue: #29b6f6;
    --orange: #fb8c00;
    --fab-ring: #ff9800;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    --radius: 14px;
    --phone: 390px;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
    color: var(--ink);
    background: #2b2b2b;
}

.app-body,
.guest-body {
    display: flex;
    justify-content: center;
    padding: 24px 12px;
}

.app-shell {
    width: min(100%, var(--phone));
    min-height: min(844px, calc(100vh - 48px));
    background: var(--shell);
    border-radius: 28px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

@media (max-width: 480px) {
    .app-body,
    .guest-body {
        padding: 0;
        background: var(--shell);
    }

    .app-shell {
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
}

.app-header {
    padding: 16px 16px 0;
    position: relative;
}

.app-main {
    flex: 1;
    padding: 12px 16px 96px;
    overflow: auto;
}

.guest-main {
    padding: 24px 20px 32px;
}

.inner-header,
.dash-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inner-title {
    flex: 1;
    font-size: 22px;
    margin: 0;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    position: relative;
}

.search-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f6f6f6;
    border-radius: 999px;
    padding: 8px 12px;
}

.search-form input {
    border: 0;
    background: transparent;
    width: 100%;
    font-size: 14px;
    outline: none;
}

.search-ico {
    color: #888;
}

.filter-icons {
    display: flex;
    align-items: center;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 4px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--chip);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 8px 4px 10px;
    font-size: 12px;
}

.chip.is-active {
    background: #ececec;
    border-color: #ccc;
    font-weight: 600;
}

.icon-btn.is-filtered {
    color: var(--orange);
}

.filter-popover {
    position: absolute;
    right: 16px;
    top: 72px;
    z-index: 25;
    min-width: 220px;
    max-width: calc(100% - 32px);
    max-height: 360px;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 8px 0 10px;
}

.filter-option,
.filter-option-label {
    display: block;
    padding: 10px 14px;
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
}

.filter-option.is-selected {
    font-weight: 700;
    background: #f6f6f6;
}

.filter-option-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    padding-bottom: 4px;
}

.custom-date-form {
    padding: 0 14px 8px;
}

.custom-date-form .field-input {
    margin-bottom: 10px;
}

.custom-date-form .btn-primary {
    margin-top: 4px;
}

.quadrant-body {
    flex: 1;
    overflow: auto;
    min-height: 80px;
}

.priority-list {
    background: #fafafa;
    border-radius: 12px;
    overflow: hidden;
}

.priority-add {
    margin-top: 12px;
}

.task-swipe {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
}

.task-swipe-actions {
    position: absolute;
    inset: 0 0 0 auto;
    display: flex;
}

.swipe-complete,
.swipe-delete {
    border: 0;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 0 14px;
    cursor: pointer;
}

.swipe-complete {
    background: #2e7d32;
}

.swipe-delete {
    background: #c62828;
}

.task-swipe-front {
    position: relative;
    z-index: 1;
    background: #fafafa;
    transition: transform 0.2s ease;
}

.task-swipe.is-open .task-swipe-front {
    transform: translateX(-132px);
}

.task-row {
    display: block;
    padding: 8px 10px 4px;
    text-decoration: none;
    color: inherit;
}

.task-meta {
    display: block;
    font-size: 10px;
    color: var(--muted);
    line-height: 1.3;
}

.task-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-priority {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    font-weight: 600;
}

.search-hit {
    background: #fff3bf;
    color: inherit;
    font-weight: 700;
    padding: 0;
}

.task-row-fallback {
    display: flex;
    gap: 10px;
    padding: 0 10px 8px;
}

.fallback-btn {
    border: 0;
    background: none;
    padding: 0;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    text-decoration: underline;
}

.btn-secondary {
    display: block;
    width: 100%;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin: 8px 0;
}

.sheet .btn-primary {
    margin-top: 8px;
}

.quadrant-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
    min-height: 420px;
}

.quadrant {
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    background: #fafafa;
}

.quadrant-head {
    display: block;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 10px;
    text-decoration: none;
}

.q-red .quadrant-head { background: var(--red); }
.q-green .quadrant-head { background: var(--green); }
.q-blue .quadrant-head { background: var(--blue); }
.q-orange .quadrant-head { background: var(--orange); }

.quadrant-empty {
    flex: 1;
    margin: 0;
    padding: 12px 10px;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.35;
}

.quadrant-add {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: var(--ink);
}

.q-red .quadrant-add { color: var(--red); }
.q-green .quadrant-add { color: var(--green); }
.q-blue .quadrant-add { color: var(--blue); }
.q-orange .quadrant-add { color: var(--orange); }

.bottom-nav {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 72px;
    background: #fff;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    align-items: center;
    padding: 0 8px 10px;
}

.nav-item {
    display: flex;
    justify-content: center;
    color: #222;
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

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

.nav-fab {
    width: 48px;
    height: 48px;
    margin: 0 auto;
    border-radius: 50%;
    background: #111;
    box-shadow: 0 0 0 3px var(--fab-ring);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.hamburger-menu {
    position: fixed;
    z-index: 40;
    width: min(280px, calc(100vw - 48px));
    right: max(16px, calc(50% - (var(--phone) / 2) + 16px));
    bottom: 96px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 8px 8px 16px;
}

.hamburger-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    color: var(--ink);
    text-decoration: none;
    font-size: 15px;
}

.menu-logout {
    display: block;
    margin: 8px 8px 0;
    background: #111;
    color: #fff !important;
    border-radius: 10px;
    justify-content: center !important;
    font-weight: 700;
}

.menu-hint {
    margin: 10px 12px 0;
    font-size: 11px;
    color: var(--muted);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 30;
}

.auth-title {
    font-size: 32px;
    margin: 8px 0 20px;
}

.field-label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 600;
}

.req {
    color: var(--red);
}

.field-input {
    width: 100%;
    border: 1px solid #d9d9d9;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    margin-bottom: 16px;
    background: #fff;
}

.field-input[readonly] {
    background: #f6f6f6;
    color: #444;
}

.support-message {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

.field-error {
    color: #b71c1c;
    font-size: 12px;
    margin: -8px 0 14px;
}

.settings-heading {
    font-size: 16px;
    margin: 18px 0 12px;
}

.settings-profile .auth-form {
    margin-top: 0;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-primary {
    display: block;
    width: 100%;
    background: #111;
    color: #fff;
    border: 0;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.text-link,
.text-link-btn {
    display: block;
    text-align: center;
    margin-top: 14px;
    color: var(--ink);
    background: none;
    border: 0;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

.otp-boxes {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 16px;
    min-width: 0;
}

.otp-box {
    width: 100%;
    min-width: 0;
    height: 48px;
    text-align: center;
    font-size: 20px;
    border: 1px solid #d9d9d9;
    border-radius: 10px;
}

.toast-success {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.toast-success p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-hero {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.auth-hero-svg {
    width: 100%;
    max-width: 280px;
    height: auto;
}

.flash {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.flash-error {
    background: #fdecea;
    color: #b71c1c;
}

.flash-success {
    background: #e8f5e9;
    color: #1b5e20;
}

.page-lead {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.bell-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.notification-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 8px;
}

.notification-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notification-list li + li {
    border-top: 1px solid var(--line);
}

.notification-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    padding: 12px 4px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.notification-row.is-unread {
    background: #fafafa;
    box-shadow: inset 3px 0 0 var(--orange);
    padding-left: 10px;
}

.notification-title {
    font-size: 15px;
    font-weight: 700;
}

.notification-row.is-unread .notification-title {
    font-weight: 800;
}

.notification-message {
    font-size: 13px;
    line-height: 1.35;
    color: var(--ink);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.notification-meta {
    font-size: 12px;
    color: var(--muted);
}

.resend-row {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

.resend-row .text-link-btn {
    display: inline;
    margin: 0;
    font-weight: 700;
    text-decoration: underline;
}

.resend-row .text-link-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: none;
}

.otp-email-hint {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin: -4px 0 16px;
}

.category-list {
    list-style: none;
    margin: 12px 0 20px;
    padding: 0;
}

.category-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.category-name {
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    flex: 1;
}

.category-actions {
    display: flex;
    gap: 2px;
}

.sr-form {
    width: 100%;
    display: none;
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 50;
}

.sheet {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 84px;
    background: #fff;
    border-radius: 16px;
    padding: 18px 16px 12px;
    z-index: 51;
    box-shadow: var(--shadow);
}

.sheet-title {
    margin: 0 0 12px;
    font-size: 20px;
}

.choice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 14px;
}

.recurring-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 14px;
    cursor: pointer;
}

.recurring-row input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.priority-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 0 16px;
}

.priority-choice {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 72px;
    padding: 10px 8px;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.priority-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.priority-choice.q-red { background: var(--red); }
.priority-choice.q-green { background: var(--green); }
.priority-choice.q-blue { background: var(--blue); }
.priority-choice.q-orange { background: var(--orange); }

.priority-choice.is-selected,
.priority-choice:has(input:checked) {
    box-shadow: inset 0 0 0 3px #111;
}

.task-form .field-row .field-input {
    margin-bottom: 6px;
}

.field-hint {
    margin: -4px 0 14px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.recurrence-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin: 0 0 16px;
    background: #fafafa;
}

.type-pills,
.weekday-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.type-pill,
.weekday-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.type-pill input,
.weekday-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-pill.is-selected,
.type-pill:has(input:checked),
.weekday-pill:has(input:checked) {
    background: #111;
    color: #fff;
    border-color: #111;
}

.recurrence-copy {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
}

.interval-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.interval-input,
.month-day-input {
    width: 88px;
    margin-bottom: 0 !important;
}

.inline-select {
    display: inline-block;
    width: auto;
    margin: 0 4px 0 0;
    padding: 8px 10px;
}

.interval-unit {
    font-size: 13px;
}

.analytics-section {
    margin: 8px 0 20px;
}

.analytics-heading {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px;
}

.analytics-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.analytics-chart-wrap {
    width: 140px;
    height: 140px;
    flex: 0 0 140px;
}

.analytics-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: 0;
}

.analytics-legend li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 10px;
}

.analytics-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 3px;
    flex: 0 0 12px;
}

.analytics-legend-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.analytics-legend-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.analytics-empty {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}
