:root {
    /* Premium Color Palette */
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-dark: #4f46e5;
    /* Indigo 600 */
    --primary-light: #818cf8;
    /* Indigo 400 */
    --accent-color: #ec4899;
    /* Pink 500 */
    --accent-light: #f472b6;
    /* Pink 400 */

    /* Toggle Switch */
    --toggle-width: 52px;
    --toggle-height: 32px;
    --toggle-bg: #cbd5e1;
    --toggle-checked: #22c55e;

    /* Semantic Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    /* Backgrounds */
    --bg-body: #f1f5f9;
    /* Slate 100 */
    --bg-surface: #ffffff;
    --bg-surface-translucent: rgba(255, 255, 255, 0.85);

    /* Text */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --text-tertiary: #94a3b8;
    /* Slate 400 */
    --text-inverse: #ffffff;

    /* Borders */
    --border-light: #e2e8f0;
    --border-focus: #6366f1;

    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);

    /* Dimensions */
    --header-height: 60px;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Safe Area for Mobile */
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    position: relative;
    /* App-like feel */
}

/* Fixed Background Wrapper */
body.has-wallpaper::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-attachment: scroll; /* Keep scroll, position fixed handles it */
    z-index: -10;
    pointer-events: none;
}

/* Glassmorphism for Wallpaper Mode */
/* Make main containers transparent so the blur doesn't stack too much */
body.has-wallpaper .settings-view,
body.has-wallpaper .finance-view,
body.has-wallpaper #main-content {
    background: transparent !important;
}

/* Inner elements and cards get the frosted glass effect */
body.has-wallpaper .schedule-item,
body.has-wallpaper .settings-list-item,
body.has-wallpaper .calendar-month,
body.has-wallpaper .weekly-grid,
body.has-wallpaper .note-card,
body.has-wallpaper [id$="-form"],
body.has-wallpaper form,
body.has-wallpaper .finance-summary-card,
body.has-wallpaper .journal-list > div,
body.has-wallpaper #kakeibo-legend {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
}

/* Remove stacked backgrounds inside already blurred items */
body.has-wallpaper .schedule-item-inner,
body.has-wallpaper .day-cell {
    background: transparent !important;
}

body.has-wallpaper .app-header {
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
}

body.has-wallpaper .bottom-nav {
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* Utilities */
[hidden] {
    display: none !important;
}

.is-hidden {
    display: none !important;
}

/* Layout */
#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    /* Limit max width for tablet/desktop */
    margin: 0 auto;
    background-color: var(--bg-body);
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.05);
}

/* Header */
.app-header {
    height: auto;
    min-height: 60px;
    background: rgba(255, 255, 255, 0.85);
    /* Hardcode for safety or use var */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: all 0.3s ease;
    gap: 0.5rem;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
    margin-right: auto;
    /* Push controls to right */
}

.header-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

/* Main Content Area */
#main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    padding: var(--space-md);
    padding-bottom: calc(100px + var(--safe-area-bottom));
    /* Space for Bottom Nav */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Force top alignment */
    scroll-behavior: smooth;
}

/* View Toggle (Modern Segmented Control) */
.view-toggle {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.view-toggle .btn {
    padding: 5px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border-radius: 9px;
    border: none;
    transition: all 0.2s ease;
}

.view-toggle .btn:hover {
    color: var(--text-primary);
}

.view-toggle .btn.active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 1px 1px rgba(0, 0, 0, 0.03);
}

/* Buttons */
.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-inverse);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px -1px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: background 0.1s;
}

.btn-secondary:hover {
    background: #f8fafc;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 600;
}

/* Schedule List */
.category-tabs {
    width: 100%;
    overflow-x: auto;
    display: flex;
    gap: var(--space-sm);
    padding: 2px var(--space-xs) var(--space-md) var(--space-xs);
    margin-bottom: var(--space-sm);
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

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

.tab-btn {
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.tab-btn.active {
    background: var(--primary-dark);
    color: var(--text-inverse);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.schedule-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.schedule-item {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    /* Remove padding from parent to allow inner to fill */
    padding: 0;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-drag: none;
}

.schedule-item-inner {
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
    padding: var(--space-md) var(--space-lg);
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
    will-change: transform;
}

.schedule-item-actions {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    z-index: 1;
    background: var(--bg-surface);
    /* Keep it same as card background to avoid red border */
}

.btn-swipe-delete {
    height: 100%;
    width: 80px;
    background: var(--danger-color);
    color: white;
    border: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    gap: 4px;
    transition: background 0.2s;
}

.btn-swipe-delete:active {
    background: #dc2626;
    /* Darker red on press */
}

.btn-swipe-delete i {
    font-size: 1.25rem;
}

.schedule-item.swiping .schedule-item-inner {
    transition: none;
}

.schedule-item:active {
    transform: scale(0.98);
}

.schedule-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.schedule-time {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.schedule-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.schedule-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Category Badges */
.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 6px;
}

.category-badge.category-バイト {
    background: #eff6ff;
    color: #3b82f6;
}

/* Blue */
.category-badge.category-学校 {
    background: #f0fdf4;
    color: #22c55e;
}

/* Green */
.category-badge.category-その他 {
    background: #f3f4f6;
    color: #6b7280;
}

/* Gray */

/* Calendar View */
/* Calendar Slider Layout */
#calendar-view {
    overflow-x: hidden;
    width: 100%;
    position: relative;
    min-height: 400px;
}

.calendar-slider {
    display: flex;
    width: 200%;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    will-change: transform;
    align-items: flex-start;
}

.calendar-view-pane {
    width: 50%;
    flex-shrink: 0;
    height: auto;
}

.calendar-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 20;
}

.view-mode-selector {
    display: flex;
    background: var(--bg-body);
    padding: 2px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.view-mode-btn {
    padding: 4px 12px;
    border: none;
    background: none;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.view-mode-btn.active {
    background: var(--bg-surface);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: bold;
}

.calendar-header-label {
    font-weight: bold;
    color: var(--text-primary);
}
.calendar-view {
    width: 100%;
    max-width: 100%;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    background: var(--bg-surface);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.calendar-month {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
    position: relative;
    touch-action: pan-y;
    /* Allow vertical scroll, but let us handle horizontal swipes */
}

.calendar-slider {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 200%;
    position: relative;
    will-change: transform;
}

.calendar-view-pane {
    flex: 0 0 50%;
    width: 50%;
    height: 100%;
    background: var(--bg-surface);
    flex-shrink: 0;
}

/* Specific heights per mode to avoid unnecessary scrolling in Month view */
[data-view="month"] .calendar-slider {
    height: auto;
}

[data-view="month"] .calendar-view-pane:nth-child(2) {
    height: 0;
    overflow: hidden;
}

[data-view="week"] .calendar-view-pane:nth-child(1) {
    height: 0;
    overflow: hidden;
}

/* Vertical Transition Mode - Removed as per user request */
.calendar-slider.is-vertical,
.calendar-slider.is-vertical .calendar-view-pane {
    display: none;
}

/* Weekly Vertical Grid */
.weekly-vertical-container {
    padding-top: 10px;
}

.weekly-grid {
    display: grid;
    grid-template-columns: 50px repeat(7, 1fr);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    position: relative;
    overflow-x: auto;
}

.weekly-time-col {
    background: #f8fafc;
    border-right: 1px solid var(--border-light);
}

.weekly-hour-cell {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    border-bottom: 1px solid #f1f5f9;
}

.weekly-day-col {
    position: relative;
    border-right: 1px solid #f1f5f9;
    min-width: 0;
}

.weekly-day-header {
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

.weekly-day-header .day-name {
    font-size: 0.7rem;
    font-weight: 700;
}

.weekly-day-header .day-num {
    font-size: 0.9rem;
    font-weight: 600;
}

.weekly-grid-body {
    position: relative;
    height: 1140px;
    /* 19 hours (5:00 to 24:00) * 60px */
}

/* Grid lines for hours */
.weekly-grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.weekly-grid-line {
    position: absolute;
    left: 0;
    width: 100%;
    border-top: 1px solid #f1f5f9;
}

.weekly-event-block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.7rem;
    color: white;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    z-index: 5;
    cursor: grab;
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    touch-action: none;
    /* Prevent scrolling while dragging */
    user-select: none;
}

.weekly-event-block:active {
    cursor: grabbing;
}

.weekly-event-block.dragging {
    opacity: 0.8;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    cursor: grabbing;
}

.weekly-event-block .event-time {
    font-weight: 700;
    font-size: 0.6rem;
    display: block;
    margin-bottom: 2px;
}

.weekly-event-block.type-バイト {
    background: #3b82f6;
}

.weekly-event-block.type-学校 {
    background: #22c55e;
}

.weekly-event-block.type-その他 {
    background: #a855f7;
}

/* Control adjustments */
.view-mode-selector {
    display: flex;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 8px;
    margin-left: 10px;
}

.view-mode-btn {
    padding: 4px 12px;
    font-size: 0.75rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.view-mode-btn.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.month-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #f1f5f9;
    /* Grid lines color */
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.weekday-header {
    background: #f8fafc;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    padding: 8px 0;
}

.weekday-header.sunday {
    color: var(--danger-color);
}

.weekday-header.saturday {
    color: var(--info-color);
}

.day-cell {
    background: var(--bg-surface);
    min-height: 70px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background 0.1s;
}

.day-cell:active {
    background: #f1f5f9;
}

.day-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 2px;
}

/* Today highlight */
.day-cell.is-today .day-number {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.4);
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.event-dot {
    font-size: 0.7rem;
    border-radius: 4px;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
}

.event-dot.type-バイト {
    background: #3b82f6;
}

.event-dot.type-学校 {
    background: #22c55e;
}

.event-dot.type-その他 {
    background: #a855f7;
}

.event-dot.more-count {
    background: #94a3b8;
    text-align: center;
    font-size: 0.65rem;
}

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--space-lg) + var(--safe-area-bottom));
    right: var(--space-lg);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    /* Squircle-ish if supported or keep round */
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.fab svg {
    stroke-width: 2.5;
}

/* Modal */
.modal {
    border: none;
    background: transparent;
    padding: 0;
    margin: auto;
    width: 90%;
    max-width: 480px;
}

#schedule-form {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    /* Larger radius */
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    background: #fff;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    background: #f8fafc;
    transition: all 0.2s;
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    background: #f8fafc;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
}

/* Close button in modal header */
.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around; /* Even distribution */
    overflow: hidden; /* No scrolling */
    z-index: 9999;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    flex: 1; /* Take up equal space */
    min-width: 0;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-tertiary);
    font-size: 0.7rem;
    padding: 8px 0;
    border-radius: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon {
    font-size: 1.5rem;
    line-height: 1;
    filter: grayscale(1);
    opacity: 0.7;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active .nav-icon {
    filter: grayscale(0);
    opacity: 1;
    transform: scale(1.1);
}

/* Adjust FAB position */
.fab {
    bottom: calc(90px + env(safe-area-inset-bottom, 20px));
    z-index: 10001;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.schedule-item {
    position: relative;
    overflow: hidden;
    background: #f8fafc;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.3s ease-out backwards;
}

.schedule-item-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    z-index: 1; /* Behind by default */
}

.schedule-item.swipe-open .schedule-item-actions {
    z-index: 10; /* Bring to front when swiped */
}

.schedule-item-actions.left-actions {
    left: 0;
}

.schedule-item-actions:not(.left-actions) {
    right: 0;
}

.btn-swipe-delete,
.btn-swipe-edit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 100%;
    border: none;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s;
    z-index: 5; /* Ensure it's above the background but below inner when not swiped? No, keep it high when visible */
}

.btn-swipe-delete {
    background: var(--danger-color);
}

.btn-swipe-edit {
    background: var(--primary-color);
}

.btn-swipe-delete:active,
.btn-swipe-edit:active {
    opacity: 0.8;
}

.schedule-item:nth-child(1) {
    animation-delay: 0.05s;
}

.schedule-item:nth-child(2) {
    animation-delay: 0.1s;
}

.schedule-item:nth-child(3) {
    animation-delay: 0.15s;
}

/* Modern Settings UI */
.settings-list-group {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.settings-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: white;
    min-height: 56px;
    transition: background 0.2s;
}

.settings-list-item:active {
    background: #f8fafc;
}

.settings-list-item:last-child {
    border-bottom: none;
}

.settings-icon-box {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 1.1rem;
}

.settings-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.settings-item-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-item-action {
    margin-left: 8px;
    color: #cbd5e1;
}

.settings-section-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Settings Accordion */
.settings-accordion {
    margin-bottom: 1rem;
}

.settings-section-header.accordion-summary {
    list-style: none; /* remove native arrow */
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin: 0;
    border-radius: 8px;
    background: transparent;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.accordion-summary::-webkit-details-marker {
    display: none;
}

.accordion-summary:active {
    background: rgba(0,0,0,0.05);
}

.accordion-icon {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    transition: transform 0.3s ease;
}

.settings-accordion[open] .accordion-icon {
    transform: rotate(180deg);
}

.settings-accordion[open] .settings-list-group {
    animation: fadeIn 0.2s ease-out;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.settings-input-inline {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9rem;
    width: 60px;
}
.finance-view {
    width: 100%;
    max-width: 800px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
}

.finance-view h3 {
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
    font-weight: 700;
}

/* Responsive */
@media (prefers-color-scheme: dark) {
    /* Optional: Add dark mode support logic here if requested, 
       but currently sticking to light mode premium as per root variables */
}

/* Weekend colors in calendar */
.day-cell.sunday .day-number {
    color: var(--danger-color);
}

.day-cell.saturday .day-number {
    color: var(--info-color);
}

/* Mobile Optimizations */
@media (max-width: 600px) {

    /* Layout */
    #main-content {
        padding: var(--space-sm);
        padding-bottom: calc(90px + var(--safe-area-bottom));
    }

    .app-header {
        padding: 0 0.25rem;
        /* Minimize padding */
        height: auto;
        min-height: 50px;
        flex-wrap: nowrap !important;
        gap: 0.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .app-header h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 1;
        min-width: 0;
        margin-right: auto;
    }

    /* Force buttons to stay on one line */
    .view-toggle .btn,
    .header-controls .btn {
        white-space: nowrap !important;
        padding: 4px 6px;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    .schedule-item {
        padding: var(--space-md);
    }

    /* Calendar Mobile */
    .calendar-controls {
        padding: var(--space-sm);
    }

}

.calendar-month {
    padding: var(--space-xs);
}

.day-cell {
    min-height: 50px;
    padding: 2px;
}

.day-number {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
}

.event-dot {
    font-size: 0.65rem;
    padding: 2px 4px;
    margin-bottom: 2px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s;
}

.event-dot:hover {
    opacity: 0.8;
}

/* Category Colors - Always white text for visibility on solid backgrounds */
.category-勉強, .type-勉強 { background-color: #3b82f6 !important; color: #fff !important; } /* Blue */
.category-バイト, .type-バイト { background-color: #8b5cf6 !important; color: #fff !important; } /* Purple */
.category-学校, .type-学校, .category-予定, .type-予定 { background-color: #10b981 !important; color: #fff !important; } /* Green */
.category-遊び, .type-遊び { background-color: #f59e0b !important; color: #fff !important; } /* Orange */
.category-その他, .type-その他 { background-color: #64748b !important; color: #fff !important; } /* Slate */

/* In list view, add a color bar to the left */
.schedule-item-inner {
    border-left: 5px solid transparent;
}

.schedule-item[data-category="勉強"] .schedule-item-inner { border-left-color: #3b82f6; }
.schedule-item[data-category="バイト"] .schedule-item-inner { border-left-color: #8b5cf6; }
.schedule-item[data-category="学校"] .schedule-item-inner,
.schedule-item[data-category="予定"] .schedule-item-inner { border-left-color: #10b981; }
.schedule-item[data-category="遊び"] .schedule-item-inner { border-left-color: #f59e0b; }
.schedule-item[data-category="その他"] .schedule-item-inner { border-left-color: #64748b; }

/* Weekly Event Blocks */
.weekly-event-block {
    position: absolute;
    left: 4px;
    right: 4px;
    padding: 4px;
    border-radius: 6px;
    color: white;
    font-size: 0.75rem;
    overflow: hidden;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    border-left: 3px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.weekly-event-block.dragging {
    opacity: 0.7;
    z-index: 100;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transform: scale(1.02);
}

.weekly-event-block .event-time {
    display: block;
    font-size: 0.65rem;
    font-weight: bold;
    opacity: 0.9;
    margin-bottom: 2px;
}

/* Modal Mobile */
.modal {
    width: 95%;
    max-width: 95%;
}

.modal-body {
    padding: var(--space-md);
    gap: var(--space-md);
}

.form-row {
    flex-direction: column;
    gap: var(--space-md);
}

/* Finance View Mobile */
.finance-view {
    padding: var(--space-sm);
}

#finance-form {
    flex-direction: column;
    align-items: stretch;
}

#finance-form input,
#finance-form select,
#finance-form button {
    width: 100%;
}


/* Toggle Switch Style */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    /* Slate 300 */
    transition: .3s;
    border-radius: 32px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
    background-color: var(--success-color);
    /* Green */
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--success-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Settings Toggle Layout (Merged from toggle.css) */
.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.toggle-item:last-child {
    border-bottom: none;
}

.toggle-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Kakeibo Type Segment Control */
.segment-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    position: relative;
    user-select: none;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.segment-item {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 1;
}

.segment-input {
    display: none;
}

.segment-label {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Active States */
.segment-input:checked+.segment-label {
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: scale(1.02);
}

/* Specific Colors based on value */
.segment-input[value="expense"]:checked+.segment-label {
    background-color: var(--danger-color);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

.segment-input[value="income"]:checked+.segment-label {
    background-color: var(--success-color);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

/* Bookkeeping Specific Styles */
.journal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.journal-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.journal-header {
    background: #f8fafc;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.journal-body {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.journal-debit,
.journal-credit {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.journal-debit {
    text-align: left;
}

.journal-credit {
    text-align: right;
}

.acc-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.acc-amount {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--primary-dark);
}

.journal-sep {
    color: var(--text-tertiary);
    font-size: 1rem;
}

.btn-del-book {
    background: #fee2e2;
    border: none;
    color: #ef4444;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: 10px;
    transition: all 0.2s;
}

.btn-del-book:hover {
    background: #fecaca;
}

.btn-del-book:active {
    background: #fca5a5;
    transform: scale(0.95);
}

.ledger-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ledger-item {
    display: grid;
    grid-template-columns: 45px 1fr 80px 80px;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
    font-size: 0.85rem;
}

.ledger-date {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.ledger-opp {
    color: var(--text-primary);
    font-weight: 500;
}

.ledger-debit-val,
.ledger-credit-val {
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-msg {
    text-align: center;
    color: var(--text-tertiary);
    padding: 2rem;
    font-size: 0.9rem;
}

/* Sticky Note Styles */
.note-form {
    background: white;
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.note-title-input {
    width: 100%;
    border: none;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    outline: none;
    color: var(--text-primary);
}

.note-content-input {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    min-height: 80px;
}

.note-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 1rem;
    flex-wrap: wrap;
}

.note-date-input {
    flex: 1;
    min-width: 120px;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
    color: var(--text-secondary);
    background: #f8fafc;
}

.btn-note-image {
    flex-shrink: 0;
    white-space: nowrap !important;
    font-size: 0.8rem !important;
    padding: 6px 10px !important;
    margin: 0 !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
}

.note-image-preview {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-note-save {
    flex-shrink: 0;
    white-space: nowrap !important;
    padding: 6px 16px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
}

.note-month-header {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 2rem 0 1rem 0.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.note-month-header::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.note-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.note-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.note-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f8fafc;
}

.note-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.note-image:hover {
    transform: scale(1.05);
}

.note-content-wrapper {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.note-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.note-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.note-body {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-actions {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    padding: 4px 0 0 0;
}

.btn-icon-del {
    background: rgba(239, 68, 68, 0.05);
    border: none;
    color: #ef4444;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon-del:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Image Modal */
.image-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation-name: zoom;
    animation-duration: 0.3s;
}

@keyframes zoom {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}