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

:root {
    --bg-primary: #fafaf8;
    --bg-secondary: #f5f5f3;
    --text-primary: #2c2c2c;
    --text-secondary: #666;
    --text-tertiary: #999;
    --border-color: #2c2c2c;
    --border-light: #ddd;
    --accent: #000;
    --zoom-level: 1;
}

body {
    font-family: 'Courier New', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: calc(16px * var(--zoom-level));
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
    width: 250px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 2px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.nav-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-item:hover {
    background: var(--bg-primary);
    border-left-color: var(--border-color);
}

.nav-item.active {
    background: var(--bg-primary);
    border-left-color: var(--border-color);
    font-weight: bold;
}

.nav-item .count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.add-collection-btn {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    margin-top: 0.5rem;
}

.add-collection-btn:hover {
    background: var(--bg-primary);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-light);
    background: white;
}

.view-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view-title h2 {
    font-size: 1.5rem;
    font-weight: 400;
}

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

.top-bar-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-secondary);
}

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

.btn-primary:hover {
    background: var(--accent);
}

.zoom-controls {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.zoom-level {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 3rem;
    text-align: center;
}

/* Content Views */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Rapid Log Input */
.rapid-log-input {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border: 1px solid var(--border-light);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-light);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    background: white;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--border-color);
}

.input-group textarea {
    min-height: 100px;
    resize: vertical;
}

.prefix-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.prefix-btn {
    padding: 1rem;
    border: 1px solid var(--border-light);
    background: white;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
    text-align: center;
}

.prefix-btn:hover {
    border-color: var(--border-color);
}

.prefix-btn.active {
    background: var(--border-color);
    color: white;
    border-color: var(--border-color);
}

.prefix-btn .symbol {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

.prefix-btn .label {
    font-size: 0.7rem;
    text-transform: uppercase;
}

/* Entries List */
.entries-container {
    max-width: 800px;
    margin: 0 auto;
}

.day-section {
    margin-bottom: 2rem;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
}

.day-date {
    font-size: 1.2rem;
    font-weight: 400;
}

.day-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.entries-list {
    list-style: none;
}

.entry {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    cursor: move;
    background: white;
    border: 1px solid var(--border-light);
}

.entry:hover {
    background: var(--bg-secondary);
    border-left-color: var(--border-color);
}

.entry.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.entry.drag-over {
    border-top: 2px solid var(--border-color);
}

.bullet {
    font-size: 1.2rem;
    min-width: 30px;
    cursor: pointer;
    user-select: none;
    text-align: center;
}

.entry-content {
    flex: 1;
    min-width: 0;
}

.entry-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.entry-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.entry-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.entry-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.entry:hover .entry-actions {
    opacity: 1;
}

.entry-action-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-light);
    background: white;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

.entry-action-btn:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.entry.completed .entry-text {
    text-decoration: line-through;
    opacity: 0.6;
}

.entry.migrated {
    opacity: 0.7;
}

.entry.canceled {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Calendar View */
.calendar-container {
    max-width: 1200px;
    margin: 0 auto;
}

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

.calendar-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.month-title {
    font-size: 1.5rem;
    font-weight: 400;
    min-width: 200px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-light);
    border: 1px solid var(--border-light);
}

.calendar-day-header {
    padding: 0.5rem;
    text-align: center;
    background: var(--bg-secondary);
    font-size: 0.85rem;
    font-weight: bold;
}

.calendar-day {
    min-height: 100px;
    padding: 0.5rem;
    background: white;
    position: relative;
}

.calendar-day.other-month {
    background: var(--bg-secondary);
    opacity: 0.5;
}

.calendar-day.today {
    background: #fffacd;
}

.calendar-day-number {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.calendar-day-entries {
    font-size: 0.75rem;
}

.calendar-entry-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    margin-right: 0.25rem;
}

/* Reflection Mode */
.reflection-container {
    max-width: 600px;
    margin: 0 auto;
}

.reflection-prompt {
    background: white;
    padding: 2rem;
    border: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
}

.reflection-prompt h3 {
    font-size: 1.2rem;
    font-weight: 400;
    margin-bottom: 1rem;
    font-style: italic;
}

.reflection-textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--border-light);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    resize: vertical;
}

/* Migration View */
.migration-container {
    max-width: 800px;
    margin: 0 auto;
}

.migration-intro {
    background: white;
    padding: 2rem;
    border: 1px solid var(--border-light);
    margin-bottom: 2rem;
    text-align: center;
}

.migration-intro h3 {
    font-size: 1.3rem;
    font-weight: 400;
    margin-bottom: 1rem;
}

.migration-intro p {
    color: var(--text-secondary);
}

.migration-entry {
    background: white;
    padding: 1.5rem;
    border: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.migration-entry-content {
    margin-bottom: 1rem;
}

.migration-actions {
    display: flex;
    gap: 0.5rem;
}

.migration-actions .btn {
    flex: 1;
}

/* Empty States */
.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 4rem 2rem;
    font-style: italic;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid var(--border-color);
}

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

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 400;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

/* Quiet Mode */
body.quiet-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
}

body.quiet-mode * {
    transition: none !important;
    animation: none !important;
}

/* Dark Mode */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --border-color: #404040;
    --border-light: #2a2a2a;
    --accent: #ffffff;
}

body.dark-mode .rapid-log-input,
body.dark-mode .entry,
body.dark-mode .btn,
body.dark-mode .prefix-btn,
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode .calendar-day,
body.dark-mode .reflection-prompt,
body.dark-mode .migration-entry,
body.dark-mode .modal-content,
body.dark-mode .top-bar {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--border-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: calc(14px * var(--zoom-level));
    }

    .app-container {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

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

    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .top-bar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .view-title {
        flex-wrap: wrap;
        width: 100%;
    }

    .view-title h2 {
        font-size: 1.3rem;
    }

    .date-display {
        font-size: 0.8rem;
    }

    .top-bar-actions {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .zoom-controls {
        gap: 0.25rem;
    }

    .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .zoom-level {
        min-width: 2.5rem;
        font-size: 0.75rem;
    }

    /* Rapid Log Input */
    .rapid-log-input {
        padding: 1rem;
    }

    .rapid-log-input h2 {
        font-size: 1.2rem;
    }

    .prefix-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .prefix-btn {
        padding: 0.75rem;
    }

    .prefix-btn .symbol {
        font-size: 1.2rem;
    }

    .prefix-btn .label {
        font-size: 0.65rem;
    }

    /* Entries */
    .entry {
        padding: 0.5rem;
        flex-wrap: wrap;
    }

    .bullet {
        font-size: 1rem;
        min-width: 25px;
    }

    .entry-content {
        flex: 1;
        min-width: 0;
    }

    .entry-title {
        font-size: 0.95rem;
    }

    .entry-text {
        font-size: 0.9rem;
    }

    .entry-meta {
        font-size: 0.7rem;
        flex-wrap: wrap;
    }

    .entry-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
        opacity: 1;
    }

    .entry-action-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Calendar */
    .calendar-container {
        overflow-x: auto;
    }

    .calendar-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .month-title {
        font-size: 1.2rem;
        min-width: 150px;
    }

    .calendar-grid {
        min-width: 320px;
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.25rem;
    }

    .calendar-day-number {
        font-size: 0.85rem;
    }

    .calendar-day-entries {
        font-size: 0.65rem;
    }

    /* Migration & Reflection */
    .migration-container,
    .reflection-container {
        padding: 0;
    }

    .migration-intro,
    .reflection-prompt,
    .migration-entry {
        padding: 1rem;
    }

    .migration-actions {
        flex-wrap: wrap;
    }

    .migration-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Day Section */
    .day-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .day-date {
        font-size: 1rem;
    }

    .day-stats {
        font-size: 0.75rem;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
    }

    /* Input groups */
    .input-group input,
    .input-group textarea,
    .input-group select {
        font-size: 1rem;
    }

    /* Sidebar Navigation */
    .sidebar-header {
        padding: 1rem;
    }

    .sidebar-header h1 {
        font-size: 1rem;
    }

    .sidebar-nav {
        padding: 0.75rem;
    }

    .nav-section h3 {
        font-size: 0.7rem;
    }

    .nav-item {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    /* Touch friendly tap targets */
    .entry,
    .nav-item,
    .btn,
    .prefix-btn,
    .calendar-day {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Disable hover effects on mobile */
    .entry:hover,
    .nav-item:hover,
    .btn:hover {
        background: inherit;
    }

    /* Active states for mobile */
    .entry:active {
        background: var(--bg-secondary);
    }

    .nav-item:active,
    .btn:active {
        opacity: 0.7;
    }

    /* Hide drag cursor on mobile */
    .entry {
        cursor: default;
    }
}

/* Tablet (landscape) */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .content-area {
        padding: 1.5rem;
    }

    .top-bar {
        padding: 1rem 1.5rem;
    }

    .prefix-selector {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Small phones */
@media (max-width: 480px) {
    .top-bar {
        padding: 0.5rem;
    }

    .view-title h2 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .rapid-log-input {
        padding: 0.75rem;
    }

    .prefix-selector {
        grid-template-columns: 1fr 1fr;
    }

    .calendar-grid {
        font-size: 0.85rem;
    }

    .entry {
        gap: 0.5rem;
    }
}

@media print {
    .sidebar,
    .top-bar-actions,
    .entry-actions,
    .add-collection-btn {
        display: none;
    }

    .main-content {
        border: none;
    }

    .entry {
        break-inside: avoid;
    }
}