:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1a1a1a;
    --border: #262626;
    --text: #e5e5e5;
    --text-muted: #737373;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --urgent: #ef4444;
    --high: #f59e0b;
    --normal: #737373;
    --low: #404040;
    --radius: 6px;
    --sidebar-width: 240px;
}

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

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

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 1.5rem;
}

.nav-links {
    list-style: none;
    margin-bottom: 1.5rem;
}

.nav-links a {
    display: block;
    padding: 0.4rem 0.6rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
    background: var(--surface-hover);
}

.sidebar-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.tree { list-style: none; }
.tree a {
    display: block;
    padding: 0.25rem 0.6rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    border-radius: var(--radius);
}
.tree a:hover { color: var(--text); background: var(--surface-hover); }
.tree ul { padding-left: 1rem; list-style: none; }

/* Main content */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 800px;
}

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

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
}

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

/* Quick add */
.quick-add {
    margin-bottom: 1rem;
}

.quick-add form {
    display: flex;
    gap: 0.5rem;
}

.quick-add input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
}

.quick-add input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Work list */
.work-list { list-style: none; }

.work-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.work-title {
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    flex: 1;
}
.work-title:hover { color: var(--accent); }

.work-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
}

/* Status button */
.status-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.status-btn[data-status="active"] { border-color: var(--accent); }
.status-btn[data-status="done"] { border-color: var(--success); background: var(--success); }
.status-btn[data-status="blocked"] { border-color: var(--warning); }
.status-btn[data-status="cancelled"] { border-color: var(--danger); background: var(--danger); opacity: 0.5; }

.status-btn-lg { width: 24px; height: 24px; }

/* Priority badges */
.priority {
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
}
.priority-urgent { background: var(--urgent); color: white; }
.priority-high { background: var(--high); color: black; }

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

/* Task detail */
.task-detail { max-width: 640px; }

.task-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.task-title {
    font-size: 1.25rem;
    font-weight: 600;
    outline: none;
    flex: 1;
}

.breadcrumb {
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.task-meta-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.meta-select, .meta-input {
    padding: 0.3rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8125rem;
}

.body-editor {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
}

.body-editor:focus {
    outline: none;
    border-color: var(--accent);
}

.subtasks { margin-top: 2rem; }
.subtasks h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.add-subtask {
    margin-top: 0.5rem;
}

.add-subtask input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8125rem;
}

.add-subtask input:focus {
    outline: none;
    border-style: solid;
    border-color: var(--accent);
}

/* Empty state */
.empty-state {
    padding: 3rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* Today view */
.today-summary {
    margin-bottom: 1.5rem;
}
.ai-summary {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    white-space: pre-line;
}

/* Chat toggle FAB */
.chat-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 100;
    transition: background 0.15s;
}
.chat-toggle:hover { background: var(--accent-hover); }
.chat-toggle.hidden { display: none; }

/* Chat panel */
.chat-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 99;
    transition: right 0.25s ease;
}
.chat-panel.open { right: 0; }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.chat-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}
.chat-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.25rem;
}
.chat-close:hover { color: var(--text); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
}
.chat-message p { margin: 0; }
.user-message {
    background: var(--accent);
    color: white;
    align-self: flex-end;
}
.ai-message {
    background: var(--bg);
    border: 1px solid var(--border);
    align-self: flex-start;
    white-space: pre-line;
}

.action-card {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    align-self: flex-start;
}
.action-card .action-type {
    color: var(--success);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.625rem;
    margin-right: 0.25rem;
}
.action-card .action-type.deleted { color: var(--danger); }
.action-card .action-type.updated { color: var(--warning); }
.action-card a { color: var(--accent); text-decoration: none; }
.action-card a:hover { text-decoration: underline; }

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}
.chat-input input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8125rem;
}
.chat-input input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-loading {
    align-self: flex-start;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}
