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

:root {
    --bg: #0b0d11;
    --surface: #14171f;
    --surface-2: #1c2029;
    --surface-hover: #232735;
    --border: #2a2e3a;
    --text: #e4e4e7;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --red: #ef4444;
    --orange: #f59e0b;
    --green: #22c55e;
    --blue: #3b82f6;
    --purple: #a855f7;
    --sidebar-w: 260px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 16px;
}

.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent); color: white; }

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.nav-item .count {
    margin-left: auto;
    font-size: 11px;
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 10px;
}
.nav-item.active .count { background: rgba(255,255,255,0.2); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar h2 {
    font-size: 16px;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.1s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { border-color: var(--accent); background: var(--accent); color: white; }

.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Summary Row */
.summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.stat-card .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Chart */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    position: relative;
    height: 420px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Project List */
.project-list { display: grid; gap: 8px; }

.project-row {
    display: grid;
    grid-template-columns: 4px 1fr 100px 80px 80px 60px;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.1s;
}

.project-row:hover { border-color: var(--accent); }

.project-row .indicator {
    width: 4px;
    height: 32px;
    border-radius: 2px;
}

.project-row .name { font-weight: 500; font-size: 14px; }
.project-row .meta { font-size: 12px; color: var(--text-muted); }

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
}

.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--purple); }

/* Task List */
.task-list { display: grid; gap: 4px; }

.task-row {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.task-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s;
}

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

.task-project-tag {
    font-size: 11px;
    color: var(--accent-light);
    background: rgba(99,102,241,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Chat */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--surface-2);
    border-bottom-left-radius: 4px;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.chat-input:focus { border-color: var(--accent); }

.chat-send {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.chat-send:hover { background: var(--accent-light); }

/* Project Detail */
.detail-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.detail-header h3 { font-size: 20px; margin-bottom: 8px; }

.detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-tasks { display: grid; gap: 4px; }

/* Voice Button */
.voice-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.voice-btn:hover { border-color: var(--accent); }
.voice-btn.recording {
    background: var(--red);
    border-color: var(--red);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.voice-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.voice-modal-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    min-width: 280px;
}

.voice-pulse {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--red);
    margin: 0 auto 20px;
    animation: pulse 1.5s infinite;
}

.voice-stop {
    margin-top: 20px;
    padding: 10px 32px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* View Transitions */
.view-transition {
    transition: opacity 0.18s ease, transform 0.18s ease;
    will-change: opacity, transform;
}
.view-transition.visible { opacity: 1; transform: translateY(0); }
.view-transition.hidden { opacity: 0; transform: translateY(6px); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--green);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

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

/* Search */
.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    outline: none;
    margin-bottom: 4px;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* Record Button */
.record-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 24px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.record-btn:hover { border-color: var(--accent); background: var(--surface-hover); }

/* Recording Item */
.recording-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}

/* Login */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-icon {
    font-size: 40px;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-box h2 {
    font-size: 20px;
    margin-bottom: 24px;
    color: var(--text);
}

.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    outline: none;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.login-input:focus { border-color: var(--accent); }

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; }

.login-error {
    color: var(--red);
    font-size: 13px;
    margin-bottom: 8px;
}

.logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    margin-top: 6px;
}

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

/* PWA safe areas */
.layout { padding-top: env(safe-area-inset-top); }
.sidebar { padding-bottom: env(safe-area-inset-bottom); }

/* Mobile Bottom Bar */
.mobile-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bar-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
}

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    padding: 4px 12px;
    position: relative;
}

.mobile-tab .tab-icon { font-size: 20px; line-height: 1; transition: transform 0.2s ease, color 0.2s ease; }
.mobile-tab.active { color: var(--accent); }
.mobile-tab.active .tab-icon { transform: scale(1.15); }

.mobile-tab .tab-badge {
    position: absolute;
    top: 0;
    right: 4px;
    background: var(--red);
    color: white;
    font-size: 9px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Mobile More Menu */
.more-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: rgba(0,0,0,0.6);
    z-index: 60;
    display: flex;
    align-items: flex-end;
}

.more-menu-inner {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    width: 100%;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    max-height: 60vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.more-menu-inner h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 4px;
}

.more-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    border-radius: 10px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.more-item:hover, .more-item:active { background: var(--surface-hover); }
.more-item .more-icon { font-size: 18px; width: 24px; text-align: center; color: var(--text-muted); }
.more-item .more-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* Voice Chat Button */
.voice-chat-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.voice-chat-btn:hover { border-color: var(--accent); color: var(--text); }
.voice-chat-btn.listening {
    background: var(--red);
    border-color: var(--red);
    color: white;
    animation: pulse 1.5s infinite;
}

/* Skeleton Loader */
.skeleton-container { padding: 24px 0; }
.skeleton-row {
    height: 14px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    margin-bottom: 16px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Task completion animation */
.task-row { transition: opacity 0.3s ease, transform 0.3s ease; }
.task-row.completing {
    opacity: 0;
    transform: translateX(40px);
}

/* Smooth scrolling */
.content { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-bar { display: block; }
    .content { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
    .main { height: 100vh; }
    .topbar { padding: 12px 16px; }
    .topbar h2 { font-size: 15px; }
    .summary-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 24px; }
    .chart-container { height: 280px; padding: 12px; }
    .project-row { grid-template-columns: 4px 1fr 60px; }
    .project-row .meta:nth-child(n+4) { display: none; }
    .chat-panel { height: calc(100vh - 120px - env(safe-area-inset-bottom, 0px)); }
    .chat-messages { max-height: none; }
    .task-row { padding: 12px; }
    .task-checkbox { width: 22px; height: 22px; padding: 11px; background-clip: content-box; }
    .filter-btn { padding: 10px 14px; font-size: 13px; }
    .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; text-align: center; }
}
