/* ================================================================
   DevCockpit -- Dark Theme Stylesheet
   Design: GitHub Dark (#0D1117), monospace-first, functional
   ================================================================ */

/* --- CSS Variables ----------------------------------------------- */
:root {
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-tertiary: #21262D;
    --bg-card: #161B22;
    --border: #30363D;
    --border-hover: #484F58;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #6E7681;
    --accent: #58A6FF;
    --accent-hover: #79C0FF;
    --green: #3FB950;
    --green-muted: #238636;
    --red: #F85149;
    --red-muted: #DA3633;
    --yellow: #D29922;
    --yellow-muted: #9E6A03;
    --purple: #A371F7;
    --purple-muted: #8957E5;
    --cyan: #79C0FF;
    --orange: #F0883E;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.5);
    --transition: 150ms ease;
    --transition-slow: 300ms ease;
    --sidebar-width: 260px;
    --topbar-height: 48px;
}

/* --- Light Theme ------------------------------------------------- */
[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F6F8FA;
    --bg-tertiary: #E8ECF0;
    --bg-card: #FFFFFF;
    --border: #D0D7DE;
    --border-hover: #9CA3AF;
    --text-primary: #1F2328;
    --text-secondary: #656D76;
    --text-muted: #8B949E;
    --accent: #0969DA;
    --accent-hover: #0550AE;
    --green: #1A7F37;
    --green-muted: #2DA44E;
    --red: #CF222E;
    --red-muted: #D1242F;
    --yellow: #9A6700;
    --yellow-muted: #BF8700;
    --purple: #8250DF;
    --purple-muted: #6639BA;
    --cyan: #0969DA;
    --orange: #BC4C00;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* --- Theme Toggle Switch ----------------------------------------- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.theme-toggle-icon { font-size: 0.9rem; line-height: 1; }
.theme-toggle-track {
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    transition: background var(--transition);
}
.theme-toggle-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 1px;
    transition: transform var(--transition);
}
[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(16px);
}

/* --- Reset & Base ------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

::selection {
    background: rgba(88, 166, 255, 0.3);
    color: var(--text-primary);
}

/* --- Typography -------------------------------------------------- */
h1, h2, h3, h4 {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

h1 {
    font-size: 1.75rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.375rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.125rem;
}

h4 {
    font-size: 1rem;
    color: var(--text-secondary);
}

p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-tertiary);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--cyan);
}

pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
}

small {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

strong {
    font-weight: 600;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* --- Layout ------------------------------------------------------ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.main-content {
    padding: 1.25rem;
    padding-bottom: 3rem;
    flex: 1;
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* --- App Shell --------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar ----------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.sidebar-brand {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.sidebar-brand a:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-logo {
    color: var(--green);
    font-size: 1.125rem;
    line-height: 1;
}

.btn.btn-new-task {
    margin: 0.75rem 0.75rem 0;
    background: var(--orange);
    border-color: var(--orange);
    color: #fff;
    font-weight: 600;
    justify-content: center;
    width: calc(100% - 1.5rem);
}

.btn.btn-new-task:hover {
    background: #e5793a;
    border-color: #e5793a;
    color: #fff;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.5rem 0;
    gap: 1px;
}

.sidebar-nav-item {
    padding: 0.4rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--transition);
}

.sidebar-nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.sidebar-nav-item.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.sidebar-section-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.sidebar-tasks {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 0.5rem;
}

.sidebar-tasks-loading {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-project-group {
    margin-bottom: 0.25rem;
}

.sidebar-project-label {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-task-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    overflow: hidden;
}

.sidebar-task-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-task-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-task-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-task-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-task-time {
    font-size: 0.625rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
}

/* --- Main Area --------------------------------------------------- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Topbar ------------------------------------------------------ */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
    gap: 0.75rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-project {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.topbar-sep {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.btn.sidebar-toggle {
    display: none;
}

/* --- No-sidebar (login page) ------------------------------------- */
body.no-sidebar .sidebar { display: none; }
body.no-sidebar .main-area { margin-left: 0; }
body.no-sidebar .topbar { display: none; }

/* --- Buttons ----------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
}

.btn:hover {
    background: var(--border);
    border-color: var(--border-hover);
    text-decoration: none;
    color: var(--text-primary);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: #1F6FEB;
    border-color: #388BFD;
    color: #fff;
}

.btn-primary:hover {
    background: #388BFD;
    border-color: var(--accent);
    color: #fff;
}

.btn-success {
    background: var(--green-muted);
    border-color: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-danger {
    background: var(--red-muted);
    border-color: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.625rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.375rem;
    min-width: 2rem;
    min-height: 2rem;
}

/* --- Forms ------------------------------------------------------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B949E' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.75rem;
    color: var(--red);
    margin-top: 0.25rem;
}

/* Segmented control (radio button group) */
.segmented-control {
    display: inline-flex;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    padding: 0.375rem 0.875rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    user-select: none;
}

.segmented-control label:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.segmented-control input[type="radio"]:checked + label {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    box-shadow: var(--shadow);
}

/* --- Cards ------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* --- Task Cards (Mission Control) -------------------------------- */
.task-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
}

.task-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: var(--text-primary);
    transform: translateX(2px);
}

.task-card[data-status="new"]              { border-left-color: #58A6FF; }
.task-card[data-status="triaged"]          { border-left-color: #D29922; }
.task-card[data-status="assigned"]         { border-left-color: #A371F7; }
.task-card[data-status="running"]          { border-left-color: #3FB950; }
.task-card[data-status="waiting_feedback"] { border-left-color: #F85149; }
.task-card[data-status="ready_review"]     { border-left-color: #79C0FF; }
.task-card[data-status="done"]             { border-left-color: #56D364; }
.task-card[data-status="parked"]           { border-left-color: #8B949E; }
.task-card[data-status="blocked"]          { border-left-color: #F85149; }

.task-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Pulsing dot for running/waiting_feedback */
.task-card[data-status="running"]::before,
.task-card[data-status="waiting_feedback"]::before {
    content: '';
    position: absolute;
    top: 0.875rem;
    right: 0.875rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.task-card[data-status="running"]::before {
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.6);
}

.task-card[data-status="waiting_feedback"]::before {
    background: var(--red);
    box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.6);
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    70%  { box-shadow: 0 0 0 8px transparent; opacity: 0.7; }
    100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

/* --- Status Badges ----------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.6;
}

.badge[data-status="new"] {
    background: rgba(88, 166, 255, 0.15);
    color: #58A6FF;
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.badge[data-status="triaged"] {
    background: rgba(210, 153, 34, 0.15);
    color: #D29922;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge[data-status="assigned"] {
    background: rgba(163, 113, 247, 0.15);
    color: #A371F7;
    border: 1px solid rgba(163, 113, 247, 0.3);
}

.badge[data-status="running"] {
    background: rgba(63, 185, 80, 0.15);
    color: #3FB950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge[data-status="waiting_feedback"] {
    background: rgba(248, 81, 73, 0.15);
    color: #F85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge[data-status="ready_review"] {
    background: rgba(121, 192, 255, 0.15);
    color: #79C0FF;
    border: 1px solid rgba(121, 192, 255, 0.3);
}

.badge[data-status="done"] {
    background: rgba(86, 211, 100, 0.15);
    color: #56D364;
    border: 1px solid rgba(86, 211, 100, 0.3);
}

.badge[data-status="parked"] {
    background: rgba(139, 148, 158, 0.15);
    color: #8B949E;
    border: 1px solid rgba(139, 148, 158, 0.3);
}

.badge[data-status="blocked"] {
    background: rgba(248, 81, 73, 0.15);
    color: #F85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge-feedback {
    background: rgba(248, 81, 73, 0.2);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.badge-priority {
    font-size: 0.625rem;
    padding: 0.0625rem 0.375rem;
}

.badge-priority[data-priority="high"] {
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge-priority[data-priority="medium"] {
    background: rgba(210, 153, 34, 0.15);
    color: var(--yellow);
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-priority[data-priority="low"] {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(139, 148, 158, 0.3);
}

/* --- Grid Layouts ------------------------------------------------ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* --- Mission Control --------------------------------------------- */
.mission-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: flex-start;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
}

.filter-bar .form-select {
    width: auto;
    min-width: 150px;
}

.filter-bar .form-input {
    width: auto;
    min-width: 200px;
}

.status-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.status-column-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-column-count {
    font-size: 0.6875rem;
    background: var(--bg-tertiary);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    color: var(--text-muted);
}

.status-column-body {
    padding: 0.5rem;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

/* --- Task Detail Layout (3-panel) -- legacy ---------------------- */
.task-detail-layout {
    display: grid;
    grid-template-columns: 300px 1fr 280px;
    gap: 1rem;
    align-items: flex-start;
}

/* --- Task Chat Layout (Codex-style) ----------------------------- */
.task-chat-layout {
    display: flex;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    margin: -1.25rem;
    margin-bottom: -3rem;
}

.context-panel {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: none;
}

.context-panel.open {
    display: block;
}

.events-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: none;
}

.events-panel.open {
    display: block;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.chat-tabs-bar {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.chat-tabs-bar .tabs {
    flex: 1;
    border-bottom: none;
}

.chat-tabs-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem;
}

.chat-tab-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    resize: none;
    min-height: 38px;
    max-height: 150px;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    padding: 0.5rem 1rem;
    height: 38px;
}

/* --- Panels ------------------------------------------------------ */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-body {
    padding: 1rem;
}

.panel-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* --- Agent Messages ---------------------------------------------- */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    flex: 1;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    line-height: 1.6;
    max-width: 85%;
    word-wrap: break-word;
}

.message-user {
    background: rgba(31, 111, 235, 0.2);
    border: 1px solid rgba(88, 166, 255, 0.2);
    color: var(--cyan);
    margin-left: auto;
    text-align: right;
}

.message-assistant {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    margin-right: auto;
}

.message-role {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* --- Flash Messages ---------------------------------------------- */
.flash {
    max-width: 1400px;
    margin: 0 auto 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: opacity var(--transition-slow);
}

.flash-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--green);
}

.flash-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--red);
}

/* --- Drag & Drop Zone -------------------------------------------- */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
    font-size: 0.875rem;
    background: var(--bg-primary);
}

.drop-zone:hover {
    border-color: var(--accent);
    color: var(--text-secondary);
    background: rgba(88, 166, 255, 0.05);
}

.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.1);
}

.drop-zone-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.6;
}

.drop-zone-text {
    display: block;
    margin-bottom: 0.25rem;
}

.drop-zone-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Voice Recorder ---------------------------------------------- */
.recorder-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.recorder-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1.25rem;
}

.recorder-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(248, 81, 73, 0.1);
}

.recorder-active {
    border-color: var(--red);
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
    animation: recorder-pulse 1.5s infinite;
}

@keyframes recorder-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(248, 81, 73, 0); }
}

.recorder-timer {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 60px;
    text-align: center;
    letter-spacing: 0.05em;
}

.recorder-timer.active {
    color: var(--red);
}

.recorder-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Screenshot Preview Grid ------------------------------------- */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.preview-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.preview-item:hover .preview-item-remove {
    opacity: 1;
}

/* --- Lightbox ---------------------------------------------------- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Spinner / Loading ------------------------------------------- */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.75rem;
    font-size: 0.875rem;
}

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

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
    display: block;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.empty-state-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* --- Tabs -------------------------------------------------------- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
    overflow-x: auto;
}

.tab-item {
    padding: 0.625rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    margin-bottom: -1px;
}

.tab-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-item.tab-active,
.tab-active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* --- Modal ------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(10px);
    transition: transform var(--transition-slow);
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1rem;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    background: var(--bg-tertiary);
}

/* --- Event Log --------------------------------------------------- */
.event-log {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 400px;
    overflow-y: auto;
}

.event-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
    transition: background var(--transition);
}

.event-item:hover {
    background: var(--bg-tertiary);
}

.event-item:last-child {
    border-bottom: none;
}

.event-type {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    min-width: 100px;
}

.event-detail {
    color: var(--text-secondary);
    flex: 1;
    word-break: break-word;
}

.event-time {
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 0.6875rem;
}

/* --- Time Ago ---------------------------------------------------- */
.time-ago {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* --- Owner Badge ------------------------------------------------- */
.owner-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.owner-badge[data-owner="jannik"] {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    border-color: rgba(88, 166, 255, 0.2);
}

.owner-badge[data-owner="ib"] {
    background: rgba(163, 113, 247, 0.1);
    color: var(--purple);
    border-color: rgba(163, 113, 247, 0.2);
}

.owner-badge[data-owner="shared"] {
    background: rgba(210, 153, 34, 0.1);
    color: var(--yellow);
    border-color: rgba(210, 153, 34, 0.2);
}

/* --- Keyboard Shortcut Hints ------------------------------------- */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    padding: 0.1em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    line-height: 1.4;
}

/* --- Audio Player ------------------------------------------------ */
.audio-preview {
    margin-top: 0.75rem;
}

.audio-preview audio {
    width: 100%;
    height: 36px;
    border-radius: var(--radius);
}

/* --- Scrollbar Styling ------------------------------------------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

/* --- Server Grid & Cards ----------------------------------------- */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.75rem;
}

.server-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.server-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.server-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0;
}

.server-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.server-card-body {
    padding: 0.65rem 1rem;
}

.server-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.82rem;
}

.server-info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.server-info-value {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.server-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--border);
}

.test-result {
    font-size: 0.78rem;
    font-weight: 500;
    margin-left: auto;
}

.test-success {
    color: var(--green);
}

.test-failure {
    color: var(--red);
}

/* --- Type Badges ------------------------------------------------- */
.badge-type {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    text-transform: capitalize;
}

.badge-type[data-type="general"] {
    background: rgba(139, 148, 158, 0.15);
    color: #8B949E;
    border: 1px solid rgba(139, 148, 158, 0.3);
}

.badge-type[data-type="deployment"] {
    background: rgba(63, 185, 80, 0.15);
    color: #3FB950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-type[data-type="agent"] {
    background: rgba(163, 113, 247, 0.15);
    color: #A371F7;
    border: 1px solid rgba(163, 113, 247, 0.3);
}

/* --- Form Card & Layout ------------------------------------------ */
.form-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 720px;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group-grow {
    flex: 1;
}

.form-group-fixed {
    width: 120px;
    flex-shrink: 0;
}

.form-group-half {
    flex: 1;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.form-textarea-mono {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
}

.form-textarea-lg {
    min-height: 300px;
}

/* --- Danger Button ----------------------------------------------- */
.btn-danger {
    background: rgba(248, 81, 73, 0.15);
    border-color: rgba(248, 81, 73, 0.4);
    color: var(--red);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.25);
    border-color: rgba(248, 81, 73, 0.6);
}

/* --- SSH Key Status ---------------------------------------------- */
.key-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(63, 185, 80, 0.08);
    border: 1px solid rgba(63, 185, 80, 0.2);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.key-status-icon {
    font-size: 1rem;
}

.key-status-text {
    font-size: 0.85rem;
    color: var(--green);
    font-weight: 500;
}

/* --- Modal Card (simple variant for confirmations) --------------- */
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-xl);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* --- Settings Layout --------------------------------------------- */
.settings-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 720px;
}

.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-section-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.settings-section-body {
    padding: 1rem;
}

/* --- Checkbox Controls ------------------------------------------- */
.checkbox-group {
    margin-bottom: 0.75rem;
}

.checkbox-group:last-child {
    margin-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.checkbox-label:hover {
    background: var(--bg-tertiary);
}

.checkbox-label input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.checkbox-text strong {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.checkbox-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* --- Info Rows --------------------------------------------------- */
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.875rem;
}

.info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.info-value {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

/* --- System Info Grid -------------------------------------------- */
.system-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.system-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.system-info-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.system-info-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* --- Utility Classes --------------------------------------------- */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent   { color: var(--accent); }
.text-green    { color: var(--green); }
.text-red      { color: var(--red); }
.text-yellow   { color: var(--yellow); }
.text-sm       { font-size: 0.8125rem; }
.text-xs       { font-size: 0.75rem; }
.font-mono     { font-family: var(--font-mono); }
.font-sans     { font-family: var(--font-sans); }
.mt-0          { margin-top: 0; }
.mt-1          { margin-top: 0.5rem; }
.mt-2          { margin-top: 1rem; }
.mt-3          { margin-top: 1.5rem; }
.mb-0          { margin-bottom: 0; }
.mb-1          { margin-bottom: 0.5rem; }
.mb-2          { margin-bottom: 1rem; }
.mb-3          { margin-bottom: 1.5rem; }
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1         { gap: 0.5rem; }
.gap-2         { gap: 1rem; }
.gap-3         { gap: 1.5rem; }
.w-full        { width: 100%; }
.hidden        { display: none; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Filter Controls -------------------------------------------- */
.filter-btn {
    padding: 0.25rem 0.625rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.filter-btn.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.form-select-sm {
    padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* --- Task Card Link --------------------------------------------- */
.task-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.task-card-link:hover {
    color: inherit;
    text-decoration: none;
}

.task-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.task-card-project {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Task Detail Header (legacy) -------------------------------- */
.task-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.task-detail-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-detail-title h1 {
    font-size: 1.25rem;
}

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

/* --- Container Fluid -------------------------------------------- */
.container-fluid {
    padding: 0 1.5rem;
}

/* --- Screenshot Grid -------------------------------------------- */
.screenshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
}

.screenshot-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color var(--transition);
}

.screenshot-thumb:hover {
    border-color: var(--accent);
}

.context-md {
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* --- Responsive -------------------------------------------------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-area {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    .mission-grid {
        grid-template-columns: 1fr 1fr;
    }

    .task-detail-layout {
        grid-template-columns: 1fr 1fr;
    }

    .task-detail-layout > *:first-child {
        grid-column: 1 / -1;
    }

    .context-panel,
    .events-panel {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 50;
        box-shadow: var(--shadow-xl);
    }

    .context-panel { left: 0; }
    .events-panel { right: 0; }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .container {
        padding: 0 1rem;
    }

    .grid-2,
    .grid-3,
    .mission-grid {
        grid-template-columns: 1fr;
    }

    .task-detail-layout {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .form-select,
    .filter-bar .form-input {
        width: 100%;
        min-width: 0;
    }

    .server-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group-fixed {
        width: 100%;
    }

    .form-card {
        padding: 1rem;
    }

    .settings-layout {
        max-width: 100%;
    }

    .system-info-grid {
        grid-template-columns: 1fr;
    }

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

/* ================================================================
   Toast Notifications
   ================================================================ */

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 360px;
}
.toast-visible { opacity: 1; transform: translateX(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* ================================================================
   Shortcut Help
   ================================================================ */

.shortcut-grid {
    display: grid;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shortcut-item span {
    color: var(--text-secondary);
}

/* ================================================================
   File Browser (Monaco Editor)
   ================================================================ */

.file-browser {
    display: flex;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.file-tree {
    width: 240px;
    min-width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px 0;
    font-size: 0.8rem;
}

.file-item {
    padding: 4px 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.file-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.file-item.active {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.folder-toggle {
    padding: 4px 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.folder-toggle:hover {
    background: var(--bg-tertiary);
}

.folder-children {
    padding-left: 16px;
}

.folder-children.collapsed {
    display: none;
}

.file-editor {
    flex: 1;
    min-width: 0;
}

/* ================================================================
   Traffic Light Dot
   ================================================================ */
.traffic-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.task-card[data-status="running"] .traffic-dot,
.task-card[data-status="waiting_feedback"] .traffic-dot {
    animation: traffic-pulse 2s infinite;
}

@keyframes traffic-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
    50% { opacity: 0.6; box-shadow: 0 0 6px 2px currentColor; }
}

/* ================================================================
   Slide-in Panel (Mission Control)
   ================================================================ */
.slide-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1599;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

.slide-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 1600;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

.slide-panel.open {
    transform: translateX(0);
}

.slide-panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.slide-panel-header h3 {
    flex: 1;
    margin: 0;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slide-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slide-panel-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

.slide-panel-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.slide-panel-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.slide-panel-messages {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.5;
}

.slide-panel-message {
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border);
}

.slide-panel-message:last-child {
    border-bottom: none;
}

.slide-panel-message-role {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
}

@media (max-width: 640px) {
    .slide-panel {
        width: 100vw;
    }
}

/* ================================================================
   Kanban Board
   ================================================================ */
/* When kanban-board is present, main-content must not scroll vertically */
.main-content:has(.kanban-board) {
    overflow: hidden;
    padding: 0.75rem;
    height: calc(100vh - 56px);
}

.kanban-board {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    overflow-x: auto;
    height: 100%;
    align-items: stretch;
    min-width: 0;
}

.kanban-column {
    min-width: 240px;
    flex: 1 0 240px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-height: 100%;
    overflow: hidden;
}

.kanban-column-header {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.kanban-column-header .traffic-dot {
    width: 10px;
    height: 10px;
}

.kanban-column-title {
    font-size: 0.8rem;
    font-weight: 600;
    flex: 1;
}

.kanban-column-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 60px;
}

.kanban-cards .task-card {
    margin-bottom: 0;
}

.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* ================================================================
   Landing Pages
   ================================================================ */

.landing-body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    min-height: 100vh;
}

/* ── Nav ─────────────────────────────────────────────────── */
.landing-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.landing-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 2rem;
}

.landing-nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.landing-nav-logo {
    color: var(--accent);
    font-size: 1.2rem;
}

.landing-nav-links {
    display: flex;
    gap: 1.5rem;
    margin-left: auto;
}

.landing-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.landing-nav-link:hover {
    color: var(--text-primary);
}

.landing-nav-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1.5rem;
}

/* ── Hero ────────────────────────────────────────────────── */
.landing-hero {
    text-align: center;
    padding: 5rem 2rem 4rem;
    max-width: 800px;
    margin: 0 auto;
}

.landing-hero-title {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 1.25rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.landing-hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 0.95rem;
}

/* ── Sections ────────────────────────────────────────────── */
.landing-main {
    min-height: 100vh;
}

.landing-section {
    padding: 4rem 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.landing-section-alt {
    background: var(--bg-secondary);
    max-width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
}

.landing-section-alt > * {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.landing-section-title {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 2.5rem;
}

/* ── Feature Grid ────────────────────────────────────────── */
.landing-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.landing-feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.landing-feature-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.landing-feature-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.landing-feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.landing-feature-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ── Steps ───────────────────────────────────────────────── */
.landing-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
}

.landing-step {
    text-align: center;
}

.landing-step-number {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.landing-step h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.landing-step p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ── Pricing Card ────────────────────────────────────────── */
.landing-pricing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

.landing-pricing-card-lg {
    max-width: 560px;
    padding: 3rem;
}

.landing-pricing-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.landing-pricing-price {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.landing-pricing-period {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.landing-pricing-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    text-align: left;
}

.landing-pricing-features li {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.landing-pricing-features li::before {
    content: "\2713";
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
}

/* ── CTA ─────────────────────────────────────────────────── */
.landing-cta {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.landing-cta h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

/* ── Footer ──────────────────────────────────────────────── */
.landing-footer {
    border-top: 1px solid var(--border);
    padding: 2rem;
}

.landing-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

.landing-footer-brand {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.landing-footer-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.landing-footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--transition);
}

.landing-footer-links a:hover {
    color: var(--text-primary);
}

/* ── FAQ ─────────────────────────────────────────────────── */
.landing-faq {
    max-width: 700px;
    margin: 0 auto;
}

.landing-faq-item {
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
}

.landing-faq-item h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.landing-faq-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ── Feature Showcase ────────────────────────────────────── */
.landing-feature-showcase {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.landing-feature-showcase-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    transition: border-color var(--transition);
}

.landing-feature-showcase-item:hover {
    border-color: var(--accent);
}

.landing-feature-showcase-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.landing-feature-showcase-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 1rem;
}

.landing-feature-showcase-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.landing-feature-showcase-content li {
    padding: 0.3rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.landing-feature-showcase-content li::before {
    content: "\2713";
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
}

/* ── GitHub Import ───────────────────────────────────────── */
.repo-import-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.repo-import-row:last-child {
    border-bottom: none;
}

.repo-import-info {
    flex: 1;
    min-width: 0;
}

.repo-import-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .landing-hero-title {
        font-size: 2rem;
    }

    .landing-hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .landing-nav-links {
        display: none;
    }

    .landing-feature-grid {
        grid-template-columns: 1fr;
    }

    .landing-steps {
        grid-template-columns: 1fr;
    }
}
