/* ═══════════════════════════════════════
   My Schedule — Apple-style
   ═══════════════════════════════════════ */

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

:root {
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
    --r: 12px;
    --r-sm: 8px;
    --r-xs: 6px;
    --ease: cubic-bezier(.25, .1, .25, 1);
    --spring: cubic-bezier(.175, .885, .32, 1.05);
    --t: .18s;
}

/* ── Light (iOS gray) ── */
[data-theme="light"] {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f2f2f7;
    --surface-3: #e5e5ea;
    --border: rgba(0,0,0,.08);
    --separator: rgba(60,60,67,.12);

    --text: #1c1c1e;
    --text-2: #3c3c43;
    --text-3: #8e8e93;

    --accent: #007aff;
    --accent-bg: rgba(0,122,255,.08);
    --red: #ff3b30;

    --shadow-sm: 0 1px 0 rgba(0,0,0,.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,.06);

    --bar: #007aff;
    --bar-dim: #c7c7cc;
}

/* ── Dark ── */
[data-theme="dark"] {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --border: rgba(255,255,255,.06);
    --separator: rgba(84,84,88,.65);

    --text: #f2f2f7;
    --text-2: #ebebf5;
    --text-3: #636366;

    --accent: #0a84ff;
    --accent-bg: rgba(10,132,255,.12);
    --red: #ff453a;

    --shadow-sm: 0 1px 0 rgba(0,0,0,.3);
    --shadow-md: 0 2px 12px rgba(0,0,0,.4);

    --bar: #0a84ff;
    --bar-dim: #48484a;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.47;
    min-height: 100dvh;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    overflow-x: hidden;
}

/* ═══════════════════════════════════════
   SHELL
   ═══════════════════════════════════════ */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Top Bar ── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 20px;
    background: var(--bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}
.top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.app-title {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* ── Buttons ── */
.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.btn-icon:active { transform: scale(0.9); }
.btn-icon svg { width: 16px; height: 16px; }

.btn-icon-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.btn-icon-sm:active { transform: scale(0.9); }
.btn-icon-sm svg { width: 12px; height: 12px; }

/* ── Theme icon visibility ── */
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none; }

/* ═══════════════════════════════════════
   CONTENT
   ═══════════════════════════════════════ */
.content {
    flex: 1;
    padding: 0 16px 120px;
}

/* ═══════════════════════════════════════
   MONTH CALENDAR
   ═══════════════════════════════════════ */
.cal-wrap {
    margin-top: 4px;
}
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 10px;
    gap: 8px;
}
.month-nav-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--t) var(--ease);
}
.month-nav-btn:active { transform: scale(0.85); }
.month-nav-btn svg { width: 14px; height: 14px; }
.cal-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
#monthLabel {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.back-to-today {
    display: block;
    padding: 3px 14px;
    border-radius: 980px;
    border: none;
    background: var(--accent-bg);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.back-to-today:active { transform: scale(0.95); }
.cal-card {
    background: var(--surface);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}
.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 8px 6px 4px;
}
.cal-weekdays span {
    text-align: center;
    font-size: 0.53125rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 2px 6px 8px;
}
.cal-day {
    position: relative;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 5px;
    gap: 2px;
    border-radius: var(--r-xs);
    transition: background var(--t) var(--ease);
}
.cal-day.duty { cursor: pointer; }
.cal-day.duty:active { background: var(--surface-2); }
.cal-day.out { opacity: .35; }
.cal-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}
.cal-day.today .cal-num {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.cal-hours {
    font-size: 0.46875rem;
    font-weight: 600;
    color: var(--accent);
    font-feature-settings: 'tnum';
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
}
.cal-day.duty .cal-num {
    color: var(--accent);
    font-weight: 600;
}
.cal-day.today.duty .cal-num {
    color: #fff;
}
.cal-day.out .cal-hours { display: none; }

/* ═══════════════════════════════════════
   SEGMENTED CONTROL
   ═══════════════════════════════════════ */
.seg-control {
    display: flex;
    background: var(--surface-2);
    border-radius: var(--r-xs);
    padding: 2px;
    margin-top: 14px;
}
.seg-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: calc(var(--r-xs) - 2px);
    background: transparent;
    color: var(--text-3);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.seg-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--r-sm);
    padding: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-info {
    flex: 1;
    min-width: 0;
}
.stat-value {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-feature-settings: 'tnum';
}
.stat-label {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-3);
    margin-top: 1px;
}

/* ═══════════════════════════════════════
   SCHEDULE LIST — Apple grouped style
   ═══════════════════════════════════════ */
.schedule-list {
    margin-top: 20px;
}
.day-group {
    margin-bottom: 24px;
}
.day-group-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 4px 8px;
}
.day-group-date {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}
.day-group-info {
    font-size: 0.6875rem;
    color: var(--text-3);
    font-feature-settings: 'tnum';
}
.day-group-items {
    background: var(--surface);
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.schedule-card {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 12px;
    transition: background var(--t) var(--ease);
    position: relative;
}
.schedule-card + .schedule-card {
    border-top: 1px solid var(--separator);
}
.schedule-card:active {
    background: var(--surface-2);
}
.schedule-body {
    flex: 1;
    min-width: 0;
}
.schedule-name {
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.schedule-time-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-3);
    font-feature-settings: 'tnum';
}
.schedule-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}
.schedule-badge {
    font-size: 0.625rem;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-bg);
    color: var(--accent);
}
.schedule-notes-text {
    font-size: 0.6875rem;
    color: var(--text-3);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.schedule-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--t);
}
.schedule-card:hover .schedule-actions,
.schedule-card:focus-within .schedule-actions {
    opacity: 1;
}
/* Always show on touch */
@media (hover: none) {
    .schedule-actions { opacity: 1; }
}
.schedule-actions button {
    width: 30px;
    height: 30px;
    border-radius: var(--r-xs);
    border: none;
    background: transparent;
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.schedule-actions button:active { transform: scale(0.85); }
.schedule-actions button svg { width: 15px; height: 15px; }
.schedule-actions .delete-btn:active { color: var(--red); }

/* ═══════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════ */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.empty-icon svg { width: 24px; height: 24px; color: var(--text-3); }
.empty-state p { font-size: 0.8125rem; color: var(--text-3); }
.btn-primary {
    padding: 10px 22px;
    border-radius: 980px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.btn-primary:active { transform: scale(0.96); opacity: .85; }
.btn-secondary {
    padding: 10px 22px;
    border-radius: 980px;
    border: none;
    background: var(--surface-3);
    color: var(--text-2);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.btn-secondary:active { transform: scale(0.96); }

/* ═══════════════════════════════════════
   TODAY BADGE
   ═══════════════════════════════════════ */
.badge-today {
    font-size: 0.5625rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════
   FAB
   ═══════════════════════════════════════ */
.fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,122,255,.35);
    z-index: 90;
    transition: all var(--t) var(--spring);
}
.fab:active { transform: scale(0.88); }
.fab svg { width: 22px; height: 22px; }

/* ═══════════════════════════════════════
   MODAL — bottom sheet
   ═══════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
    background: var(--surface);
    border-radius: var(--r) var(--r) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-bottom: none;
}
.modal-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-3);
    margin: 10px auto 0;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 0;
}
.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}
.modal-body { padding: 16px 20px; }
.modal-footer {
    display: flex;
    gap: 8px;
    padding: 4px 20px 24px;
}
.modal-footer .btn-secondary { flex: 1; }
.modal-footer .btn-primary { flex: 2; }

/* ═══════════════════════════════════════
   EXPORT SHEET
   ═══════════════════════════════════════ */
.export-hint {
    padding: 14px 20px 0;
    font-size: 0.8125rem;
    color: var(--text-3);
}
.export-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 20px 24px;
}
.export-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    padding: 13px 14px;
    border-radius: var(--r-xs);
    border: 1px solid var(--separator);
    background: var(--surface-2);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--t) var(--ease);
}
.export-option:active {
    background: var(--surface-3);
    transform: scale(0.98);
}
.export-option-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}
.export-option-sub {
    font-size: 0.6875rem;
    color: var(--text-3);
}

/* ═══════════════════════════════════════
   FORM FIELDS
   ═══════════════════════════════════════ */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="text"],
input[type="time"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--separator);
    border-radius: var(--r-xs);
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.3;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color var(--t) var(--ease);
    -webkit-appearance: none;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
textarea { resize: vertical; min-height: 56px; }
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background: var(--surface-2);
    border-radius: var(--r-xs);
    border: 1px solid var(--separator);
    cursor: pointer;
    transition: background var(--t) var(--ease);
}
.check-row:active { background: var(--surface-3); }
.check-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.check-row span { font-size: 0.875rem; font-weight: 500; }
.lunch-fields {
    margin-top: 8px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--r-xs);
    border: 1px solid var(--separator);
}

/* ═══════════════════════════════════════
   TOAST
   ═══════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    pointer-events: none;
}
.toast {
    padding: 8px 16px;
    border-radius: 980px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #fff;
    background: var(--text);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    animation: toastIn .3s var(--spring) forwards;
    pointer-events: auto;
}
@keyframes toastIn { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.95); } }

/* ═══════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
@media (prefers-reduced-transparency: reduce) {
    .modal-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
    .top-bar { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ═══════════════════════════════════════
   TABLET+
   ═══════════════════════════════════════ */
@media (min-width: 520px) {
    .app-shell { max-width: 520px; }
    .fab { right: calc(50% - 260px + 28px); }
    .content { padding-bottom: 40px; }
}
