/* =========================
   1) Design tokens
   ========================= */
:root {
    color-scheme: light;
    
    /* Color Palette - Apple Light Mode */
    --bg: #f5f5f7;
    --bg-secondary: #ffffff;
    --surface: rgba(255, 255, 255, 0.75);
    --surface-subtle: rgba(255, 255, 255, 0.5);
    --border: rgba(0, 0, 0, 0.06);
    --text: #1d1d1f;
    --text-secondary: #76767f;
    --accent: #007AFF;
    --accent-subtle: rgba(0, 122, 255, 0.1);
    --danger: #FF3B30;
    
    /* Spacing (8pt system) */
    --sp-4: 4px;
    --sp-6: 6px;
    --sp-8: 8px;
    --sp-10: 10px;
    --sp-12: 12px;
    --sp-16: 16px;
    --sp-20: 20px;
    --sp-24: 24px;
    --sp-28: 28px;
    --sp-32: 32px;
    --sp-40: 40px;
    
    /* Typography */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;
    --text-4xl: 32px;
    --text-5xl: 34px;
    
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-black: 800;
    
    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Radius */
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Layout */
    --sidebar-width: 280px;
    --page-max: 760px;
    --bp-tablet: 1024px;
    --bp-mobile-nav: 920px;
    --bp-mobile: 640px;

    --fab-size: 60px;
    --fab-right: 16px;
    --fab-bottom: 16px;
}

/* =========================
   2) Base / reset
   ========================= */
html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Noto Sans KR", "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overscroll-behavior: none;
    word-break: keep-all;
    overflow-wrap: break-word;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button, input, select {
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

button {
    user-select: none;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    padding: var(--sp-20);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding-bottom: var(--sp-20);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-20);
}

.brand-mark {
    font-size: var(--text-3xl);
    font-weight: var(--font-black);
}

.brand-link,
.topbar-link {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    text-align: left;
}

.brand-link {
    cursor: pointer;
}

.topbar-link {
    font-size: var(--text-lg);
    font-weight: var(--font-black);
    cursor: pointer;
}

.brand-subtitle,
.topbar-subtitle,
.muted {
    color: var(--text-secondary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    flex: 1;
}

.nav-item {
    padding: var(--sp-12) var(--sp-16);
    border-radius: 12px;
    font-weight: var(--font-bold);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: rgba(0, 122, 255, 0.08);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.main-column {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: var(--sp-12);
    padding: 0 var(--sp-16);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(245, 245, 247, 0.75);
    backdrop-filter: blur(24px);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.topbar-title {
    font-weight: var(--font-black);
    font-size: var(--text-lg);
    line-height: 1;
}

.brand-mark,
.topbar-title,
.section-header h1,
.card h1,
.card h2,
.calendar-toolbar h1,
.hero-number {
    font-family: "Plus Jakarta Sans", "Noto Sans KR", "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
    letter-spacing: -0.01em;
}

.topbar-spacer {
    flex: 1;
}

.icon-button,
.fab,
.button-primary,
.button-secondary,
.button-tonal,
.segment,
.card-delete,
.place-result,
.calendar-day {
    border: 0;
    border-radius: 12px;
}

.icon-button {
    width: 44px;
    height: 44px;
    background: transparent;
    color: var(--text);
    font-size: var(--text-2xl);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: rgba(0, 122, 255, 0.08);
    color: var(--accent);
}

.content {
    padding: var(--sp-16) var(--sp-12) calc(var(--fab-size) + var(--fab-bottom) + 20px + env(safe-area-inset-bottom));
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.content::before,
.content::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(60px);
    opacity: 0.35;
}

.content::before {
    width: 240px;
    height: 240px;
    top: -120px;
    right: -80px;
    background: rgba(0, 122, 255, 0.28);
}

.content::after {
    width: 220px;
    height: 220px;
    bottom: 40px;
    left: -100px;
    background: rgba(99, 102, 241, 0.2);
}

.page-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-16);
    padding-bottom: 0;
    max-width: var(--page-max);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-12);
}

.card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    padding: var(--sp-16);
    display: flex;
    flex-direction: column;
    gap: var(--sp-12);
    transition: all 0.2s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.controls-card,
.empty-card,
.calendar-card {
    padding: var(--sp-16);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.accent-card {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.08), rgba(0, 100, 200, 0.05));
    backdrop-filter: blur(24px);
    border: 1px solid rgba(0, 122, 255, 0.25);
    border-radius: var(--radius-xl);
    box-shadow: 0 12px 40px rgba(0, 122, 255, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.accent-card .muted,
.accent-card .light,
.accent-card h1,
.accent-card h2,
.accent-card .recommend-time {
    color: #007AFF;
}

.home-welcome-card {
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.8), rgba(238, 246, 255, 0.62));
    border: 1px solid rgba(255, 255, 255, 0.75);
}

.home-welcome-eyebrow {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.03em;
    color: var(--accent);
    text-transform: uppercase;
}

.home-welcome-title {
    margin: var(--sp-4) 0 0;
    font-size: var(--text-3xl);
    font-weight: var(--font-black);
}

.home-welcome-copy {
    margin: var(--sp-8) 0 0;
}

.home-onboarding-row {
    margin-top: var(--sp-12);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--sp-12);
    border-radius: 14px;
    border: 1px solid rgba(0, 122, 255, 0.18);
    background: rgba(0, 122, 255, 0.08);
    padding: var(--sp-12);
}

.home-onboarding-copy {
    font-size: var(--text-sm);
    line-height: 1.4;
    color: #0f3a71;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-12);
    flex-wrap: wrap;
}

.section-header h1,
.card h1,
.card h2,
.calendar-toolbar h1 {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: var(--font-black);
    line-height: 1.3;
    outline: none;
}

.card h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    line-height: 1.28;
}

.section-header > div:first-child {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.card p {
    margin: 0;
    line-height: 1.45;
}

.muted,
.muted-note {
    line-height: 1.45;
}

.muted {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    letter-spacing: 0.01em;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-8);
}

.segment {
    min-height: 44px;
    background: rgba(200, 210, 230, 0.35);
    color: var(--text);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    transition: all 0.15s ease;
    border: 1px solid rgba(200, 210, 230, 0.3);
}

.segment.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.segment:hover {
    background: rgba(200, 210, 230, 0.5);
    border-color: rgba(200, 210, 230, 0.4);
}

.button-primary,
.button-secondary,
.button-tonal {
    min-height: 44px;
    padding: 0 var(--sp-16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-account {
    margin-top: var(--sp-16);
    padding-top: var(--sp-12);
    border-top: 1px solid var(--border);
    display: grid;
    gap: var(--sp-8);
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    background: #0051cc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

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

.button-secondary {
    background: transparent;
    color: var(--text);
    border: 1.5px solid rgba(0, 0, 0, 0.1);
}

.button-secondary:hover {
    background: rgba(200, 210, 230, 0.3);
    border-color: rgba(0, 0, 0, 0.15);
}

.button-secondary.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button-tonal {
    background: rgba(0, 122, 255, 0.12);
    color: #007AFF;
}

.button-tonal.active {
    background: var(--accent);
    color: #fff;
}

.button-tonal:hover {
    background: rgba(0, 122, 255, 0.2);
}

.button-tonal.icon {
    width: 44px;
    padding: 0;
}

.button-secondary.small {
    min-height: 40px;
    padding: 0 var(--sp-12);
    font-size: var(--text-xs);
}

.topbar .button-tonal {
    min-height: 36px;
    height: 36px;
    padding: 0 var(--sp-12);
    border-radius: 10px;
}

.full {
    width: 100%;
}

.fab {
    position: fixed;
    right: var(--fab-right);
    bottom: calc(var(--fab-bottom) + env(safe-area-inset-bottom));
    width: var(--fab-size);
    height: var(--fab-size);
    background: var(--accent);
    color: white;
    font-size: 32px;
    font-weight: var(--font-black);
    box-shadow: 0 12px 32px rgba(0, 122, 255, 0.35);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 8;
}

.fab:hover {
    box-shadow: 0 16px 40px rgba(0, 122, 255, 0.35);
    transform: scale(1.08);
}

.fab:active {
    transform: scale(0.96);
}

.schedule-card {
    display: grid;
    grid-template-columns: minmax(72px, auto) 4px minmax(0, 1fr) auto;
    gap: var(--sp-10);
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.schedule-card:hover {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(200, 210, 230, 0.15);
}

.schedule-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}

.time-column {
    font-size: var(--text-2xl);
    font-weight: var(--font-black);
    line-height: 1.1;
    word-break: normal;
    overflow-wrap: normal;
    white-space: nowrap;
}

.accent-bar {
    width: 4px;
    min-height: 64px;
    border-radius: 999px;
    background: var(--accent);
}

.schedule-title {
    font-size: var(--text-base);
    font-weight: var(--font-black);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    padding-right: var(--sp-4);
}

.schedule-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    padding-right: var(--sp-4);
}

.badge-row {
    display: flex;
    gap: var(--sp-6);
    flex-wrap: wrap;
    margin-top: var(--sp-6);
    padding-right: var(--sp-4);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 var(--sp-10);
    border-radius: 999px;
    color: #fff;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    gap: var(--sp-4);
    word-break: break-word;
    white-space: nowrap;
}

.badge.prep,
.badge.leave {
    background: var(--accent);
}

.badge.late {
    background: var(--danger);
}

.late-note {
    margin-top: var(--sp-8);
    color: #c41c00;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 var(--sp-8);
    border-radius: 999px;
    font-size: 11px;
    font-weight: var(--font-bold);
    letter-spacing: 0.01em;
}

.status-pill.past {
    background: rgba(107, 114, 128, 0.18);
    color: #4b5563;
}

.save-status {
    margin-top: var(--sp-8);
    text-align: center;
    color: var(--accent);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
}

.save-status.error {
    color: var(--danger);
}

.schedule-card.late {
    border-color: rgba(239, 68, 68, 0.35);
}

.schedule-card.late .accent-bar {
    background: var(--danger);
}

.schedule-card.past {
    background: rgba(230, 232, 236, 0.55);
    border-color: rgba(107, 114, 128, 0.22);
}

.schedule-card.past .accent-bar {
    background: #9ca3af;
}

.schedule-card.past .badge.prep,
.schedule-card.past .badge.leave {
    background: #9ca3af;
}

.schedule-card.past .schedule-title,
.schedule-card.past .schedule-subtitle,
.schedule-card.past .time-column {
    color: #4b5563;
}

.card-delete {
    background: var(--danger);
    color: #fff;
    min-height: 36px;
    padding: 0 var(--sp-12);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    white-space: nowrap;
    align-self: start;
    position: relative;
    z-index: 9;
    transition: all 0.15s ease;
}

.card-delete:hover {
    background: #ff453a;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.25);
}

.card-delete:active {
    transform: scale(0.96);
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-8);
    margin-bottom: var(--sp-12);
}

.weekday-row,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--sp-8);
}

.weekday-row {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    margin-bottom: var(--sp-8);
}

.weekday-row span {
    text-align: center;
}

.calendar-day {
    min-height: 44px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    position: relative;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.calendar-day:hover {
    background: rgba(200, 210, 230, 0.3);
}

.calendar-day.dimmed {
    opacity: 0.45;
}

.calendar-day.past:not(.selected) {
    background: rgba(230, 232, 236, 0.45);
    color: #6b7280;
}

.calendar-day.selected {
    background: var(--accent);
    color: #fff;
    outline: none;
}

.day-dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--accent);
}

.mini-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-8);
}

.mini-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-12);
    padding: var(--sp-12) 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.mini-row:hover {
    color: var(--accent);
}

.mini-row:hover .mini-row-title {
    color: var(--accent);
}

.mini-row:last-child {
    border-bottom: 0;
}

.mini-row.past {
    opacity: 0.72;
}

.mini-row-content {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    min-width: 0;
    flex: 1;
}

.mini-row-title {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: var(--text);
}

.mini-row-subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.place-picker {
    display: flex;
    flex-direction: column;
    gap: var(--sp-8);
}

.place-picker-input {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: var(--sp-12);
    align-items: center;
}

.place-icon {
    opacity: 0.7;
}

.place-input {
    border: 0;
    background: transparent;
    color: var(--text);
    outline: none;
    min-width: 0;
    font-size: var(--text-base);
    transition: all 0.15s ease;
}

.place-input:focus {
    color: var(--accent);
}

.place-results {
    padding: var(--sp-8);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    max-height: 240px;
    overflow: auto;
}

.place-results-title {
    padding: var(--sp-4) var(--sp-12) var(--sp-4);
    font-size: var(--text-xs);
    font-weight: var(--font-black);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.place-empty {
    padding: var(--sp-12);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.place-result {
    text-align: left;
    background: transparent;
    color: var(--text);
    padding: var(--sp-12);
    cursor: pointer;
}

.place-result:hover {
    background: rgba(0, 122, 255, 0.08);
}

.place-result-title {
    font-weight: var(--font-bold);
}

.place-result-subtitle,
.place-selected {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.recent-places {
    display: flex;
    flex-direction: column;
    gap: var(--sp-12);
}

.recent-places-title {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.recent-place-grid {
    display: grid;
    gap: var(--sp-12);
}

.recent-place-card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    padding: var(--sp-12);
    display: flex;
    flex-direction: column;
    gap: var(--sp-8);
}

.recent-place-title {
    font-weight: var(--font-black);
    font-size: var(--text-sm);
}

.recent-place-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.recent-place-actions {
    display: flex;
    gap: var(--sp-8);
    flex-wrap: wrap;
}

.recent-place-actions .button-secondary {
    flex: 1 1 0;
}

.map-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-12);
}

.map-copy h2 {
    margin: 0 0 var(--sp-4);
}

.route-map {
    width: 100%;
    height: 280px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(200, 210, 230, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.form-input {
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    border: 1.5px solid rgba(200, 210, 230, 0.6);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    color: var(--text);
    padding: 0 var(--sp-16);
    box-sizing: border-box;
    font-size: var(--text-base);
    transition: all 0.15s ease;
}

.form-input:hover {
    border-color: rgba(200, 210, 230, 0.8);
    background: rgba(255, 255, 255, 0.7);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.form-input.large {
    min-height: 48px;
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-12);
}

.form-grid label,
.card label {
    display: flex;
    flex-direction: column;
    gap: var(--sp-8);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
}

.mt-12 {
    margin-top: var(--sp-12);
}

.muted-note {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--sp-12);
    margin-bottom: 0;
}

.spacer,
.divider {
    height: var(--sp-12);
}

.divider {
    border-top: 1px solid var(--border);
    height: 0;
}

.recommend-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-12);
}

.recommend-slot {
    border-radius: 12px;
    padding: var(--sp-12);
    background: rgba(0, 122, 255, 0.06);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 122, 255, 0.2);
    transition: all 0.15s ease;
}

.recommend-slot.late {
    background: rgba(255, 59, 48, 0.06);
    border: 1.5px solid rgba(255, 59, 48, 0.25);
    backdrop-filter: blur(16px);
}

.recommend-time {
    font-size: var(--text-4xl);
    font-weight: var(--font-black);
}

.recommend-subtitle {
    margin-top: var(--sp-8);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: #c41c00;
}

.hero-number {
    font-size: var(--text-5xl);
    font-weight: var(--font-black);
    margin-top: var(--sp-8);
}

.insights-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-8);
    margin-bottom: var(--sp-8);
}

.insights-subtitle {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
}

.insights-progress {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.section-pending {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}

.status {
    padding: var(--sp-12) var(--sp-16);
    border-radius: 12px;
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.status.error {
    background: rgba(255, 59, 48, 0.1);
    color: #c41c00;
}

.status.info {
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
}

.action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-12);
    padding-top: var(--sp-4);
    margin-top: var(--sp-8);
}

.switch-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--sp-16);
    font-size: var(--text-sm);
}

.switch-row span {
    text-align: left;
    line-height: 1.35;
}

.switch-input {
    appearance: none;
    width: 50px;
    height: 28px;
    background: #e5e5e7;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.switch-input::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 999px;
    top: 1px;
    left: 1px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.switch-input:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.switch-input:checked::before {
    left: 25px;
    background: #fff;
}

.agenda-quick-nav {
    display: flex;
    gap: var(--sp-8);
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
}

.agenda-quick-nav .button-tonal {
    min-width: 72px;
    padding: 0 var(--sp-16);
    white-space: nowrap;
}

.week-chip-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--sp-8);
}

.week-chip {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    min-height: 56px;
    background: rgba(255, 255, 255, 0.65);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: center;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    cursor: pointer;
}

.week-chip strong {
    font-size: var(--text-sm);
    color: var(--text);
}

.week-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.week-chip.active strong {
    color: #fff;
}

.week-chip.past:not(.active) {
    background: rgba(230, 232, 236, 0.5);
    border-color: rgba(148, 163, 184, 0.35);
}

.next-summary-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-8);
    border-left: 4px solid var(--accent);
}

.next-summary-title {
    font-size: var(--text-xl);
    font-weight: var(--font-black);
}

.next-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-8);
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.next-summary-note {
    color: #007AFF;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
}

.backdrop {
    display: none;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

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

/* =========================
   3) Responsive
   ========================= */
@media (max-width: 1024px) {
    .page-stack {
        max-width: 900px;
    }

    @media (max-height: 900px) {
        :root {
            --fab-bottom: 96px;
        }
    }

    @media (max-height: 760px) {
        :root {
            --fab-bottom: 120px;
        }
    }

    .content {
        padding-left: var(--sp-16);
        padding-right: var(--sp-16);
    }

    .topbar .button-tonal {
        min-width: 0;
        padding: 0 var(--sp-10);
    }
}

@media (max-width: 920px) {
    :root {
        --fab-size: 56px;
        --fab-right: 14px;
        --fab-bottom: 76px;
    }

    .sidebar {
        width: min(84vw, 320px);
        flex-basis: min(84vw, 320px);
        position: fixed;
        left: 0;
        top: 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(0, 0, 0, 0.3);
    }

    .content {
        padding: var(--sp-16) var(--sp-16) calc(96px + env(safe-area-inset-bottom));
    }

    .topbar {
        padding: 0 var(--sp-12);
        height: 56px;
    }

    .topbar-subtitle {
        display: none;
    }
}

@media (min-width: 921px) {
    .topbar .icon-button {
        display: none;
    }

    .backdrop {
        display: none !important;
    }
}

@media (max-width: 640px) {
    :root {
        --fab-size: 54px;
        --fab-right: 12px;
        --fab-bottom: 86px;
    }

    .page-stack {
        gap: var(--sp-16);
        max-width: none;
        margin: 0;
    }

    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-header > div:first-child {
        width: 100%;
    }

    .section-header .button-tonal {
        width: 100%;
    }

    .agenda-quick-nav {
        width: 100%;
    }

    .agenda-quick-nav .button-tonal {
        flex: 1 1 0;
        min-width: 0;
    }

    .week-chip-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .home-welcome-title {
        font-size: var(--text-2xl);
    }

    .home-onboarding-row {
        grid-template-columns: 1fr;
    }

    .insights-head-row {
        align-items: flex-end;
    }

    .schedule-card {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "time delete"
            "bar bar"
            "content content";
        gap: var(--sp-12);
        align-items: start;
    }

    .time-column {
        grid-area: time;
        font-size: var(--text-2xl);
    }

    .accent-bar {
        grid-area: bar;
        width: 100%;
        min-height: 3px;
        height: 3px;
    }

    .schedule-content {
        grid-area: content;
    }

    .card-delete {
        grid-area: delete;
        align-self: start;
    }

    .badge-row {
        gap: var(--sp-4);
        padding-right: 0;
    }

    .form-grid,
    .action-row,
    .recommend-grid,
    .segmented {
        grid-template-columns: 1fr;
    }

    .calendar-grid {
        gap: var(--sp-4);
    }

    .calendar-day {
        min-height: 40px;
        border-radius: 10px;
        font-size: var(--text-xs);
    }

    .calendar-toolbar {
        flex-wrap: wrap;
    }

    .calendar-toolbar h1 {
        flex: 1 1 100%;
        order: 3;
        text-align: center;
        margin-top: var(--sp-4);
    }

    .form-input.large {
        font-size: var(--text-lg);
    }

    .hero-number {
        font-size: var(--text-4xl);
    }

    .recommend-time {
        font-size: var(--text-2xl);
    }

    .action-row {
        grid-template-columns: 1fr 1fr;
    }

    .route-map {
        height: 220px;
    }
}
