:root {
    --ink: #1f332d;
    --muted: #6d7772;
    --paper: #f5f2eb;
    --surface: #fffdf9;
    --surface-strong: #ffffff;
    --line: #dddcd4;
    --green: #245443;
    --green-dark: #183f32;
    --green-soft: #dce9df;
    --sage: #a9bea9;
    --terracotta: #c46f4f;
    --terracotta-soft: #f3dfd5;
    --gold: #a97a2a;
    --gold-soft: #f7e9c9;
    --blue-soft: #dce8eb;
    --danger: #a3483d;
    --danger-soft: #f8e1dc;
    --shadow-sm: 0 4px 18px rgba(33, 50, 44, .07);
    --shadow-lg: 0 28px 80px rgba(23, 45, 38, .2);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 28px;
    --page-width: 1240px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.has-modal {
    overflow: hidden;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

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

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--terracotta);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 14px 14px 14px 5px;
    background: var(--green);
    color: #fff;
    font-family: Georgia, serif;
    font-size: 1.35rem;
    font-weight: 700;
    box-shadow: 0 7px 16px rgba(36, 84, 67, .2);
}

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 13px;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
.close-button:focus-visible,
.room-tab:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(196, 111, 79, .35);
    outline-offset: 2px;
}

.button-primary {
    background: var(--green);
    color: #fff;
    box-shadow: 0 7px 18px rgba(36, 84, 67, .2);
}

.button-primary:hover {
    background: var(--green-dark);
    box-shadow: 0 10px 24px rgba(36, 84, 67, .25);
}

.button-secondary {
    border-color: #cbd4ce;
    background: var(--surface-strong);
    color: var(--green);
}

.button-secondary:hover {
    border-color: var(--green);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
}

.button-danger-ghost {
    border-color: #e4b8ae;
    background: #fffafa;
    color: var(--danger);
}

.button-wide {
    width: 100%;
}

.button[disabled],
button[disabled] {
    cursor: wait;
    opacity: .65;
    transform: none;
}

/* Auth and first-run */
.auth-page {
    display: grid;
    min-height: 100vh;
    padding: clamp(18px, 5vw, 60px);
    place-items: center;
    background:
        radial-gradient(circle at 8% 12%, rgba(196, 111, 79, .15), transparent 28%),
        radial-gradient(circle at 91% 84%, rgba(36, 84, 67, .17), transparent 32%),
        var(--paper);
}

.auth-shell {
    display: grid;
    width: min(100%, 980px);
    min-height: 620px;
    grid-template-columns: 1.08fr .92fr;
    overflow: hidden;
    border: 1px solid rgba(43, 67, 59, .08);
    border-radius: 34px;
    background: var(--surface-strong);
    box-shadow: var(--shadow-lg);
}

.auth-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px;
    background: linear-gradient(155deg, #dce8dd 0%, #c8d9cc 54%, #b7cdbd 100%);
}

.auth-visual > p {
    max-width: 360px;
    margin: 38px 0 0;
    color: #29463c;
    font-family: Georgia, serif;
    font-size: clamp(1.35rem, 2vw, 1.8rem);
    line-height: 1.3;
    text-align: center;
}

.mini-room {
    position: relative;
    width: min(100%, 370px);
    aspect-ratio: 1.25;
    overflow: hidden;
    border-radius: 28px 28px 60px 28px;
    background: #f8f3e8;
    box-shadow: inset 0 -52px 0 #d4b99c, 0 25px 50px rgba(47, 76, 65, .15);
}

.mini-window {
    position: absolute;
    top: 30px;
    left: 34px;
    width: 100px;
    height: 90px;
    border: 9px solid #fff;
    background: linear-gradient(#bad8df 60%, #d5dfc2 60%);
    box-shadow: 0 4px 12px #264c3c12;
}

.mini-window::before,
.mini-window::after {
    position: absolute;
    content: "";
    background: #fff;
}

.mini-window::before { inset: 0 auto 0 42px; width: 7px; }
.mini-window::after { inset: 38px 0 auto; height: 7px; }

.mini-sofa {
    position: absolute;
    right: 30px;
    bottom: 44px;
    width: 210px;
    height: 76px;
    border-radius: 20px 20px 10px 10px;
    background: #c6795d;
    box-shadow: inset 0 -14px 0 #b5674c;
}

.mini-sofa::before,
.mini-sofa::after {
    position: absolute;
    bottom: 54px;
    width: 98px;
    height: 75px;
    border-radius: 18px 18px 5px 5px;
    background: #d88b6c;
    content: "";
}

.mini-sofa::before { left: 4px; }
.mini-sofa::after { right: 4px; }

.mini-plant {
    position: absolute;
    bottom: 45px;
    left: 35px;
    width: 42px;
    height: 55px;
    border-radius: 4px 4px 18px 18px;
    background: #a76e4a;
}

.mini-plant::before {
    position: absolute;
    bottom: 38px;
    left: -25px;
    width: 88px;
    height: 100px;
    border-radius: 70% 10% 70% 10%;
    background: #567f5c;
    content: "";
    transform: rotate(-18deg);
    clip-path: polygon(50% 0, 72% 45%, 100% 35%, 70% 62%, 85% 100%, 49% 70%, 15% 100%, 28% 61%, 0 38%, 31% 45%);
}

.mini-lamp {
    position: absolute;
    top: 27px;
    right: 43px;
    width: 72px;
    height: 45px;
    border-radius: 50% 50% 10px 10px;
    background: #e2b85f;
}

.mini-lamp::before {
    position: absolute;
    top: -46px;
    left: 34px;
    width: 4px;
    height: 48px;
    background: #47675c;
    content: "";
}

.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(34px, 6vw, 62px);
}

.auth-suite-nav,
.suite-nav {
    display: inline-grid;
    grid-template-columns: repeat(2, max-content);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, .58);
}

.auth-suite-nav {
    align-self: flex-start;
    margin-bottom: 26px;
}

.auth-suite-nav a,
.suite-nav a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 9px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}

.auth-suite-nav a:hover,
.suite-nav a:hover {
    color: var(--green);
    background: rgba(36, 84, 67, .07);
}

.auth-suite-nav a.active,
.suite-nav a.active {
    background: var(--green);
    color: #fff;
    box-shadow: 0 5px 14px rgba(36, 84, 67, .18);
}

.auth-card .brand-mark {
    margin-bottom: 30px;
}

.auth-card h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 600;
    letter-spacing: -.035em;
    line-height: 1.08;
}

.auth-copy {
    margin: 14px 0 28px;
    color: var(--muted);
}

.auth-footnote {
    margin: 20px 0 0;
    color: #909791;
    font-size: .78rem;
    text-align: center;
}

.stack-form {
    display: grid;
    gap: 17px;
}

.stack-form label > span:first-child,
.field > span:first-child {
    display: block;
    margin-bottom: 7px;
    color: #40534c;
    font-size: .84rem;
    font-weight: 700;
}

.stack-form input:not([type="checkbox"]),
.field input,
.field select,
.field textarea,
.filterbar input,
.filterbar select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.stack-form input:not([type="checkbox"]),
.field input,
.field select,
.field textarea {
    padding: 11px 13px;
}

.field textarea {
    min-height: 112px;
    resize: vertical;
}

.stack-form input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.filterbar input:focus,
.filterbar select:focus {
    border-color: #7da18f;
    box-shadow: 0 0 0 4px rgba(36, 84, 67, .09);
}

.password-field {
    position: relative;
    display: block;
}

.password-field input {
    padding-right: 82px !important;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    padding: 6px 7px;
    border: 0;
    background: transparent;
    color: var(--green);
    cursor: pointer;
    font-size: .76rem;
    font-weight: 800;
    transform: translateY(-50%);
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 12px 0;
    cursor: pointer;
}

.check-row input {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    margin: 2px 0 0;
    accent-color: var(--green);
}

.check-row span {
    display: grid;
    gap: 2px;
}

.check-row strong {
    color: var(--ink);
    font-size: .88rem;
}

.check-row small {
    color: var(--muted);
    font-size: .77rem;
    line-height: 1.4;
}

/* App shell */
.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    height: 74px;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(24px, calc((100vw - var(--page-width)) / 2));
    border-bottom: 1px solid rgba(33, 51, 45, .09);
    background: rgba(245, 242, 235, .92);
    backdrop-filter: blur(16px);
}

.topbar > .suite-nav {
    position: absolute;
    left: 50%;
    background: rgba(255, 255, 255, .72);
    transform: translateX(-50%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
}

.brand small,
.brand strong {
    display: block;
}

.brand small {
    margin-bottom: 1px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.brand strong {
    max-width: 330px;
    overflow: hidden;
    font-family: Georgia, serif;
    font-size: 1.1rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 11px;
    color: var(--muted);
    font-size: 1.1rem;
    text-decoration: none;
}

.icon-button:hover {
    background: rgba(36, 84, 67, .08);
    color: var(--green);
}

.text-button,
.link-button {
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: var(--green);
    cursor: pointer;
    font-size: .84rem;
    font-weight: 750;
}

.page-shell {
    width: min(calc(100% - 48px), var(--page-width));
    margin: 0 auto;
    padding: 50px 0 90px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.page-heading h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(2.4rem, 5vw, 4.1rem);
    font-weight: 600;
    letter-spacing: -.05em;
    line-height: 1;
}

.page-heading p:last-child {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.desktop-add span {
    font-size: 1.2rem;
    font-weight: 400;
}

.notice {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    border: 1px solid transparent;
    border-radius: 13px;
    font-size: .88rem;
}

.page-notice {
    margin: 0 0 22px;
}

.notice button {
    flex: 0 0 auto;
    padding: 0 3px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.notice-success {
    border-color: #b7d6c3;
    background: #e8f4eb;
    color: #255239;
}

.notice-error {
    border-color: #e8bbb1;
    background: var(--danger-soft);
    color: #7f352d;
}

.notice-warning {
    border-color: #e9d29e;
    background: #fff4d8;
    color: #765918;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 13px;
    margin-bottom: 34px;
}

.stat-card {
    display: flex;
    min-height: 94px;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(37, 57, 50, .07);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border-radius: 13px;
    font-family: Georgia, serif;
    font-size: 1.35rem;
}

.stat-open .stat-icon { background: var(--blue-soft); color: #3c6570; }
.stat-favorite .stat-icon { background: var(--terracotta-soft); color: var(--terracotta); }
.stat-bought .stat-icon { background: var(--green-soft); color: var(--green); }
.stat-budget .stat-icon { background: var(--gold-soft); color: var(--gold); }

.stat-card div {
    min-width: 0;
}

.stat-card strong,
.stat-card span:last-child {
    display: block;
}

.stat-card strong {
    overflow: hidden;
    font-family: Georgia, serif;
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card span:last-child {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 650;
}

.workspace {
    padding-top: 4px;
}

.room-tabs {
    display: flex;
    gap: 8px;
    margin: 0 -3px 18px;
    padding: 3px;
    overflow-x: auto;
    scrollbar-width: none;
}

.room-tabs::-webkit-scrollbar { display: none; }

.room-tab {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .52);
    color: #586761;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
}

.room-tab span {
    display: grid;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    place-items: center;
    border-radius: 999px;
    background: rgba(33, 51, 45, .07);
    font-size: .68rem;
}

.room-tab:hover,
.room-tab.active {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

.room-tab.active span,
.room-tab:hover span {
    background: rgba(255, 255, 255, .16);
}

.filterbar {
    display: grid;
    grid-template-columns: minmax(230px, 1fr) 170px 185px auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 22px;
}

.search-field {
    position: relative;
}

.search-field > span:not(.visually-hidden) {
    position: absolute;
    top: 50%;
    left: 14px;
    color: #809088;
    font-size: 1.25rem;
    transform: translateY(-52%);
}

.filterbar input,
.filterbar select {
    height: 46px;
    padding: 0 13px;
}

.filterbar .search-field input {
    padding-left: 42px;
}

.filter-submit {
    min-height: 46px;
}

.clear-filter {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.clear-filter:hover { color: var(--danger); }

.todo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.todo-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(32, 51, 45, .09);
    border-radius: 22px;
    background: var(--surface-strong);
    box-shadow: 0 5px 24px rgba(32, 51, 45, .06);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.todo-card:hover {
    z-index: 1;
    border-color: rgba(36, 84, 67, .25);
    box-shadow: 0 16px 38px rgba(32, 51, 45, .12);
    transform: translateY(-3px);
}

.todo-card.status-purchased {
    opacity: .78;
}

.card-link {
    position: absolute;
    z-index: 2;
    inset: 0;
    border-radius: inherit;
}

.card-media {
    position: relative;
    height: 205px;
    overflow: hidden;
    background: #e8e8e1;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.todo-card:hover .card-media img {
    transform: scale(1.035);
}

.media-placeholder,
.detail-placeholder {
    display: grid;
    width: 100%;
    height: 100%;
    place-content: center;
    background:
        linear-gradient(135deg, rgba(255,255,255,.25) 25%, transparent 25%) 0 0 / 32px 32px,
        linear-gradient(315deg, rgba(255,255,255,.25) 25%, transparent 25%) 0 0 / 32px 32px,
        #d8e2d8;
    color: var(--green);
    text-align: center;
}

.media-placeholder span,
.detail-placeholder span {
    font-family: Georgia, serif;
    font-size: 3.2rem;
    line-height: 1;
}

.media-placeholder small,
.detail-placeholder small {
    margin-top: 9px;
    color: #587166;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.status-pill,
.priority-flag,
.soft-badge,
.priority-badge,
.alpha-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.card-media .status-pill {
    position: absolute;
    top: 12px;
    left: 12px;
}

.status-pill {
    min-height: 27px;
    padding: 5px 10px;
}

.status-pill-open { background: rgba(238, 246, 248, .94); color: #3b6670; }
.status-pill-shortlisted { background: rgba(250, 232, 222, .95); color: #9b5039; }
.status-pill-purchased { background: rgba(224, 240, 228, .95); color: #27603f; }

.priority-flag {
    position: absolute;
    top: 12px;
    right: 12px;
    min-height: 27px;
    padding: 5px 10px;
    background: rgba(122, 47, 39, .9);
    color: #fff;
}

.card-body {
    padding: 18px 18px 17px;
}

.card-meta {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    color: #7d8782;
    font-size: .71rem;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.card-body h2 {
    display: -webkit-box;
    min-height: 48px;
    margin: 0;
    overflow: hidden;
    font-family: Georgia, serif;
    font-size: 1.28rem;
    font-weight: 650;
    letter-spacing: -.018em;
    line-height: 1.16;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-subtitle {
    display: -webkit-box;
    min-height: 38px;
    margin: 9px 0 16px;
    overflow: hidden;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.card-footer {
    display: flex;
    min-height: 44px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding-top: 13px;
    border-top: 1px solid #ecece6;
}

.card-price strong,
.card-price small {
    display: block;
}

.card-price strong {
    color: var(--green);
    font-size: .96rem;
}

.card-price small {
    margin-top: 1px;
    color: #8b928e;
    font-size: .68rem;
}

.card-arrow {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border-radius: 50%;
    background: #eef2ed;
    color: var(--green);
    transition: transform .16s ease;
}

.todo-card:hover .card-arrow { transform: translateX(2px); }

.quick-action {
    position: absolute;
    z-index: 4;
    right: 12px;
    bottom: 13px;
    opacity: 0;
    transition: opacity .16s ease;
}

.todo-card:hover .quick-action,
.quick-action:focus-within { opacity: 1; }

.quick-action + * { pointer-events: none; }

.quick-action button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #b7d2bd;
    border-radius: 50%;
    background: #f0f8f2;
    color: var(--green);
    cursor: pointer;
    font-weight: 900;
}

.quick-action ~ .card-body .card-arrow {
    visibility: hidden;
}

.empty-state {
    display: grid;
    min-height: 390px;
    place-items: center;
    align-content: center;
    padding: 50px 20px;
    border: 1px dashed #bdc5bf;
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.42);
    text-align: center;
}

.empty-state h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.8rem;
}

.empty-state > p:not(.eyebrow) {
    max-width: 430px;
    margin: 9px 0 22px;
    color: var(--muted);
}

.empty-illustration {
    position: relative;
    width: 105px;
    height: 78px;
    margin-bottom: 22px;
    border-radius: 12px 12px 30px 12px;
    background: #d8e4d9;
    box-shadow: inset 0 -20px #cfb292;
}

.empty-illustration span:nth-child(1) { position:absolute;left:14px;top:15px;width:27px;height:25px;border:4px solid white;background:#b8d5dc; }
.empty-illustration span:nth-child(2) { position:absolute;right:14px;bottom:16px;width:50px;height:21px;border-radius:8px;background:#c77659; }
.empty-illustration span:nth-child(3) { position:absolute;left:10px;bottom:15px;width:12px;height:26px;border-radius:8px 8px 3px 3px;background:#5e865f; }

.mobile-add {
    position: fixed;
    z-index: 15;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    display: none;
    min-height: 52px;
    align-items: center;
    gap: 6px;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    box-shadow: 0 12px 30px rgba(25, 64, 50, .32);
    font-weight: 800;
    text-decoration: none;
}

.mobile-add span { font-size: 1.2rem; }

/* Modals */
.modal-layer {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(19, 34, 29, .58);
    backdrop-filter: blur(5px);
}

.modal-sheet {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    max-height: min(90vh, 900px);
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 26px;
    background: var(--surface-strong);
    box-shadow: var(--shadow-lg);
    animation: modal-in .22s ease-out both;
    overscroll-behavior: contain;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(.985); }
    to { opacity: 1; transform: none; }
}

.modal-header {
    position: sticky;
    z-index: 3;
    top: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 26px 18px;
    border-bottom: 1px solid #ebece6;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(12px);
}

.modal-header h2,
.detail-content h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(1.65rem, 4vw, 2.3rem);
    font-weight: 650;
    letter-spacing: -.035em;
    line-height: 1.1;
}

.close-button {
    display: grid;
    width: 39px;
    height: 39px;
    flex: 0 0 39px;
    place-items: center;
    border-radius: 50%;
    background: #f0f1ed;
    color: #5e6a65;
    font-size: 1.35rem;
    line-height: 1;
    text-decoration: none;
}

.close-button:hover { background: #e4e8e3; color: var(--ink); }

.todo-form {
    padding: 0 26px 26px;
}

.form-section {
    padding: 23px 0;
    border-bottom: 1px solid #ebece6;
}

.form-section h3 {
    margin: 0 0 14px;
    font-family: Georgia, serif;
    font-size: 1.12rem;
}

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

.section-heading h3 { margin-bottom: 3px; }
.section-heading p,
.section-copy { margin: 0 0 14px; color: var(--muted); font-size: .8rem; }

.alpha-badge {
    padding: 4px 8px;
    background: var(--terracotta-soft);
    color: #975139;
    letter-spacing: .08em;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field + .field,
.field-grid + .field,
.field + .field-grid {
    margin-top: 14px;
}

.field-grid .field + .field { margin-top: 0; }

.field b {
    color: var(--terracotta);
}

.field small {
    color: #8a928e;
    font-weight: 500;
}

.product-form-section {
    margin: 0 -14px;
    padding-right: 14px;
    padding-left: 14px;
    border-radius: 16px;
    background: #f4f8f3;
}

.compact-check {
    padding-bottom: 0;
}

.modal-actions {
    position: sticky;
    z-index: 3;
    bottom: -26px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 0 -26px -26px;
    padding: 17px 26px calc(17px + env(safe-area-inset-bottom));
    border-top: 1px solid #e7e8e2;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
}

/* Detail sheet */
.detail-sheet {
    display: grid;
    width: min(100%, 980px);
    grid-template-columns: minmax(300px, .88fr) 1.12fr;
    overflow: hidden;
}

.floating-close {
    position: absolute;
    z-index: 5;
    top: 16px;
    right: 16px;
    box-shadow: var(--shadow-sm);
}

.detail-media {
    position: sticky;
    top: 0;
    height: min(90vh, 900px);
    min-height: 600px;
    background: #e3e7e1;
}

.detail-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-content {
    min-width: 0;
    padding: 34px 32px 30px;
    overflow-y: auto;
}

.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-right: 42px;
    margin-bottom: 14px;
}

.soft-badge,
.priority-badge {
    min-height: 27px;
    padding: 5px 10px;
    background: #eef0ec;
    color: #65716c;
}

.priority-badge {
    background: var(--danger-soft);
    color: var(--danger);
}

.detail-description {
    margin: 13px 0 22px;
    color: var(--muted);
    font-size: .91rem;
    line-height: 1.65;
}

.price-panel {
    padding: 18px;
    border: 1px solid #d9e1da;
    border-radius: 17px;
    background: #f1f6f1;
}

.price-panel > div:first-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #d9e3db;
}

.price-panel > div > span {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
}

.price-panel > div > strong {
    color: var(--green);
    font-family: Georgia, serif;
    font-size: 1.45rem;
}

.price-panel dl {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 20px;
    margin: 14px 0 0;
}

.price-panel dl div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.price-panel dt,
.price-panel dd {
    margin: 0;
    font-size: .75rem;
}

.price-panel dt { color: var(--muted); }
.price-panel dd { color: var(--ink); font-weight: 750; }

.product-panel {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #e1e2dc;
    border-radius: 17px;
}

.product-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.product-panel h3 {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-family: Georgia, serif;
    font-size: 1.02rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-panel > p {
    display: -webkit-box;
    margin: 12px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.external-link {
    flex: 0 0 auto;
    color: var(--green);
    font-size: .75rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.external-link:hover { text-decoration: underline; }

.preview-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #ecece7;
}

.preview-status > span {
    color: #8a918d;
    font-size: .68rem;
}

.preview-status .link-button {
    padding: 4px 0;
    white-space: nowrap;
}

.due-note {
    margin: 15px 0 0;
    padding: 10px 13px;
    border-radius: 10px;
    background: var(--gold-soft);
    color: #6e551f;
    font-size: .78rem;
}

.status-actions {
    margin-top: 22px;
}

.status-actions > p {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 750;
    text-transform: uppercase;
}

.status-actions > div {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.status-choice {
    width: 100%;
    min-height: 40px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    font-size: .76rem;
    font-weight: 750;
}

.status-choice:hover {
    border-color: var(--green);
    color: var(--green);
}

.status-choice.active {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
    cursor: default;
    opacity: 1;
}

.detail-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid #e9eae4;
}

.settings-sheet {
    width: min(100%, 570px);
}

.about-alpha {
    margin: 20px 0;
    padding: 16px;
    border-radius: 14px;
    background: #f3f4f0;
}

.about-alpha strong {
    font-size: .84rem;
}

.about-alpha p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: .75rem;
}

@media (max-width: 1000px) {
    .topbar > .suite-nav { position: static; margin-left: auto; transform: none; }
    .brand strong { max-width: 220px; }
    .todo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filterbar { grid-template-columns: minmax(190px, 1fr) 160px 180px auto; }
    .clear-filter { grid-column: 1 / -1; }
    .auth-shell { grid-template-columns: .9fr 1.1fr; }
    .auth-visual { padding: 35px; }
    .detail-sheet { width: min(100%, 880px); }
}

@media (max-width: 760px) {
    .auth-page { display: block; padding: 0; background: var(--surface-strong); }
    .auth-shell { min-height: 100vh; grid-template-columns: 1fr; border: 0; border-radius: 0; box-shadow: none; }
    .auth-visual { display: none; }
    .auth-card { justify-content: flex-start; padding: max(44px, env(safe-area-inset-top)) 24px 34px; }
    .auth-card .brand-mark { margin-bottom: 40px; }
    .auth-card h1 { font-size: 2.15rem; }

    .topbar { height: 66px; padding: 0 16px; }
    .brand-mark { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px 12px 12px 4px; }
    .brand-copy { display: none; }
    .topbar > .suite-nav { position: static; margin-left: auto; transform: none; }
    .topbar > .suite-nav a { min-height: 32px; padding: 6px 8px; font-size: .7rem; }
    .text-button { display: none; }

    .page-shell { width: min(calc(100% - 30px), var(--page-width)); padding: 30px 0 104px; }
    .page-heading { margin-bottom: 24px; }
    .page-heading h1 { font-size: 2.55rem; }
    .page-heading p:last-child { max-width: 300px; font-size: .88rem; }
    .desktop-add { display: none; }
    .mobile-add { display: inline-flex; }

    .stats-grid { gap: 9px; margin-bottom: 25px; }
    .stat-card { min-height: 80px; gap: 10px; padding: 13px; border-radius: 15px; }
    .stat-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; font-size: 1.05rem; }
    .stat-card strong { font-size: 1.13rem; }
    .stat-card span:last-child { font-size: .68rem; }

    .room-tabs { margin-right: -15px; padding-right: 15px; }
    .filterbar { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .filter-submit { display: none; }
    .clear-filter { grid-column: 1 / -1; text-align: center; }
    .filterbar input,
    .filterbar select { font-size: .86rem; }

    .todo-grid { grid-template-columns: 1fr; gap: 13px; }
    .todo-card { display: grid; min-height: 154px; grid-template-columns: 142px 1fr; border-radius: 18px; }
    .card-media { height: 100%; min-height: 154px; }
    .card-body { display: flex; min-width: 0; flex-direction: column; padding: 14px; }
    .card-body h2 { min-height: auto; font-size: 1.08rem; -webkit-line-clamp: 2; }
    .product-subtitle { min-height: auto; margin: 6px 0 10px; font-size: .72rem; -webkit-line-clamp: 2; }
    .card-footer { margin-top: auto; padding-top: 9px; }
    .card-price strong { font-size: .85rem; }
    .card-price small { font-size: .62rem; }
    .card-arrow { width: 29px; height: 29px; flex-basis: 29px; }
    .card-media .status-pill { top: 8px; left: 8px; }
    .priority-flag { top: auto; right: 8px; bottom: 8px; padding: 4px 8px; }
    .quick-action { display: none; }
    .quick-action ~ .card-body .card-arrow { visibility: visible; }
    .media-placeholder span { font-size: 2.5rem; }

    .modal-layer { align-items: end; padding: 0; }
    .modal-sheet { width: 100%; max-height: calc(96vh - env(safe-area-inset-top)); border-radius: 24px 24px 0 0; animation-name: sheet-in; }
    @keyframes sheet-in { from { opacity: .5; transform: translateY(50px); } to { opacity: 1; transform: none; } }
    .modal-header { padding: 20px 18px 15px; }
    .todo-form { padding: 0 18px 22px; }
    .form-section { padding: 20px 0; }
    .modal-actions { bottom: -22px; margin: 0 -18px -22px; padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); }

    .detail-sheet { display: block; overflow-y: auto; }
    .detail-media { position: relative; width: 100%; height: min(40vh, 330px); min-height: 240px; }
    .detail-content { overflow: visible; padding: 23px 18px calc(28px + env(safe-area-inset-bottom)); }
    .detail-content h2 { font-size: 1.8rem; }
    .floating-close {
        position: fixed;
        z-index: 6;
        top: max(32px, calc(env(safe-area-inset-top, 0px) + 14px));
        right: max(18px, calc(env(safe-area-inset-right, 0px) + 12px));
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        box-shadow: 0 5px 18px rgba(22, 39, 33, .24);
    }
    .price-panel dl { grid-template-columns: 1fr; }
    .product-panel-head { display: block; }
    .external-link { display: inline-block; margin-top: 12px; }
    .preview-status { align-items: flex-end; }
    .detail-actions .button { flex: 1; }
    .detail-actions form { display: flex; flex: 1; }
    .detail-actions form .button { width: 100%; }
}

@media (max-width: 430px) {
    .auth-suite-nav { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { padding: 0 12px; }
    .topbar > .suite-nav a { padding-right: 6px; padding-left: 6px; font-size: .66rem; }
    .page-shell { width: calc(100% - 24px); }
    .page-heading h1 { font-size: 2.25rem; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { gap: 8px; padding: 11px; }
    .stat-icon { width: 32px; height: 32px; flex-basis: 32px; }
    .todo-card { grid-template-columns: 118px 1fr; }
    .card-meta { font-size: .61rem; }
    .card-body { padding: 12px; }
    .card-body h2 { font-size: 1rem; }
    .status-pill { font-size: .61rem; }
    .field-grid { grid-template-columns: 1fr; gap: 13px; }
    .field-grid .field + .field { margin-top: 0; }
    .modal-header h2 { font-size: 1.65rem; }
    .modal-actions .button { flex: 1; padding-right: 10px; padding-left: 10px; }
    .price-panel > div:first-child { display: block; }
    .price-panel > div > strong { display: block; margin-top: 3px; }
    .status-choice { padding: 6px 4px; font-size: .7rem; }
}

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