:root {
    --primary: #1e3a8a; /* Navy Blue */
    --secondary: #3b82f6; /* Blue */
    --accent: #f59e0b; /* Amber/Gold */
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --danger: #ef4444;
    --success: #10b981;
    --nav-height: 60px;
    --header-height: 56px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* App-like feel */
}

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

.app-header h1 {
    font-size: 1.2rem;
    font-weight: bold;
}
.app-header h1 span {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-left: 5px;
}

.header-actions button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: white;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-img {
    height: 34px;
    width: auto;
    display: block;
}

.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    user-select: none;
}

/* Main Container */
#app-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: var(--nav-height); /* Space for nav */
}

.view {
    display: none;
    padding: 16px;
    min-height: 100%;
}

.view.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    align-items: center;
    background: var(--card-bg);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 12px;
}

.hero-illust {
    width: 110px;
    height: auto;
    display: block;
}

.hero-text h2 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.hero-text p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.35;
}

@media (max-width: 420px) {
    .hero {
        grid-template-columns: 92px 1fr;
    }
    .hero-illust {
        width: 92px;
    }
}

/* Auth Gate */
.auth-gate {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 200;
}

.auth-gate.hidden { display: none; }

.auth-card {
    width: min(420px, 100%);
    background: var(--card-bg);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.auth-title-img {
    width: 180px;
    height: auto;
    display: block;
    margin: 0 auto 10px;
}

.auth-sub {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 10px;
}

.auth-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

#product-key {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.auth-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.auth-actions button { flex: 1; }

.auth-msg {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--danger);
    text-align: center;
    min-height: 1.2em;
}

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

.overlay-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 20;
    padding: 0;
    overflow-y: auto;
}
.overlay-view.hidden {
    display: none;
}
.overlay-header {
    background: var(--card-bg);
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
}

/* Navigation */
.bottom-nav {
    height: var(--nav-height);
    background: var(--card-bg);
    border-top: 1px solid #e5e7eb;
    display: flex;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 10;
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s;
}

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

.nav-item .icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
}
.nav-item .label {
    font-size: 0.7rem;
}

/* Components */
.primary-btn { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.secondary-btn { background: var(--secondary); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.accent-btn { background: var(--accent); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: bold; }
.danger-btn { background: var(--danger); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.small { padding: 4px 8px; font-size: 0.85rem; }

.input-area {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}
.input-area input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 1rem;
}
.input-controls {
    display: flex;
    gap: 8px;
}
.input-controls select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Task List */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-card {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border-left: 4px solid transparent;
    transition: transform 0.1s;
    cursor: pointer;
}
.task-card:active { transform: scale(0.99); }

.task-card.priority-high { border-left-color: var(--danger); }
.task-card.priority-medium { border-left-color: var(--accent); }
.task-card.priority-low { border-left-color: var(--success); }

.task-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.task-title { font-weight: 600; font-size: 1rem; }
.task-meta { font-size: 0.8rem; color: var(--text-light); display: flex; gap: 8px; flex-wrap: wrap;}
.badge { background: #eee; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; }
.badge.epic { background: #e0e7ff; color: var(--primary); }
.badge.score { background: #fef3c7; color: #b45309; }

/* Triage Specific */
.triage-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}
.triage-row { margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.triage-row label { width: 80px; color: var(--text-light); font-size: 0.8rem; }
.triage-row select, .triage-row input { flex: 1; padding: 4px; border: 1px solid #ddd; border-radius: 4px; }

/* Calendar / Plan */
.plan-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
    font-weight: bold;
    font-size: 1.1rem;
}
.plan-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}
.calendar-container {
    display: flex;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    height: 600px; /* Fixed height for scroll */
    position: relative;
}
.time-axis {
    width: 50px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: right;
    padding-right: 4px;
}
.time-slot { height: 60px; border-bottom: 1px solid #f3f4f6; padding-top: 4px; box-sizing: border-box; }
.schedule-area {
    flex: 1;
    position: relative;
    background: 
        repeating-linear-gradient(to bottom, transparent 0 59px, #f3f4f6 59px 60px);
}
.schedule-block {
    position: absolute;
    left: 10px;
    right: 10px;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: white;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.schedule-block.meeting { background: var(--text-light); border: 2px dashed #999; }
.schedule-block.work { background: var(--primary); opacity: 0.9; }
.schedule-block.proposed { background: var(--accent); border: 2px solid white; }
.schedule-block.investigation { background: var(--success); }

/* Today View */
.today-hero {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.today-hero h2 { color: var(--primary); margin-bottom: 4px; }
.action-btn-group { display: flex; gap: 8px; margin-top: 8px; }

/* Epic Detail */
.epic-stats {
    padding: 16px;
    display: flex;
    gap: 16px;
    font-weight: bold;
    background: #e0e7ff;
    color: var(--primary);
}
.template-actions {
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
    white-space: nowrap;
}
.template-actions button {
    margin-right: 8px;
    padding: 4px 10px;
    border: 1px solid var(--secondary);
    background: #fff;
    color: var(--secondary);
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Settings */
.settings-content { padding: 16px; }
.card { background: white; padding: 16px; border-radius: 8px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
#json-io { width: 100%; border: 1px solid #ddd; margin: 8px 0; font-family: monospace; font-size: 0.8rem; }
.row { display: flex; gap: 8px; }

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 100;
    display: flex; justify-content: center; align-items: center;
}
.modal.hidden { display: none; }
.modal-content {
    background: white; width: 90%; max-width: 400px;
    padding: 20px; border-radius: 8px;
    display: flex; flex-direction: column; gap: 12px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }