/* ===== Design System: 2226 Lab Notebook ===== */

:root {
    /* Paper substrate */
    --bg: #fafbfc;
    --bg-secondary: #f0f2f5;
    --bg-inset: #ebedf0;
    --bg-hover: #f0f2f5;

    /* Ink — high contrast for readability */
    --text: #111318;
    --text-secondary: #3b4455;
    --text-tertiary: #6b7280;

    /* Accent — institutional blue */
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.06);
    --accent-hover: #1d4ed8;

    /* Ambient status */
    --status-active: #2563eb;
    --status-complete: #059669;
    --status-pending: #6b7280;
    --status-failed: #dc2626;
    --status-queued: #d97706;

    /* Borders */
    --border: #d0d4db;
    --border-subtle: #e2e5ea;

    /* Geometry */
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

    /* Spacing (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 150ms;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --bg-inset: #1c2128;
    --bg-hover: #1c2128;
    --text: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --accent: #58a6ff;
    --accent-soft: rgba(88, 166, 255, 0.1);
    --accent-hover: #79c0ff;
    --border: #30363d;
    --border-subtle: #21262d;
    --status-active: #58a6ff;
    --status-complete: #3fb950;
    --status-pending: #6e7681;
    --status-failed: #f85149;
    --status-queued: #d29922;
}

/* ===== Reset ===== */

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

/* Inherit fonts on form elements (browsers don't do this by default) */
input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

/* Form element base styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ===== Typography ===== */

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: -0.011em;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}



h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; }
h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; }

/* ===== Layout ===== */

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
}

main {
    padding: 60px 0;
    flex: 1;
}

/* ===== Footer ===== */

footer {
    border-top: 1px solid var(--border);
    padding: 12px 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

footer .container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-sep {
    opacity: 0.4;
}

/* ===== Header — Thin Rule ===== */

header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 4px;
}

.logo:hover {
    color: var(--text);
}

/* Breadcrumb navigation */
.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.nav-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color var(--duration) var(--ease);
}

.nav-breadcrumb a:hover {
    color: var(--accent);
}

.nav-sep {
    color: var(--text-tertiary);
    font-size: 12px;
    margin: 0 6px;
    flex-shrink: 0;
}

.nav-project-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
.nav-project-name[contenteditable] {
    cursor: text;
    border-radius: 3px;
    padding: 1px 4px;
    margin: -1px -4px;
    outline: none;
}
.nav-project-name[contenteditable]:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.nav-project-name[contenteditable]:focus {
    background: var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--accent);
}

.nav-status-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
    margin-left: 8px;
    border: none;
    cursor: default;
}

select.nav-status-badge {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 18px;
    width: auto;
    max-width: 120px;
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.nav-status-badge.status-started {
    background-color: var(--accent-soft);
    color: var(--accent);
}

.nav-status-badge.status-in-progress {
    background-color: #3b82f620;
    color: #60a5fa;
}

.nav-status-badge.status-completed {
    background-color: #22c55e20;
    color: #22c55e;
}

/* ===== User Menu Dropdown ===== */

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 3px 6px 3px 3px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--duration) var(--ease);
}

.user-menu-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-menu-name {
    font-size: 13px;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-btn svg {
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform var(--duration) var(--ease);
}

.user-menu.open .user-menu-btn svg:last-child {
    transform: rotate(180deg);
}

.user-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 240px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: fadeIn 0.15s var(--ease);
    overflow: hidden;
}

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

.user-panel-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.user-panel-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.user-panel-email {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-panel-items {
    padding: 4px 0;
}

.user-panel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    font-family: var(--font-sans);
    text-align: left;
}

.user-panel-item:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-panel-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.user-panel-item--danger {
    color: var(--status-failed);
}

.user-panel-item--danger:hover {
    background: rgba(220, 38, 38, 0.06);
    color: var(--status-failed);
}

.user-panel-sep {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Legacy nav (non-project pages) */
nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color var(--duration) var(--ease);
}

nav a:hover {
    color: var(--accent);
}

/* ===== Buttons — Instrument Controls ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--duration) var(--ease);
    font-family: var(--font-sans);
}

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

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

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

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

.btn.btn-secondary.active,
.btn.code-file-btn.active,
.code-file-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.btn-success {
    background: #22c55e;
    color: #fff;
    border: 1px solid #22c55e;
}
.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
}

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

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

.btn-danger {
    background: transparent;
    color: var(--status-failed);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.06);
    border-color: var(--status-failed);
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
    border: 1px solid #f59e0b;
}
.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 7px 0;
    border: none;
}

.btn-text:hover {
    color: var(--accent);
}

/* ===== Cards ===== */

.card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    transition: background var(--duration) var(--ease);
}

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

/* ===== Form Elements ===== */

input, textarea, select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder {
    color: var(--text-tertiary);
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 20px;
}

/* ===== Icons ===== */

.icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.icon-lg {
    width: 48px;
    height: 48px;
}

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

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: fadeIn 0.2s var(--ease);
}

.toast.toast-success {
    border-top: 2px solid var(--status-complete);
}

.toast.toast-error {
    border-top: 2px solid var(--status-failed);
}

.toast.toast-info {
    border-top: 2px solid var(--accent);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-success .toast-icon { color: var(--status-complete); }
.toast-error .toast-icon { color: var(--status-failed); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    margin: -4px;
    opacity: 0.6;
    transition: opacity var(--duration);
}

.toast-close:hover {
    opacity: 1;
}

.toast.removing {
    animation: fadeOut 0.2s var(--ease) forwards;
}

/* ===== Confirm Modal ===== */

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s var(--ease);
}

.confirm-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
    animation: scaleIn 0.2s var(--ease);
}

.confirm-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-actions .btn {
    min-width: 80px;
}

/* Input modal field */
.input-modal-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.input-modal-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ===== Keyboard shortcut badges ===== */

kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    margin-right: 4px;
    line-height: 1.6;
}

/* ===== Jobs Indicator ===== */

.jobs-indicator {
    position: relative;
}

.jobs-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--duration) var(--ease);
}

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

.jobs-btn.has-jobs {
    color: var(--accent);
}

.jobs-btn.has-jobs svg {
    animation: breathe 2s ease-in-out infinite;
}

.jobs-count {
    display: none;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--accent);
    color: white;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.jobs-count.visible {
    display: inline-flex;
}

.jobs-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 320px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: fadeIn 0.15s var(--ease);
}

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

.jobs-panel-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 8px 12px 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.jobs-panel-list {
    max-height: 320px;
    overflow-y: auto;
}

.job-item {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

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

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

.job-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.job-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

.job-item-project {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.job-item-progress {
    height: 3px;
    background: var(--bg-inset);
    border-radius: 2px;
    overflow: hidden;
}

.job-item-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.job-item-bar.failed {
    background: var(--status-failed);
}

.job-item-message {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
}

.job-item-cancel {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    background: var(--bg);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.job-item-cancel:hover {
    background: var(--status-failed);
    color: white;
    border-color: var(--status-failed);
}

.jobs-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ===== Status Indicator System ===== */

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot--active   { background: var(--status-active); }
.status-dot--complete { background: var(--status-complete); }
.status-dot--pending  { background: var(--status-pending); }
.status-dot--failed   { background: var(--status-failed); }
.status-dot--queued   { background: var(--status-queued); animation: breathe 2s ease-in-out infinite; }
.status-dot--running  { background: var(--status-active); animation: breathe 2s ease-in-out infinite; }

.status-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
}

/* ===== Utility Classes ===== */

.mono { font-family: var(--font-mono); }
.dim  { opacity: 0.5; }
.ghost { opacity: 0.35; }

/* ===== Animations ===== */

@keyframes breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

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

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}

@keyframes scaleIn {
    from { transform: scale(0.97); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ===== Command Palette ===== */

.cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10002;
    display: none;
    justify-content: center;
    padding-top: 20vh;
}

.cmd-overlay.active {
    display: flex;
}

.cmd-dialog {
    width: 520px;
    max-height: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.12s var(--ease);
    align-self: flex-start;
}

.cmd-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.cmd-input-wrap svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.cmd-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--text);
    outline: none;
    padding: 0;
    width: auto;
}

.cmd-input::placeholder {
    color: var(--text-tertiary);
}

.cmd-results {
    overflow-y: auto;
    max-height: 320px;
    padding: 4px 0;
}

.cmd-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 8px 16px 4px;
}

.cmd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.08s;
    font-size: 14px;
    color: var(--text);
}

.cmd-item:hover,
.cmd-item.selected {
    background: var(--bg-secondary);
}

.cmd-item svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.cmd-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmd-item-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.cmd-empty {
    padding: 20px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ===== Stage Duration ===== */

.stage-duration {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.stage-duration svg {
    opacity: 0.5;
}

/* ===== Relative Timestamps ===== */

.timeago {
    cursor: default;
}
