* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background:
        radial-gradient(circle at top left, rgba(185, 110, 77, 0.12), transparent 24%),
        radial-gradient(circle at top right, rgba(68, 108, 99, 0.1), transparent 28%),
        linear-gradient(180deg, #ece3d7 0%, #f6f1e8 100%);
    color: var(--text);
    font-family: "Manrope", sans-serif;
    overflow: hidden;
}

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

button {
    border: 0;
    background: none;
    cursor: pointer;
}

.app-shell {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    overflow: hidden;
}

.phone-frame {
    width: min(100%, 430px);
    height: calc(100vh - 28px);
    background: rgba(255, 250, 244, 0.96);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 38px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.app-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 0%, rgba(185, 110, 77, 0.08), transparent 24%),
        radial-gradient(circle at 88% 8%, rgba(68, 108, 99, 0.08), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0));
    pointer-events: none;
}

.app-header,
.app-main,
.bottom-nav {
    position: relative;
    z-index: 1;
}

.app-header {
    padding: 16px 16px 8px;
}

.eyebrow {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

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

.page-title {
    margin: 0;
    font-size: 25px;
    line-height: 1.04;
    font-family: "Prata", serif;
    font-weight: 400;
}

.page-subtitle {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

.header-action {
    min-width: 40px;
    height: 40px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(24, 50, 47, 0.12);
    box-shadow: 0 10px 20px rgba(20, 28, 25, 0.1);
    color: var(--text);
}

.app-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 12px 104px;
    -webkit-overflow-scrolling: touch;
}

.screen-section {
    margin-bottom: 10px;
}

.glass-card,
.hero-card,
.metric-card,
.route-card,
.list-card,
.sheet-card {
    background: var(--bg-elevated);
    border: 1px solid rgba(24, 50, 47, 0.09);
    backdrop-filter: blur(18px);
    box-shadow: 0 14px 30px rgba(39, 38, 33, 0.1);
}

.hero-card {
    border-radius: var(--radius-lg);
    padding: 14px;
    color: var(--text-inverse);
    background:
        linear-gradient(135deg, rgba(24, 43, 39, 0.97), rgba(59, 92, 84, 0.94)),
        radial-gradient(circle at top left, rgba(196, 162, 120, 0.24), transparent 35%);
}

.hero-card-route {
    padding-top: 16px;
    padding-bottom: 16px;
}

.hero-kicker {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-title {
    margin: 8px 0 4px;
    font-family: "Prata", serif;
    font-size: 21px;
    line-height: 1.06;
}

.hero-meta {
    margin-top: 2px;
    color: rgba(248, 241, 231, 0.82);
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.hero-stat {
    border-radius: 18px;
    padding: 10px;
    background: rgba(255, 250, 244, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: var(--text);
    box-shadow: 0 10px 18px rgba(14, 24, 22, 0.14);
}

.hero-stat-value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
    color: #132421;
    word-break: break-word;
}

.hero-stat-label {
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #56635f;
}

.route-hero-shell {
    display: grid;
    gap: 8px;
}

.route-hero-title {
    font-size: 20px;
    margin: 0;
}

.route-hero-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.route-hero-pill {
    background: rgba(255, 255, 255, 0.18);
    color: #fffdf8;
    border-color: rgba(255, 255, 255, 0.18);
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(18, 29, 27, 0.16);
}

.route-hero-meta-row .route-status {
    color: #fffdf8;
    border-color: rgba(255, 255, 255, 0.18);
    text-shadow: 0 1px 0 rgba(18, 29, 27, 0.16);
}

.route-hero-meta-row .status-planned {
    background: rgba(120, 138, 172, 0.28);
}

.route-hero-meta-row .status-active {
    background: rgba(90, 136, 124, 0.28);
}

.route-hero-meta-row .status-spontaneous {
    background: rgba(185, 110, 77, 0.3);
}

.route-hero-stats .hero-stat {
    background: rgba(255, 255, 255, 0.96);
}

.metric-card {
    border-radius: 18px;
    padding: 10px;
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(24, 50, 47, 0.08);
    box-shadow: 0 8px 18px rgba(24, 34, 31, 0.08);
}

.metric-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 5px;
    font-weight: 700;
}

.metric-value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
}

.section-link {
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(68, 108, 99, 0.1);
    white-space: nowrap;
}

.routes-stack,
.cards-stack,
.timeline-stack,
.checklist-stack {
    display: grid;
    gap: 6px;
}

.route-card {
    border-radius: 22px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(24, 50, 47, 0.1);
}

.plan-step-card {
    border-radius: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(24, 50, 47, 0.1);
    box-shadow: 0 10px 22px rgba(24, 34, 31, 0.06);
}

.plan-step-card.status-doing {
    background: linear-gradient(180deg, rgba(252, 245, 241, 0.98), rgba(255, 255, 255, 0.98));
    border-color: rgba(185, 110, 77, 0.24);
}

.plan-step-card.status-done {
    background: linear-gradient(180deg, rgba(243, 248, 247, 0.98), rgba(255, 255, 255, 0.98));
    border-color: rgba(68, 108, 99, 0.24);
}

.plan-result-box {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(244, 247, 246, 0.96);
    border: 1px solid rgba(24, 50, 47, 0.09);
}

.plan-result-copy {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text);
}

.route-open {
    width: 100%;
    text-align: left;
}

.route-topline,
.route-meta,
.chip-row,
.inline-stat-row,
.quick-grid,
.tab-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.route-status,
.chip,
.soft-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-planned {
    background: rgba(108, 126, 161, 0.16);
    color: #4d617f;
    border-color: rgba(108, 126, 161, 0.22);
}

.status-active {
    background: rgba(68, 108, 99, 0.16);
    color: #355a52;
    border-color: rgba(68, 108, 99, 0.22);
}

.status-spontaneous {
    background: rgba(185, 110, 77, 0.16);
    color: #9a5f43;
    border-color: rgba(185, 110, 77, 0.22);
}

.soft-pill,
.chip {
    background: rgba(24, 50, 47, 0.07);
    color: var(--text);
    border-color: rgba(24, 50, 47, 0.1);
}

.route-hero-meta-row .soft-pill,
.route-hero-meta-row .route-status {
    color: #fffdf8;
    border-color: rgba(255, 255, 255, 0.18);
    text-shadow: 0 1px 0 rgba(18, 29, 27, 0.16);
}

.route-hero-meta-row .soft-pill {
    background: rgba(255, 255, 255, 0.18);
}

.route-hero-meta-row .status-planned {
    background: rgba(120, 138, 172, 0.28);
}

.route-hero-meta-row .status-active {
    background: rgba(90, 136, 124, 0.28);
}

.route-hero-meta-row .status-spontaneous {
    background: rgba(185, 110, 77, 0.3);
}

.route-title {
    margin: 6px 0 3px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.route-title-sm {
    font-size: 15px;
}

.route-title-archive {
    font-size: 16px;
}

.route-title-inline {
    margin: 0;
}

.route-desc,
.muted-copy {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}

.route-note-spaced {
    margin-top: 8px;
}

.route-note-compact {
    margin-top: 6px;
}

.inline-stat {
    min-width: calc(50% - 4px);
    background: rgba(247, 249, 248, 0.98);
    border-radius: 15px;
    padding: 8px 10px;
    border: 1px solid rgba(24, 50, 47, 0.08);
}

.route-card-stats {
    margin-top: 10px;
}

.inline-stat strong {
    display: block;
    font-size: 14px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: stretch;
}

.action-card {
    border-radius: 20px;
    padding: 12px;
    min-height: 88px;
    text-align: left;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(24, 50, 47, 0.08);
    box-shadow: 0 14px 28px rgba(24, 34, 31, 0.1);
    min-width: 0;
}

.action-card.primary {
    color: var(--text-inverse);
    background: linear-gradient(135deg, #34574f, #4c7b70);
}

.action-card.secondary {
    color: var(--text-inverse);
    background: linear-gradient(135deg, #a6674a, #c07b59);
}

.action-card.neutral {
    background: rgba(255, 255, 255, 0.98);
}

.action-card-title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 800;
}

.action-card-copy {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    opacity: 0.9;
}

.budget-amount {
    flex: 0 0 auto;
    align-self: center;
    font-size: 14px;
    color: var(--text);
}

.list-card {
    border-radius: 20px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.98);
}

.list-item {
    padding: 10px 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.list-item-history {
    padding: 0;
}

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

.list-badge {
    min-width: 34px;
    height: 34px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: #8f543b;
    border: 1px solid rgba(185, 110, 77, 0.14);
}

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

.item-actions {
    flex: 0 0 auto;
}

.chip-title-row {
    align-items: center;
}

.list-title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
}

.list-meta {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.list-note {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
}

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

.tab-button {
    white-space: nowrap;
    width: 100%;
    padding: 8px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-muted);
    border: 1px solid rgba(24, 50, 47, 0.1);
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 6px 16px rgba(24, 34, 31, 0.05);
}

.tab-button.active {
    background: var(--surface-dark);
    color: var(--text-inverse);
    border-color: rgba(24, 50, 47, 0.42);
    box-shadow: 0 10px 24px rgba(24, 50, 47, 0.2);
}

.sheet-card {
    border-radius: 22px;
    padding: 12px;
    background: rgba(255,255,255,0.98);
}

.bottom-nav {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    border-radius: 20px;
    background: rgba(15, 26, 24, 0.96);
    padding: 7px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    box-shadow: 0 18px 44px rgba(16, 22, 20, 0.28);
    z-index: 3;
}

.nav-button {
    min-height: 44px;
    color: rgba(248, 241, 231, 0.82);
    border-radius: 14px;
    display: grid;
    place-items: center;
    gap: 4px;
    border: 1px solid transparent;
}

.nav-button.active {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-inverse);
    border-color: rgba(255,255,255,0.12);
}

.nav-icon {
    font-size: 15px;
}

.nav-label {
    font-size: 9px;
    font-weight: 700;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 23, 22, 0.48);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    z-index: 50;
}

.modal-sheet {
    width: min(100%, 430px);
    border-radius: 24px 24px 18px 18px;
    background: rgba(255, 250, 243, 0.99);
    padding: 16px;
    box-shadow: 0 24px 60px rgba(8, 11, 10, 0.28);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(24, 50, 47, 0.1);
}

.field-grid {
    display: grid;
    gap: 8px;
}

.field {
    display: grid;
    gap: 5px;
}

.field label {
    font-size: 11px;
    font-weight: 700;
    color: #41504b;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid rgba(24, 50, 47, 0.14);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    padding: 11px 12px;
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.56);
}

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

.button-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

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

.item-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    margin-left: auto;
}

.item-actions-inline {
    flex-direction: row;
    justify-content: flex-end;
    margin-top: 8px;
}

.mini-action {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-2);
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(68, 108, 99, 0.1);
}

.checklist-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(24, 50, 47, 0.1);
    text-align: left;
}

.checklist-item.is-done {
    background: rgba(241, 247, 245, 0.98);
    border-color: rgba(68, 108, 99, 0.22);
}

.checkmark {
    min-width: 22px;
    height: 22px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(24, 50, 47, 0.16);
    color: #116961;
    font-size: 12px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.9);
}

.checklist-copy {
    font-size: 12px;
    line-height: 1.35;
}

.checklist-item.is-done .checklist-copy {
    text-decoration: line-through;
    color: var(--text-muted);
}

.btn {
    flex: 1;
    min-height: 42px;
    border-radius: 14px;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(24, 34, 31, 0.08);
}

.btn-primary {
    background: linear-gradient(135deg, #31554d, #4c7b70);
    color: var(--text-inverse);
}

.danger-button {
    background: linear-gradient(135deg, #9a5d45, #b97456);
}

.btn-secondary {
    background: rgba(24, 50, 47, 0.12);
    color: var(--text);
}

.field-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.field-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(24, 50, 47, 0.1);
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
}

.chip-remove {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(24, 50, 47, 0.12);
    color: #4e5d58;
    font-size: 12px;
    padding: 0;
}

.danger-link {
    color: #9c5d45;
    background: rgba(185, 110, 77, 0.12);
}

.markdown-box {
    background: #142421;
    color: #d9f5ef;
    border-radius: 18px;
    padding: 10px;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
    font-size: 10px;
    line-height: 1.4;
    border: 1px solid rgba(217, 245, 239, 0.08);
}

@media (max-width: 520px) {
    .app-shell {
        padding: 0;
    }

    .phone-frame {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .app-main {
        padding-bottom: 116px;
    }
}

@media (max-width: 390px) {
    .hero-kicker {
        padding: 5px 8px;
        font-size: 9px;
    }

    .hero-title,
    .route-hero-title {
        font-size: 18px;
    }

    .hero-meta {
        font-size: 11px;
    }

    .route-hero-meta-row {
        gap: 5px;
    }

    .hero-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .hero-stat {
        padding: 9px 8px;
        border-radius: 16px;
    }

    .hero-stat-value {
        font-size: 15px;
    }

    .hero-stat-label {
        font-size: 9px;
    }

    .section-header {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .section-link {
        width: auto;
        justify-content: center;
        text-align: center;
    }

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

    .route-topline,
    .chip-row {
        gap: 4px;
    }

    .route-status,
    .chip,
    .soft-pill {
        padding: 4px 8px;
        font-size: 10px;
    }

    .inline-stat-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-stat-row .inline-stat:last-child:first-child,
    .inline-stat-row .inline-stat:last-child:nth-child(3) {
        grid-column: 1 / -1;
    }

    .inline-stat {
        min-width: 0;
    }

    .list-item {
        gap: 8px;
    }

    .list-badge {
        min-width: 30px;
        height: 30px;
        border-radius: 10px;
    }

    .item-actions {
        width: auto;
        flex-direction: column;
        justify-content: flex-start;
        margin-left: auto;
        margin-top: 0;
    }

    .item-actions-inline {
        width: auto;
        flex-direction: row;
        justify-content: flex-end;
        margin-left: auto;
        margin-top: 8px;
    }

    .compact-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .record-item {
        display: grid;
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 8px;
    }

    .record-item .list-badge {
        grid-column: 1;
        grid-row: 1;
    }

    .record-item .list-body {
        grid-column: 2;
        min-width: 0;
    }

    .record-actions {
        grid-column: 2;
        width: 100%;
        flex-direction: row;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 4px;
    }

    .budget-item {
        display: grid;
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 8px;
    }

    .budget-item .list-badge {
        grid-column: 1;
        grid-row: 1;
    }

    .budget-item .list-body {
        grid-column: 2;
        min-width: 0;
    }

    .budget-amount {
        grid-column: 2;
        justify-self: start;
        margin-top: 2px;
    }

    .budget-actions {
        grid-column: 2;
        width: 100%;
        flex-direction: row;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 4px;
    }

    .mini-action {
        padding: 5px 8px;
    }

    .nav-button {
        min-height: 42px;
    }
}

@media (max-width: 350px) {
    .app-main {
        padding-left: 10px;
        padding-right: 10px;
    }

    .hero-card,
    .route-card,
    .sheet-card,
    .list-card,
    .plan-step-card {
        padding: 10px;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .route-hero-meta-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .tab-row {
        gap: 6px;
    }

    .tab-button {
        padding: 7px 8px;
        font-size: 11px;
    }

    .nav-label {
        font-size: 8px;
    }
}
