:root {
    --header-gradient: linear-gradient(135deg, #a8a8a8 0%, #555555 100%);
    --bg-color: #f2f2f7; /* iOS standard light grey for background of sheets? Or white. Screenshot looks white. */
    --card-bg: #ffffff;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --text-header: #ffffff;
    --accent-color: #5856d6; /* iOS Indigo-ish */
    --border-color: #e5e5ea;
    --font-main:
        system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    --radius-l: 30px;
    --radius-m: 16px;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--header-gradient);
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-image 0.5s ease-in-out;
}

/* Header */
.app-header {
    padding: 1.5rem 1.5rem 4rem 1.5rem; /* Extra bottom padding for overlap */
    color: var(--text-header);
    position: relative;
    z-index: 1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease-in-out;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0;
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.date-group h1 {
    font-size: 2.5rem;
    margin: 0;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

#full-date {
    margin: 0.5rem 0 0 0;
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 500;
}

.time-group {
    text-align: right;
}

#clock-time {
    font-size: 2rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-feature-settings: "tnum";
}

.brand-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-top: 0.2rem;
}

.nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-arrow {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: grid;
    place-content: center;
    transition: background 0.2s;
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Main Content Overlay */
.content-overlay {
    background-color: var(--card-bg);
    flex: 1;
    border-top-left-radius: var(--radius-l);
    border-top-right-radius: var(--radius-l);
    margin-top: -2rem; /* Pull up */
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 2;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
}

.layout-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100%;
}

/* Tasks */
.input-card {
    background-color: #f7f7f9; /* Pill background */
    border-radius: var(--radius-m);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.input-icon {
    color: var(--text-secondary);
}

#task-input {
    border: none;
    background: transparent;
    font-size: 1rem;
    width: 100%;
    font-family: var(--font-main);
    color: var(--text-primary);
    outline: none;
}

#task-input::placeholder {
    color: #b0b0b8;
}

#task-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.task-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.task-checkbox {
    appearance: none;
    width: 24px;
    height: 24px;
    border: 2px solid #d1d1d6;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0.1rem;
    transition: all 0.2s;
    position: relative;
}

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

.task-checkbox:checked::after {
    content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>');
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    display: block;
}

.task-content {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

.task-item.completed .task-content {
    color: var(--text-secondary);
    text-decoration: line-through;
}

.task-item.completed {
    background-color: #fafafa;
    border-color: transparent;
    box-shadow: none;
}

.task-edit-input {
    width: 100%;
    font-family: var(--font-main);
    font-size: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--accent-color);
    border-radius: 8px;
}

/* Notes */
.notes-panel {
    display: flex;
    flex-direction: column;
    margin-top: auto; /* Push to bottom on mobile if height allows */
}

.notes-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.notes-container {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    padding: 1rem;
    box-shadow: var(--shadow-soft);
}

#notes-input {
    width: 100%;
    border: none;
    resize: none;
    font-family: var(--font-main);
    font-size: 0.95rem;
    line-height: 1.6;
    min-height: 150px;
    outline: none;
    color: var(--text-secondary);
}

#notes-input:focus {
    color: var(--text-primary);
}

.autosave-indicator {
    text-align: right;
    font-size: 0.7rem;
    color: #ccc;
    margin-top: 0.5rem;
}

.hidden {
    display: none;
}

/* Desktop */
@media (min-width: 768px) {
    .content-overlay {
        margin-top: -3rem;
        padding: 3rem;
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        width: 100%;
    }

    .layout-grid {
        flex-direction: row;
        align-items: flex-start;
        gap: 3rem;
    }

    .tasks-panel {
        flex: 1; /* 50% */
    }

    .notes-panel {
        flex: 1; /* 50% */
        position: sticky;
        top: 2rem;
    }

    .notes-container {
        min-height: 500px;
    }

    #notes-input {
        height: 450px;
    }
}

/* Notes Markdown Display */
.notes-content {
    font-size: 0.95rem;
    line-height: 1.6;
    min-height: 150px;
    color: var(--text-primary);
    cursor: pointer;
}
.notes-content p {
    margin-top: 0;
    margin-bottom: 0.8em;
}
.notes-content h1,
.notes-content h2,
.notes-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 1em 0 0.5em 0;
    color: var(--accent-color);
}
.notes-content ul,
.notes-content ol {
    padding-left: 1.2em;
}
.notes-content a {
    color: var(--accent-color);
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Search Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-m);
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.search-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #f2f2f7;
    padding: 0.8rem 1rem;
    border-radius: 12px;
}

.search-icon-small {
    color: var(--text-secondary);
}

#search-input {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    width: 100%;
    outline: none;
    color: var(--text-primary);
}

#close-search {
    color: var(--text-secondary);
}
#close-search:hover {
    color: var(--text-primary);
}

.search-results-list {
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
    display: block;
    text-decoration: none;
    color: inherit;
}

.search-result-item:hover {
    background: #f9f9f9;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.result-type {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    background: #eee;
    color: #555;
}

.result-type.task {
    background: #e3f2fd;
    color: #1976d2;
}

.result-type.note {
    background: #f3e5f5;
    color: #7b1fa2;
}

.result-text {
    font-size: 1rem;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: rgba(30, 30, 30, 0.9);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: rgba(220, 53, 69, 0.95);
}

.toast.success {
    background: rgba(40, 167, 69, 0.95);
}

/* Sidebar */
#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1100;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease, visibility 0.3s;
    visibility: visible;
    opacity: 1;
}

#sidebar-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    display: block; /* Override generic .hidden display:none */
}

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    z-index: 1101;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    box-shadow: 5px 0 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transform: translateX(0);
    visibility: visible;
}

#sidebar.hidden {
    transform: translateX(-100%);
    visibility: hidden;
    display: flex; /* Override generic .hidden */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: transparent;
    border: none;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-m);
    transition: background 0.2s;
    text-align: left;
    width: 100%;
    font-family: var(--font-main);
}

.sidebar-item:hover {
    background: #f2f2f7;
}

.sidebar-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

#sidebar-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: 40vh;
}

/* Tags */
.tag {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    margin: 0 2px;
}

.tag:hover {
    opacity: 0.8;
}

.sidebar-tag {
    background-color: #e5e5ea;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: inline-block;
}

.sidebar-tag:hover {
    background-color: var(--accent-color);
    color: white;
}
