:root {
    --paper: #fbfaf7;
    --white: #ffffff;
    --ink: #1f2937;
    --ink-soft: #667085;
    --line: #deded9;
    --line-dark: #c8c8c1;
    --wash: #f2f1ed;
    --accent: #223149;
    --accent-2: #35445c;
    --danger: #a33a35;
    --success: #2e654a;
    --completed: #858585;
    --radius: 10px;
    --shadow: 0 16px 60px rgba(28, 35, 46, 0.09);
    font-family: "Google Sans Flex", "Google Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-optical-sizing: auto;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 50% -10%, rgba(34, 49, 73, 0.035), transparent 34rem),
        var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: 3px; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

.wordmark {
    display: inline-block;
    color: var(--ink);
    font-size: 1.15rem;
    font-weight: 720;
    letter-spacing: -0.035em;
    text-decoration: none;
}

.wordmark span { color: var(--accent); }
.eyebrow { margin: 0 0 0.85rem; color: var(--accent-2) !important; font-size: 0.72rem !important; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: min(100%, 430px);
    padding: 2.7rem 2.75rem 2.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(31, 41, 55, 0.09);
    box-shadow: var(--shadow);
    border-radius: 18px;
}

.auth-heading { margin: 4.4rem 0 2rem; }
.auth-heading .back-link { display: inline-block; margin-bottom: 2rem; }
.auth-heading h1 { margin: 0; max-width: 9em; font-size: clamp(2.1rem, 8vw, 3.15rem); line-height: 0.98; letter-spacing: -0.065em; font-weight: 710; }
.auth-heading p { margin: 1.1rem 0 0; color: var(--ink-soft); font-size: 0.94rem; line-height: 1.55; }

.form-stack { display: grid; gap: 1rem; }
.form-stack label { display: grid; gap: 0.48rem; font-size: 0.78rem; font-weight: 670; }
.form-stack input:not([type="checkbox"]),
.form-stack textarea,
.form-stack select,
.inline-invite input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--white);
    padding: 0.78rem 0.8rem;
    outline: none;
    font-size: 0.94rem;
    font-weight: 430;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-stack input:focus, .form-stack textarea:focus, .form-stack select:focus, .inline-invite input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 49, 73, 0.09); }
.form-stack small { color: var(--ink-soft); font-weight: 430; }

.check-line { display: flex !important; align-items: center; gap: 0.65rem !important; font-weight: 430 !important; color: var(--ink-soft); }
.check-line input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }

.button {
    display: inline-flex;
    min-height: 43px;
    justify-content: center;
    align-items: center;
    padding: 0.7rem 1rem;
    border: 1px solid transparent;
    border-radius: 7px;
    font-weight: 660;
    font-size: 0.88rem;
    text-decoration: none;
}

.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: #18243a; }
.button.secondary { border-color: var(--line-dark); background: var(--white); color: var(--ink); }
.button.secondary:hover { background: var(--wash); }
.button.text { background: transparent; color: var(--ink-soft); }
.button.compact { min-height: 34px; padding: 0.42rem 0.7rem; background: var(--accent); color: white; }
.auth-links { display: grid; gap: 0.65rem; margin-top: 1.6rem; color: var(--ink-soft); font-size: 0.8rem; }
.auth-links a { color: var(--ink); font-weight: 630; }

.notice { margin: 0 0 1.2rem; padding: 0.8rem 0.9rem; border-radius: 7px; font-size: 0.84rem; line-height: 1.45; }
.notice.success { color: var(--success); background: #edf6f0; }
.notice.error { color: var(--danger); background: #fbefee; }
.field-error { margin: -0.55rem 0 0; color: var(--danger); font-size: 0.76rem; }
.dev-note { padding: 0.8rem; background: #fff8dd; border-radius: 7px; color: #705c1d; font-size: 0.8rem; overflow-wrap: anywhere; }
.back-link { color: var(--ink-soft); font-size: 0.82rem; text-decoration: none; }

.task-shell {
    width: min(100%, 460px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 1rem max(6rem, calc(env(safe-area-inset-bottom) + 5rem));
    background: rgba(255, 255, 255, 0.72);
    position: relative;
}

.task-header {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding-top: max(1.3rem, env(safe-area-inset-top));
    border-bottom: 1px solid var(--line);
    background: var(--white);
}

.day-tabs { display: flex; gap: 2.1rem; }
.day-tab {
    position: relative;
    display: block;
    padding: 0.55rem 0 0.85rem;
    color: #777771;
    font-size: 0.96rem;
    text-decoration: none;
}
.day-tab.active { color: var(--ink); font-weight: 720; }
.day-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }

.menu-wrap { position: relative; }
.icon-button, .task-more, .drag-handle, .dialog-close {
    appearance: none;
    border: 0;
    background: transparent;
}
.menu-trigger { padding: 0.4rem 0.2rem 0.7rem 0.8rem; color: #6a6d70; font-weight: 800; letter-spacing: 0.06em; }
.popover {
    position: absolute;
    z-index: 20;
    top: 2.45rem;
    right: 0;
    width: 205px;
    overflow: hidden;
    border: 1px solid rgba(31, 41, 55, 0.12);
    border-radius: 10px;
    background: var(--white);
    box-shadow: 0 16px 40px rgba(28, 35, 46, 0.14);
}
.popover a, .popover form button { display: block; width: 100%; border: 0; padding: 0.72rem 0.85rem; background: white; color: var(--ink); text-align: left; text-decoration: none; font-size: 0.84rem; }
.popover a:hover, .popover form button:hover { background: var(--wash); }
.menu-identity { display: grid; gap: 0.18rem; padding: 0.8rem 0.85rem; border-bottom: 1px solid var(--line); }
.menu-identity strong { font-size: 0.82rem; }
.menu-identity span { color: var(--ink-soft); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; }

.fab-add {
    position: fixed;
    z-index: 12;
    right: max(1.35rem, calc((100vw - 460px) / 2 + 1.35rem));
    bottom: max(1.35rem, calc(env(safe-area-inset-bottom) + 1rem));
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 24px rgba(34, 49, 73, 0.3);
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.fab-add span { font-size: 2rem; font-weight: 350; line-height: 1; transform: translateY(-1px); }
.fab-add:hover { background: #18243a; box-shadow: 0 10px 28px rgba(34, 49, 73, 0.36); transform: translateY(-2px); }
.fab-add:active { box-shadow: 0 5px 16px rgba(34, 49, 73, 0.28); transform: translateY(0) scale(0.96); }
.fab-add:focus-visible { outline: 3px solid rgba(34, 49, 73, 0.24); outline-offset: 3px; }

.task-list { display: grid; gap: 0.16rem; margin-top: 2.35rem; }
.task-row { position: relative; min-height: 54px; overflow: hidden; border-radius: 6px; touch-action: pan-y; }
.task-row.dragging { opacity: 0.35; }
.task-row.drop-before::before { content: ""; position: absolute; z-index: 5; top: 0; left: 0.4rem; right: 0.4rem; height: 2px; background: var(--accent); }
.swipe-cue { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 1rem; background: #e8edf3; color: var(--accent); font-size: 0.74rem; font-weight: 750; opacity: 0; transition: opacity 100ms ease; }
.task-row.swiping .swipe-cue { opacity: 1; }
.task-shell[data-list="today"] .task-row.swiping-move .swipe-cue,
.task-shell[data-list="tomorrow"] .task-row.swiping-delete .swipe-cue { justify-content: flex-start; }
.task-shell[data-list="tomorrow"] .task-row.swiping-move .swipe-cue,
.task-shell[data-list="today"] .task-row.swiping-delete .swipe-cue { justify-content: flex-end; }
.task-row.swiping-delete .swipe-cue { background: #f6e9e7; color: var(--danger); }

.task-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 0.65rem;
    min-height: 54px;
    padding: 0.38rem 0;
    background: var(--white);
    transition: transform 180ms cubic-bezier(.2,.8,.2,1), background 120ms ease;
}
.task-row:hover .task-content { background: #f4f4f1; }

.task-check { width: 21px; height: 21px; margin-left: 1px; display: grid; place-items: center; padding: 0; border: 1.5px solid #90949a; border-radius: 2px; background: white; color: transparent; }
.task-check span { font-size: 0.8rem; line-height: 1; }
.task-check[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: white; }
.task-open { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0; border: 0; background: transparent; text-align: left; }
.task-title { min-width: 0; font-size: 0.95rem; line-height: 1.45; overflow-wrap: anywhere; }
.label-pill { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 18px; padding: 0.12rem 0.5rem; border-radius: 99px; background: var(--accent); color: white; font-size: 0.59rem; font-weight: 790; letter-spacing: 0.04em; line-height: 1.2; }
.drag-handle { width: 28px; height: 34px; padding: 0; color: #90969e; font-size: 1.13rem; cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.task-more { display: none; width: 28px; height: 34px; padding: 0; color: #757a82; font-weight: 800; }
.task-row.completed .task-title { color: var(--completed); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-row.completed .task-check { border-color: var(--completed); background: var(--completed); color: white; }
.task-row.completed .task-content { background: var(--white); }
.task-row.completed:hover .task-content { background: #f4f4f1; }
.task-row.completed .label-pill { opacity: 0.58; }
.task-actions { position: absolute; z-index: 4; right: 0.2rem; top: 3rem; width: 148px; padding: 0.3rem; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: 0 10px 28px rgba(28,35,46,.12); }
.task-actions button { display: block; width: 100%; padding: 0.55rem; border: 0; background: white; text-align: left; font-size: 0.75rem; }
.task-actions .danger { color: var(--danger); }
.task-row.actions-open { overflow: visible; z-index: 6; }

.empty-state { margin: 4.6rem 0 0; color: var(--ink-soft); text-align: center; font-size: 0.85rem; }
.clear-completed { margin-top: 1.9rem; padding: 0.5rem 0; border: 0; background: transparent; color: #70706d; font-size: 0.8rem; }

.task-dialog { width: min(calc(100% - 2rem), 430px); padding: 0; border: 0; border-radius: 14px; background: white; box-shadow: 0 24px 80px rgba(20,27,39,.22); }
.task-dialog::backdrop { background: rgba(28, 33, 39, 0.32); backdrop-filter: blur(2px); }
.dialog-sheet { display: grid; gap: 1.2rem; padding: 1.2rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 0.8rem; border-bottom: 1px solid var(--line); font-size: 0.78rem; font-weight: 700; }
.dialog-close { width: 32px; height: 32px; color: var(--ink-soft); font-size: 1.5rem; }
.dialog-sheet > label { display: grid; gap: 0.48rem; color: var(--ink-soft); font-size: 0.72rem; font-weight: 650; }
.dialog-sheet input, .dialog-sheet textarea, .dialog-sheet select { width: 100%; padding: 0.72rem; border: 1px solid var(--line); border-radius: 7px; background: white; outline: none; font-size: 0.92rem; color: var(--ink); font-weight: 430; }
.dialog-sheet textarea { resize: vertical; line-height: 1.55; }
.dialog-sheet input:focus, .dialog-sheet textarea:focus, .dialog-sheet select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,49,73,.08); }
.dialog-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.4rem; }
.new-task-actions { justify-content: flex-end; }
.dialog-delete { color: var(--danger) !important; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: max(1.4rem, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 2rem); padding: 0.7rem 0.9rem; border-radius: 7px; background: var(--accent); color: white; box-shadow: 0 10px 32px rgba(28,35,46,.2); font-size: 0.78rem; }

.settings-shell, .message-shell { width: min(100% - 2rem, 480px); margin: 0 auto; padding: max(2rem, env(safe-area-inset-top)) 0 4rem; }
.settings-header { margin-bottom: 3rem; }
.settings-header h1 { margin: 1.15rem 0 0; font-size: clamp(1.9rem, 8vw, 2.6rem); line-height: 1; letter-spacing: -0.055em; }
.settings-section { padding: 1.5rem 0 2.2rem; border-top: 1px solid var(--line); }
.settings-section h2 { margin: 0 0 0.65rem; font-size: 0.82rem; }
.section-copy, .muted { margin: 0 0 1.25rem; color: var(--ink-soft); font-size: 0.78rem; line-height: 1.55; }
.compact-form { margin-top: 1.25rem; }
.label-collection { display: grid; gap: 1rem; }
.label-collection > h2 { margin-bottom: 0; }
.label-card { padding: 1rem; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.7); }
.label-card-head, .invite-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.label-card-head small, .invite-row small { color: var(--ink-soft); font-size: 0.68rem; }
.member-list { margin: 1rem 0; padding: 0; list-style: none; }
.member-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid #ecece8; font-size: 0.75rem; }
.member-list small { color: var(--ink-soft); }
.inline-invite { display: flex; gap: 0.5rem; }
.inline-invite input { padding: 0.58rem 0.65rem; font-size: 0.78rem; }
.inline-invite button { border: 0; border-radius: 6px; background: var(--accent); color: white; font-size: 0.72rem; font-weight: 650; padding: 0 0.75rem; }
.label-actions { margin-top: 0.8rem; }
.label-actions button, .text-danger { padding: 0.25rem 0; border: 0; background: transparent; color: var(--danger); font-size: 0.7rem; }
.invite-row { margin-top: 0.85rem; }
.invite-row > div { display: flex; align-items: center; gap: 0.5rem; }
.logout-block { margin-top: 1rem; }
.security-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.security-row .section-copy { margin-bottom: 0; }
.security-row .button { flex: 0 0 auto; }
.password-actions { justify-content: flex-end; }

.message-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.message-shell h1 { margin: 4rem 0 0.8rem; font-size: 2.6rem; letter-spacing: -0.06em; }
.message-shell p { margin: 0 0 1.5rem; color: var(--ink-soft); line-height: 1.5; }

@media (min-width: 600px) {
    .task-shell { min-height: min(100vh, 760px); margin-top: clamp(1rem, 5vh, 3.5rem); padding: 0 1.4rem 6rem; border: 1px solid rgba(31,41,55,.075); border-radius: 10px; box-shadow: 0 18px 70px rgba(28,35,46,.055); }
    .task-header { padding-top: 1.25rem; }
    .fab-add { bottom: max(1.35rem, calc(100vh - clamp(1rem, 5vh, 3.5rem) - min(100vh, 760px) + 1.35rem)); }
    .task-more { display: none; }
}

@media (max-width: 599px) {
    html { font-size: 18px; }
    body { background: white; }
    .task-shell { padding: 0 1.1rem max(6rem, calc(env(safe-area-inset-bottom) + 5rem)); background: white; }
    .task-header { padding-top: max(1.4rem, env(safe-area-inset-top)); }
    .auth-shell { padding: 0; background: white; }
    .auth-card { min-height: 100vh; padding: max(1.7rem, env(safe-area-inset-top)) 1.25rem 2rem; border: 0; border-radius: 0; box-shadow: none; }
    .wordmark { font-size: 1.25rem; }
    .auth-heading { margin-top: 4.25rem; }
    .auth-heading h1 { font-size: clamp(2.25rem, 10vw, 3.15rem); }
    .auth-heading p { font-size: 1rem; }
    .form-stack { gap: 1.1rem; }
    .form-stack label { font-size: 0.86rem; }
    .form-stack input:not([type="checkbox"]),
    .form-stack textarea,
    .form-stack select { min-height: 50px; font-size: 1rem; }
    .check-line input { width: 21px; height: 21px; }
    .button { min-height: 50px; font-size: 0.96rem; }
    .button.compact { min-height: 42px; }
    .auth-links { font-size: 0.9rem; }
    .notice { font-size: 0.92rem; }
    .field-error { font-size: 0.84rem; }
    .dev-note, .back-link { font-size: 0.9rem; }

    .day-tabs { gap: 2.25rem; }
    .day-tab { padding: 0.65rem 0 0.95rem; font-size: 1.05rem; }
    .menu-trigger { min-width: 44px; min-height: 44px; padding: 0.45rem 0 0.65rem 0.75rem; font-size: 1rem; }
    .popover { top: 2.75rem; width: min(245px, calc(100vw - 2.2rem)); }
    .popover a, .popover form button { min-height: 48px; display: flex; align-items: center; padding: 0.8rem 0.9rem; font-size: 0.92rem; }
    .menu-identity { padding: 0.9rem; }
    .menu-identity strong { font-size: 0.9rem; }
    .menu-identity span { font-size: 0.78rem; }

    .fab-add { right: 1.2rem; bottom: max(1.2rem, calc(env(safe-area-inset-bottom) + 0.9rem)); width: 60px; height: 60px; }
    .fab-add span { font-size: 2.15rem; }
    .task-list { margin-top: 2.2rem; }
    .task-row, .task-content { min-height: 64px; }
    .task-content { grid-template-columns: 30px minmax(0, 1fr) 34px; gap: 0.72rem; padding: 0.45rem 0; }
    .task-check { width: 24px; height: 24px; }
    .task-check span { font-size: 0.9rem; }
    .task-open { padding: 0.65rem 0; }
    .task-title { font-size: 1.05rem; line-height: 1.5; }
    .label-pill { min-height: 21px; padding: 0.14rem 0.55rem; font-size: 0.66rem; }
    .swipe-cue { font-size: 0.82rem; }
    .drag-handle { display: block; width: 34px; height: 44px; font-size: 1.25rem; touch-action: none; }
    .task-more { display: none; }
    .empty-state { font-size: 0.95rem; }
    .clear-completed { min-height: 44px; font-size: 0.9rem; }

    .task-dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; }
    .dialog-sheet { max-height: 90dvh; overflow-y: auto; gap: 1.25rem; padding: 1.35rem 1.1rem max(1.35rem, env(safe-area-inset-bottom)); }
    .dialog-head { font-size: 0.88rem; }
    .dialog-close { width: 44px; height: 44px; font-size: 1.7rem; }
    .dialog-sheet > label { font-size: 0.82rem; }
    .dialog-sheet input, .dialog-sheet textarea, .dialog-sheet select { min-height: 50px; font-size: 1rem; }
    .dialog-sheet textarea { min-height: 7.5rem; }
    .toast { padding: 0.8rem 1rem; font-size: 0.88rem; }

    .settings-shell, .message-shell { width: min(100% - 2.2rem, 480px); }
    .settings-header h1 { font-size: clamp(2.1rem, 9vw, 2.75rem); }
    .settings-section h2 { font-size: 0.92rem; }
    .section-copy, .muted { font-size: 0.88rem; }
    .label-card { padding: 1.1rem; }
    .label-card-head, .invite-row { align-items: flex-start; flex-wrap: wrap; gap: 0.65rem; }
    .label-card-head small, .invite-row small { font-size: 0.77rem; }
    .member-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: flex-start; padding: 0.6rem 0; font-size: 0.84rem; overflow-wrap: anywhere; }
    .member-list small { white-space: nowrap; }
    .inline-invite input { min-width: 0; min-height: 46px; font-size: 0.9rem; }
    .inline-invite button { min-height: 46px; font-size: 0.82rem; }
    .label-actions button, .text-danger { min-height: 44px; display: inline-flex; align-items: center; font-size: 0.8rem; }
    .security-row { align-items: stretch; flex-direction: column; }
}

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