/* Foundations ------------------------------------------------------------- */
@font-face {
    font-family: "UniChat";
    src: url("../../fonts/TTF/ClashDisplay-Variable.ttf") format("truetype");
    font-display: swap;
}

:root {
    --ink: #171717;
    --muted: #6b6b6b;
    --soft: #f6f6f4;
    --line: #e5e5e2;
    --blue: #3157f6;
    --blue-soft: #eef1ff;
    --white: #ffffff;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--ink);
    background: var(--white);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

html.planner-dialog-open,
body.planner-dialog-open {
    overflow: hidden;
    overscroll-behavior: none;
}

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

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

button {
    color: inherit;
}

/* Page shell and landing -------------------------------------------------- */
.shell {
    width: min(100%, 1120px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 18px 88px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    background: rgba(255, 255, 255, 0.91);
    border-bottom: 1px solid rgba(229, 229, 226, 0.8);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-family: "UniChat", sans-serif;
    font-size: 21px;
    font-weight: 650;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.brand-mark {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.topbar-link {
    min-height: 42px;
    padding: 10px 13px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.view[hidden] {
    display: none !important;
}

.landing {
    display: grid;
    min-height: calc(100vh - 156px);
    place-items: center;
    text-align: center;
}

.landing-inner {
    width: min(100%, 680px);
    padding: 56px 0 70px;
}

.eyebrow {
    margin: 0 0 20px;
    color: var(--blue);
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 22px;
    font-family: "UniChat", sans-serif;
    font-size: clamp(47px, 10vw, 78px);
    font-weight: 580;
    line-height: 0.98;
    letter-spacing: -0.045em;
}

.landing-copy {
    width: min(100%, 530px);
    margin: 0 auto 34px;
    color: var(--muted);
    font-size: clamp(17px, 3vw, 20px);
    line-height: 1.55;
}

.primary,
.secondary,
.quiet-button,
.danger-button {
    min-height: 50px;
    padding: 13px 19px;
    border: 1px solid transparent;
    border-radius: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary {
    color: var(--white);
    background: var(--ink);
}

.primary:hover {
    background: #2a2a2a;
    transform: translateY(-1px);
}

.primary.blue {
    background: var(--blue);
}

.secondary {
    background: var(--white);
    border-color: var(--line);
}

.secondary:hover,
.quiet-button:hover {
    background: var(--soft);
}

.quiet-button {
    min-height: 44px;
    padding: 10px 13px;
    color: var(--muted);
    background: transparent;
    border: 0;
    font-weight: 650;
}

.danger-button {
    color: var(--danger);
    background: #fff4f2;
}

.primary:disabled,
.secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Onboarding -------------------------------------------------------------- */
.onboarding-wrap {
    width: min(100%, 690px);
    margin: 38px auto 0;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
}

.progress-track {
    overflow: hidden;
    flex: 1;
    height: 4px;
    background: var(--line);
    border-radius: 999px;
}

.progress-value {
    width: 14.285%;
    height: 100%;
    background: var(--ink);
    border-radius: inherit;
    transition: width 250ms ease;
}

.question-card {
    padding: clamp(24px, 5vw, 42px);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.question-card h2 {
    margin-bottom: 10px;
    font-family: "UniChat", sans-serif;
    font-size: clamp(31px, 6vw, 43px);
    font-weight: 580;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.question-hint {
    margin-bottom: 28px;
    color: var(--muted);
    line-height: 1.5;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
}

.text-input,
.ai-input,
.select-input {
    width: 100%;
    min-height: 52px;
    padding: 13px 15px;
    color: var(--ink);
    background: var(--white);
    border: 1px solid #d4d4d0;
    border-radius: 14px;
    outline: 0;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.text-input:focus,
.ai-input:focus,
.select-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
}

.two-fields {
    display: grid;
    gap: 15px;
    grid-template-columns: 1fr 1fr;
}

.field-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.choice-grid {
    display: grid;
    gap: 10px;
}

.choice-grid.two {
    grid-template-columns: 1fr 1fr;
}

.choice {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 13px 15px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 15px;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.choice:hover {
    border-color: #c7c7c1;
    transform: translateY(-1px);
}

.choice:has(input:checked) {
    background: var(--blue-soft);
    border-color: var(--blue);
}

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

.choice-copy {
    display: block;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.3;
}

.interest-tools {
    position: sticky;
    top: 68px;
    z-index: 2;
    padding-bottom: 10px;
    background: var(--white);
}

.interest-grid {
    display: flex;
    overflow-y: auto;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 330px;
    padding: 2px 2px 10px;
}

.interest-chip {
    min-height: 42px;
    padding: 9px 13px;
    background: var(--soft);
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
}

.interest-chip[aria-pressed="true"] {
    color: var(--white);
    background: var(--ink);
}

.selected-count {
    margin: 10px 2px 0;
    color: var(--muted);
    font-size: 13px;
}

.question-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding: 0 4px;
}

.question-actions .primary {
    margin-left: auto;
}

/* Seven-day planner ------------------------------------------------------- */
.planner-wrap {
    padding: 36px 0 184px;
}

.planner-heading {
    display: grid;
    align-items: end;
    gap: 20px;
    margin-bottom: 26px;
    grid-template-columns: 1fr auto;
}

.planner-heading h1 {
    margin-bottom: 12px;
    font-size: clamp(40px, 7vw, 62px);
}

.planner-summary {
    max-width: 680px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.55;
}

.cost-card {
    min-width: 160px;
    padding: 16px 18px;
    background: var(--soft);
    border-radius: 18px;
    text-align: right;
}

.cost-card span {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
}

.cost-card strong {
    font-size: 25px;
}

.cost-card small {
    display: block;
    max-width: 240px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.planner-toolbar {
    display: flex;
    overflow-x: auto;
    gap: 9px;
    margin: 0 -4px 22px;
    padding: 4px;
    scrollbar-width: none;
}

.planner-toolbar::-webkit-scrollbar {
    display: none;
}

.planner-toolbar button,
.planner-toolbar a {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-height: 43px;
    padding: 9px 13px;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 13px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

.ai-dock {
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 50%;
    z-index: 45;
    width: min(calc(100% - 28px), 760px);
    padding: 11px;
    background: rgba(246, 246, 244, 0.94);
    border: 1px solid rgba(229, 229, 226, 0.92);
    border-radius: 22px;
    box-shadow: 0 16px 45px rgba(16, 24, 40, 0.16);
    backdrop-filter: blur(18px);
    transform: translateX(-50%);
}

.ai-dock[hidden] {
    display: none;
}

.ai-editor {
    display: grid;
    gap: 10px;
    margin: 0;
    grid-template-columns: 1fr auto;
}

.ai-input {
    background: var(--white);
    border-color: transparent;
}

.example-prompts {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin: 9px 0 0;
    padding: 0 1px 3px;
    scrollbar-width: none;
}

.example-prompt {
    flex: 0 0 auto;
    padding: 8px 11px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(229, 229, 226, 0.95);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.improvement-status {
    margin: 7px 3px 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
}

.improvement-status.limit-reached {
    color: var(--danger);
    font-weight: 700;
}

.days-grid {
    display: grid;
    gap: 16px;
}

.day-card {
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.day-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 20px 14px;
}

.day-title {
    margin-bottom: 4px;
    font-family: "UniChat", sans-serif;
    font-size: 27px;
    font-weight: 620;
    letter-spacing: -0.025em;
}

.day-theme {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.day-regenerate {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 12px;
    font-size: 20px;
    cursor: pointer;
}

.activities {
    padding: 0 14px 14px;
}

.activity {
    display: grid;
    width: 100%;
    grid-template-columns: 58px 72px 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 82px;
    padding: 13px 6px;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-top: 1px solid var(--line);
    text-align: left;
    cursor: pointer;
}

.activity-image {
    width: 68px;
    height: 68px;
    object-fit: cover;
    background: var(--soft);
    border-radius: 14px;
}

.activity:first-child {
    border-top: 0;
}

.activity-time {
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.activity-name {
    display: block;
    margin-bottom: 5px;
    font-weight: 720;
    line-height: 1.3;
}

.activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 9px;
    color: var(--muted);
    font-size: 12px;
}

.category-pill {
    padding: 5px 8px;
    color: #525252;
    background: var(--soft);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 720;
    text-transform: capitalize;
}

.free-time {
    margin: 0 20px 19px;
    padding: 12px 14px;
    color: var(--muted);
    background: var(--soft);
    border-radius: 13px;
    font-size: 13px;
    line-height: 1.4;
}

.empty-day {
    padding: 23px 7px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    text-align: center;
}

.save-card {
    display: grid;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
    padding: clamp(22px, 5vw, 34px);
    color: var(--white);
    background: var(--ink);
    border-radius: var(--radius);
    grid-template-columns: 1fr auto;
}

.save-card h2 {
    margin-bottom: 7px;
    font-family: "UniChat", sans-serif;
    font-size: 30px;
    font-weight: 580;
}

.save-card p {
    margin-bottom: 0;
    color: #b8b8b8;
    line-height: 1.5;
}

.save-card .primary {
    color: var(--ink);
    background: var(--white);
}

.saved-label {
    display: inline-flex;
    align-items: center;
    min-height: 50px;
    color: #c7f9cc;
    font-weight: 720;
}

/* Dialogs, feedback and loading states ----------------------------------- */
dialog {
    width: min(calc(100% - 24px), 540px);
    max-height: calc(100vh - 30px);
    margin: auto;
    padding: 0;
    background: var(--white);
    border: 0;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

dialog.dialog-visible {
    opacity: 1;
    transform: scale(1);
}

dialog.dialog-closing {
    pointer-events: none;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(3px);
}

.dialog-inner {
    overflow-y: auto;
    max-height: calc(100vh - 30px);
    padding: 25px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.dialog-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.dialog-top h2 {
    margin-bottom: 8px;
    font-family: "UniChat", sans-serif;
    font-size: 31px;
    font-weight: 600;
    line-height: 1.05;
}

.activity-dialog-image {
    display: block;
    width: 100%;
    max-height: 260px;
    margin: 18px 0;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--soft);
    border-radius: 18px;
}

.dialog-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    background: var(--soft);
    border: 0;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
}

.detail-row {
    display: grid;
    gap: 4px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.detail-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-reason {
    margin: 18px 0;
    padding: 15px;
    background: var(--blue-soft);
    border-radius: 15px;
    line-height: 1.5;
}

.detail-links,
.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 17px;
}

.detail-links a {
    color: var(--blue);
    font-size: 14px;
    font-weight: 700;
}

.move-row {
    display: grid;
    gap: 9px;
    margin-top: 17px;
    grid-template-columns: 1fr auto;
}

.auth-benefits {
    margin: 18px 0 24px;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.75;
}

.auth-dialog-copy {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.auth-actions {
    display: grid;
    gap: 10px;
}

.account-setup-actions {
    margin-top: 24px;
}

#account-setup-dialog h2 {
    margin: 0;
    font-family: "UniChat", sans-serif;
    font-size: 31px;
    font-weight: 600;
    line-height: 1.05;
}

.auth-actions a {
    display: grid;
    place-items: center;
    min-height: 50px;
    border-radius: 15px;
    font-weight: 720;
    text-decoration: none;
}

.auth-actions .signup-link {
    color: var(--white);
    background: var(--ink);
}

.auth-actions .login-link {
    color: var(--ink);
    border: 1px solid var(--line);
}

.loading-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(9px);
}

.loading-layer[hidden] {
    display: none;
}

.loading-card {
    width: min(100%, 440px);
    padding: 28px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-align: center;
}

.spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 17px;
    border: 3px solid var(--line);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 750ms linear infinite;
}

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

.loading-card strong {
    display: block;
    margin-bottom: 7px;
    font-size: 18px;
}

.loading-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.loading-fact {
    margin-top: 22px;
    padding: 17px 18px;
    color: var(--ink);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    text-align: left;
}

.loading-fact[hidden] {
    display: none;
}

.loading-fact span {
    display: block;
    margin-bottom: 6px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.loading-fact p {
    min-height: 4.35em;
    margin: 0;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 110;
    max-width: min(390px, calc(100% - 36px));
    padding: 13px 16px;
    color: var(--white);
    background: var(--ink);
    border-radius: 14px;
    box-shadow: var(--shadow);
    line-height: 1.4;
}

body.planner-active .toast {
    bottom: calc(174px + env(safe-area-inset-bottom));
}

.toast[hidden] {
    display: none;
}

.toast.error {
    background: var(--danger);
}

.noscript {
    margin: 30px auto;
    padding: 18px;
    color: var(--danger);
    background: #fff4f2;
    border-radius: 14px;
    text-align: center;
}

/* Responsive behaviour --------------------------------------------------- */
@media (min-width: 800px) {
    .days-grid {
        grid-template-columns: 1fr 1fr;
    }

    .day-card:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .shell {
        padding-right: 14px;
        padding-left: 14px;
    }

    .two-fields,
    .choice-grid.two,
    .planner-heading,
    .save-card {
        grid-template-columns: 1fr;
    }

    .cost-card {
        width: fit-content;
        text-align: left;
    }

    .ai-editor {
        grid-template-columns: 1fr;
    }

    .planner-wrap {
        padding-bottom: 222px;
    }

    .ai-dock {
        bottom: calc(7px + env(safe-area-inset-bottom));
        width: calc(100% - 14px);
        padding: 9px;
        border-radius: 18px;
    }

    .example-prompts {
        margin-top: 7px;
    }

    body.planner-active .toast {
        bottom: calc(210px + env(safe-area-inset-bottom));
    }

    .activity {
        grid-template-columns: 48px 58px 1fr;
        gap: 9px;
    }

    .activity-image {
        width: 54px;
        height: 54px;
        border-radius: 12px;
    }

    .activity .category-pill {
        display: none;
    }

    .save-card .primary {
        width: 100%;
    }

    dialog {
        width: 100%;
        min-width: 100%;
        max-height: calc(100vh - 18px);
        margin: auto 0 0;
        border-radius: 24px 24px 0 0;
        overflow: hidden;
        opacity: 1;
        transform: translateY(100%);
        transition: transform 0.5s ease;
    }

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

    dialog.dialog-dragging {
        transition: none;
    }

    .dialog-inner {
        height: auto;
        max-height: calc(100vh - 18px);
        padding-bottom: 60px;
    }
}

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