:root {
    /* Premium Color Palette */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    /* Light Theme Basics */
    --bg-base: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-elevated: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
    --nav-bg: rgba(255, 255, 255, 0.9);
    --timeline-line: rgba(0, 0, 0, 0.1);

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --font-inter: 'Inter', sans-serif;
    --font-title: 'Outfit', sans-serif;

    /* Layout */
    --nav-height: 70px;
    --header-height: 80px;
}

[data-theme="dark"] {
    --bg-base: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-elevated: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --nav-bg: rgba(15, 23, 42, 0.9);
    --timeline-line: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: var(--font-inter);
    background-color: var(--bg-base);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.title-font {
    font-family: var(--font-title);
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.text-danger {
    color: var(--danger);
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cursor-pointer {
    cursor: pointer;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-inter);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:active {
    transform: scale(0.97);
    background: var(--border-color);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

.icon-btn:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.btn-toggle {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--primary);
    color: white;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 100px 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* Header */
.main-header {
    padding: 20px 0;
    position: sticky;
    top: 0;
    background: var(--bg-base);
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-top h1 {
    font-size: 2rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.subtitle-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Tabs */
.tab-content {
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.section-title {
    font-size: 1.25rem;
    font-family: var(--font-title);
    margin-bottom: 8px;
    margin-top: 16px;
}

.divider {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin-bottom: 20px;
}

/* Glassmorphism Modals & Cards */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-modal .modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg);
}

/* Overlay & Modal */
.overlay,
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.pin-card,
.modal-content {
    width: 100%;
    max-width: 450px;
    padding: 24px;
    border-radius: var(--radius-lg);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="time"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-main);
    font-family: var(--font-inter);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Timeline */
.timeline-container {
    position: relative;
    padding-left: 50px;
    margin-bottom: 30px;
    height: 1200px;
}

.timeline-hour {
    position: absolute;
    left: 0;
    width: 40px;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transform: translateY(-50%);
}

.timeline-line {
    position: absolute;
    left: 50px;
    right: 0;
    height: 1px;
    background: var(--timeline-line);
}

.current-time-indicator {
    position: absolute;
    left: 45px;
    right: 0;
    height: 2px;
    background: var(--primary);
    z-index: 5;
    display: flex;
    align-items: center;
    transition: top 60s linear;
    /* Smoothly update */
}

.current-time-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    left: 1px;
}

.timeline-block {
    position: absolute;
    left: 60px;
    right: 10px;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
    z-index: 2;
    border: 1px solid;
    display: flex;
    flex-direction: column;
    /* background + border-color + color set dynamically in JS */
}

.timeline-block:hover {
    transform: translateY(-2px);
    z-index: 6;
    filter: brightness(1.15);
}

.block-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block-desc {
    font-size: 0.75rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.timeline-mini-block {
    position: absolute;
    left: 60px;
    right: 10px;
    height: 26px;
    border-radius: 8px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
    z-index: 3;
    transition: all 0.2s;
    border: 1px solid;
    /* background + border-color + color set dynamically in JS */
}

.timeline-mini-block:hover {
    transform: translateX(4px);
    filter: brightness(1.15);
}

.timeline-mini-block .block-title {
    font-size: 0.8rem;
}

.unassigned-tasks {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.task-item:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: translateX(2px);
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.task-checkbox.checked::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.task-content {
    flex: 1;
    overflow: hidden;
}

.task-item.checked .block-title {
    text-decoration: line-through;
    opacity: 0.5;
}

/* FAB */
.fab-container {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 32px;
    border: none;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: var(--font-inter);
}

.fab:hover {
    transform: scale(1.05) rotate(90deg);
}

.fab.active {
    transform: rotate(45deg);
    background: var(--text-muted);
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.fab-menu.hidden {
    display: none;
}

.fab-item {
    background: var(--bg-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    animation: slideUp 0.3s ease backwards;
}

.fab-item:nth-child(1) {
    animation-delay: 0.1s;
}

.fab-item:nth-child(2) {
    animation-delay: 0.05s;
}

.fab-item:nth-child(3) {
    animation-delay: 0s;
}

.fab-item:hover {
    background: var(--primary);
    color: white;
}

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

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

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--nav-bg);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 90;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    flex: 1;
    height: 100%;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    color: var(--text-main);
}

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

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 20px;
    transition: transform 0.2s;
}

.nav-text {
    font-size: 10px;
    font-weight: 600;
}

/* Color Picker */
.color-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.color-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-circle:hover {
    transform: scale(1.1);
}

.color-circle.selected {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--primary);
}

/* Chips */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chip {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-view-toggle {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}

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

.cal-day-header {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.cal-day {
    aspect-ratio: 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    position: relative;
    font-size: 0.9rem;
}

.cal-day:hover {
    border-color: var(--primary);
}

.cal-day.today {
    background: var(--primary);
    color: white;
    font-weight: bold;
}

.cal-day.selected {
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px var(--secondary);
}

.cal-day.holiday {
    color: var(--danger);
    font-weight: bold;
}

.cal-day.other-month {
    opacity: 0.3;
}

.cal-dots {
    display: flex;
    gap: 2px;
    margin-top: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 80%;
}

.cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
}

/* Detailed Calendar Grid */
.calendar-detailed-container {
    overflow-x: auto;
    padding-bottom: 10px;
}

.calendar-detailed-grid {
    display: grid;
    min-width: 600px; /* Force some minimum width for scrolling if on very small screens */
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.calendar-detailed-grid.month-view {
    grid-template-columns: 40px repeat(7, 1fr);
}

.calendar-detailed-grid.week-view {
    grid-template-columns: 50px repeat(7, 1fr);
}

.cal-detail-header {
    background: var(--bg-card);
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
}
.cal-detail-header.today {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.cal-detail-cell {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    min-height: 80px;
    padding: 4px;
}

.cal-detail-kw {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}

.cal-detail-time-axis {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    position: relative;
}

.cal-detail-hour {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-bottom: 1px dotted var(--border-color);
    box-sizing: border-box;
}

.cal-detail-event-block {
    font-size: 0.7rem;
    border-radius: 4px;
    padding: 2px 4px;
    margin-bottom: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border: 1px solid;
    color: var(--text-main);
    cursor: pointer;
    line-height: 1.2;
}

/* Absolute positioning for week view */
.cal-detail-event-abs {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 0.7rem;
    border: 1px solid;
    color: var(--text-main);
    cursor: pointer;
    z-index: 5;
    line-height: 1.2;
}

.cal-detail-event-abs:hover, .cal-detail-event-block:hover {
    filter: brightness(1.2);
    z-index: 10;
}

.cal-detail-day-column {
    border-right: 1px solid var(--border-color);
    position: relative;
}

.cal-detail-grid-line {
    position: absolute;
    width: 100%;
    border-bottom: 1px dotted var(--border-color);
    left: 0;
}

/* Lists */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.list-item {
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid;
    /* background + border-color + color set dynamically in JS */
}

.list-item:hover {
    transform: translateY(-2px);
    filter: brightness(1.15);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.list-item-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.list-item-time {
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--bg-base);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* Day Controls */
.day-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.bottom-controls {
    margin-top: 20px;
    margin-bottom: 40px;
}

.error-msg {
    color: var(--danger);
    margin-top: 10px;
    font-size: 0.875rem;
    text-align: center;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .2s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

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