/* ============================================
   BioDOE - Exact Replica of Mockup UI
   ============================================ */

:root {
    /* Modern SaaS palette — clean neutral slate + a single indigo accent.
       No warm/brown tones anywhere. */
    --bg-base: #F8FAFC;
    --bg-surface: #ffffff;
    --bg-surface-hover: #F1F5F9;

    /* Sidebar */
    --sidebar-bg: #F8FAFC;
    --sidebar-text: #64748B;
    --sidebar-text-active: #4F46E5;
    --sidebar-active-bg: #EEF2FF;
    --sidebar-border: #E2E8F0;
    --sidebar-width: 220px;

    /* Typography */
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;

    /* Table Headers — a single accent family, two shades, so the two
       tables read as distinct without introducing an extra hue */
    --factor-header-bg: #4F46E5;
    --response-header-bg: #0EA5E9;
    --matrix-header-bg: #4F46E5;

    /* Primary Accent — indigo */
    --teal: #4F46E5;
    --teal-hover: #4338CA;
    --teal-light: #EEF2FF;
    --teal-border: #C7D2FE;

    /* Secondary accent — emerald, for success/confirmation states */
    --agar: #059669;
    --agar-soft: #ECFDF5;
    --agar-ink: #065F46;
    --agar-border: #A7F3D0;

    /* Alert — red, used sparingly */
    --alert: #DC2626;
    --alert-soft: #FEF2F2;
    --alert-border: #FECACA;
    --alert-ink: #991B1B;

    /* Borders & Radius */
    --border-color: #E2E8F0;
    --border-light: #F1F5F9;
    --radius: 10px;
    --radius-sm: 6px;
    --topbar-height: 56px;

    /* Type system: one clean sans-serif for everything written, monospace
       reserved for tabular data so numbers line up. */
    --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* --- App Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

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

.sidebar-logo {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    font-size: 26px;
    color: var(--teal);
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    color: #1a202c;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 10px;
    color: #718096;
    font-weight: 500;
}

.nav-menu {
    flex: 1;
    padding: 8px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(20, 138, 123, 0.08);
    color: var(--teal);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.nav-item i {
    font-size: 15px;
    color: var(--teal);
    width: 18px;
    text-align: center;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #718096;
    padding: 16px 12px 6px;
}

.btn-new-project {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    color: var(--teal);
    background: var(--teal-light);
    border: 1px solid var(--teal-border);
    border-radius: 999px;
    padding: 3px 9px 3px 7px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-new-project:hover {
    background: var(--teal-border);
}

.btn-new-project i {
    font-size: 13px;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.project-item:hover {
    background: rgba(0,0,0,0.04);
}

.project-item.active {
    background: var(--sidebar-active-bg);
    color: var(--teal);
    font-weight: 600;
}

.project-item .proj-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-item .delete-btn {
    opacity: 0;
    font-size: 13px;
    color: #e53e3e;
    transition: opacity 0.15s;
}

.project-item:hover .delete-btn {
    opacity: 0.7;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-base);
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.breadcrumbs {
    font-size: 12px;
    color: var(--text-muted);
}

.breadcrumbs .highlight {
    color: var(--text-primary);
    font-weight: 500;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
}

.edit-icon {
    font-size: 14px;
    color: var(--teal);
    cursor: pointer;
}

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

/* --- Content Area --- */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* --- Views --- */
.view-section { display: none; }
.view-section.active { display: block; }

/* ============================================
   TABBED WORKSPACE — one panel full-width at a time
   ============================================ */

.workspace-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
}

.workspace-tab {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-bottom: none;
    padding: 10px 18px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.workspace-tab:hover { color: var(--text-primary); }
.workspace-tab:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.workspace-tab.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(32,41,31,0.06), 0 6px 16px -10px rgba(32,41,31,0.22);
    transform: translateY(1px);
    position: relative;
    z-index: 1;
}

.workspace-panels {
    height: calc(100vh - var(--topbar-height) - 32px - 41px);
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(32,41,31,0.06), 0 6px 16px -10px rgba(32,41,31,0.22);
    width: 100%;
    height: 100%;
}

.panel.active-tab {
    display: flex;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-surface);
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-header .panel-icon {
    font-size: 16px;
    color: var(--teal);
    cursor: pointer;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

/* --- Panel 1: Factors & Responses --- */
.section-label {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Info tooltip — replaces a paragraph of explanation with an (i) icon that
   reveals the same text on hover/focus, so the panel isn't dominated by
   prose the user only needs to read once. */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-muted);
    font-size: 10px;
    cursor: help;
    position: relative;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: normal;
}
.info-tip:hover, .info-tip:focus-visible {
    background: var(--teal-light);
    color: var(--teal-hover);
    outline: none;
}
.info-tip::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: 140%;
    background: var(--text-primary);
    color: var(--bg-surface);
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.5;
    padding: 9px 11px;
    border-radius: 6px;
    width: 250px;
    box-shadow: 0 6px 16px -6px rgba(32,41,31,0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease;
    z-index: 50;
    pointer-events: none;
}
.info-tip:hover::after, .info-tip:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.panel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.factor-table th {
    background: var(--factor-header-bg);
    color: white;
    padding: 7px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 10.5px;
    font-family: var(--font-body);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.response-table th {
    background: var(--response-header-bg);
    color: white;
    padding: 7px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 10.5px;
    font-family: var(--font-body);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.panel-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 12px;
}

.panel-table tr:hover td {
    background: var(--bg-surface-hover);
}

.td-actions {
    text-align: right;
    white-space: nowrap;
    width: 68px;
}

.td-actions i {
    cursor: pointer;
    font-size: 13px;
    color: var(--teal);
    margin-left: 4px;
}

/* Bigger, easier-to-hit click targets for row edit/delete icons — the plain
   13px glyphs they replaced were genuinely hard to click precisely. */
.row-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 2px;
    transition: background .15s ease;
}
.row-action-icon:hover { background: var(--bg-surface-hover); }
.edit-factor-btn, .edit-response-btn { color: var(--teal-hover); }
.delete-factor-btn, .delete-response-btn { color: var(--alert); }

.add-link-wrapper {
    text-align: right;
    margin-bottom: 14px;
}

.add-factor-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--teal-hover);
    background: var(--teal-light);
    border: 1.5px solid var(--teal-border);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.add-factor-link:hover {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
    transform: translateY(-1px);
}

/* --- Panel 2: Design of Experiment --- */
.section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.table-responsive {
    overflow-x: auto;
    max-height: 400px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.matrix-table th {
    background: var(--matrix-header-bg);
    color: white;
    padding: 7px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 10.5px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

.matrix-table td {
    padding: 5px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.matrix-table tr:nth-child(even) td {
    background: var(--bg-surface-hover);
}

.table-input {
    width: 100%;
    padding: 3px 4px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 11px;
    font-family: var(--font-mono);
    text-align: center;
    outline: none;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.table-input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(184, 122, 23, 0.18);
}

/* --- Editable response column header (added via the Panel 2 "+ Add
   Response" button) --- */
.response-col-header {
    min-width: 108px;
    vertical-align: top;
}

.response-col-inner {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 2px 0;
}

.response-name-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px dashed rgba(255,255,255,0.5);
    color: white;
    font-weight: 700;
    font-size: 10.5px;
    text-transform: none;
    letter-spacing: normal;
    text-align: center;
    padding: 1px 2px;
    outline: none;
}

.response-name-input:focus {
    border-bottom-color: white;
}

.response-col-controls {
    display: flex;
    align-items: center;
    gap: 3px;
}

.response-unit-input {
    width: 0;
    flex: 1;
    background: rgba(255,255,255,0.18);
    border: none;
    border-radius: 3px;
    color: white;
    font-size: 9px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    text-align: center;
    padding: 2px 3px;
    outline: none;
}

.response-unit-input::placeholder {
    color: rgba(255,255,255,0.65);
}

.response-goal-select {
    background: rgba(255,255,255,0.18);
    border: none;
    border-radius: 3px;
    color: white;
    font-size: 9px;
    font-weight: 500;
    text-transform: none;
    padding: 2px 1px;
    outline: none;
}

.response-goal-select option {
    color: var(--text-primary);
}

.delete-response-col {
    color: white;
    opacity: 0.75;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.delete-response-col:hover {
    opacity: 1;
}

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

/* --- Panel 3: Data Analysis --- */
.chart-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--bg-surface);
}

.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}
.stat-card-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}
.stat-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Same principle, smaller scale: one mini-chart per factor. More factors
   add rows instead of shrinking every mini-chart toward unreadable. */
.main-effects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    min-height: auto;
}

.chart-heading {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}

.plot-container {
    width: 100%;
    min-height: 180px;
}

.chart-placeholder {
    height: 160px;
    background: var(--bg-surface-hover);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: box-shadow .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
    font-family: var(--font-body);
}

.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn-teal-filled {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.btn-teal-filled:hover {
    background: var(--teal-hover);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

.btn-teal-outline {
    background: var(--bg-surface);
    color: var(--teal);
    border-color: var(--border-color);
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}

.btn-teal-outline:hover {
    background: var(--teal-light);
    border-color: var(--teal-border);
}

.btn-danger-outline {
    background: var(--bg-surface);
    color: var(--alert);
    border-color: var(--border-color);
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}

.btn-danger-outline:hover {
    background: var(--alert-soft);
    border-color: var(--alert-border);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.surface-view-toggle {
    background: var(--bg-surface);
    color: var(--text-muted);
}

.surface-view-toggle.active {
    background: var(--teal);
    color: white;
}

/* --- Utility classes --- */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }

/* Stats Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.data-table th {
    background: var(--matrix-header-bg);
    color: white;
    padding: 5px 6px;
    text-align: left;
    font-family: var(--font-body);
    font-size: 10.5px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 700;
}

.data-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Modal Wizard Overlay */
.wizard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

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

.wizard-container {
    background: var(--bg-surface);
    width: 800px;
    max-width: 90vw;
    height: 550px;
    border-radius: 12px;
    display: flex;
    box-shadow: 0 20px 40px rgba(32,41,31,0.28);
    overflow: hidden;
}

/* --- Toast Notifications --- */
.app-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    max-width: 380px;
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.app-toast-enter {
    opacity: 1;
    transform: translateY(0);
}

.app-toast.app-toast-exit {
    opacity: 0;
    transform: translateY(8px);
}

.app-toast-message {
    flex: 1;
    white-space: pre-line;
    word-break: break-word;
}

.app-toast-close {
    cursor: pointer;
    opacity: 0.6;
    flex-shrink: 0;
}

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

.app-toast-success { background: var(--agar-soft); border-color: var(--agar-border); color: var(--agar-ink); }
.app-toast-success > i:first-child { color: var(--agar); }

.app-toast-error { background: var(--alert-soft); border-color: var(--alert-border); color: var(--alert-ink); }
.app-toast-error > i:first-child { color: var(--alert); }

.app-toast-info { background: var(--teal-light); border-color: var(--teal-border); color: var(--teal-hover); }
.app-toast-info > i:first-child { color: var(--teal); }

/* --- Confirm / Prompt Dialog (reuses .wizard-overlay for backdrop/positioning) --- */
.app-dialog-container {
    background: var(--bg-surface);
    width: 420px;
    max-width: 90vw;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(32,41,31,0.28);
}

.app-dialog-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.app-dialog-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 16px;
    white-space: pre-line;
}

.app-dialog-input {
    width: 100%;
    font-size: 13px;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid #CBD5E1;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.app-dialog-textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.wizard-sidebar {
    width: 200px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
}

.wizard-sidebar h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
}

.wizard-steps { list-style: none; }
.wizard-steps li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.wizard-steps li.active {
    color: var(--teal);
    font-weight: 600;
}

.step-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 10px;
}

.wizard-steps li.active .step-num {
    background: var(--teal);
    color: white;
}

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

.wizard-pane { display: none; }
.wizard-pane.active { display: block; }

.wizard-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.input-field {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-body);
    background: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
    min-width: 0; /* let it shrink inside a flex/grid row instead of forcing the row to overflow */
}

.input-field:focus {
    border-color: var(--teal);
}

.dial-builder {
    background: var(--bg-surface-hover);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Range-slider dials — turning a knob, not filling a form field */
input[type="range"].dial-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--agar-soft), var(--teal-light));
    outline: none;
    margin: 10px 0 4px;
}
input[type="range"].dial-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    border: 3px solid var(--bg-surface);
    box-shadow: 0 0 0 1.5px var(--teal);
    cursor: pointer;
    margin-top: -6px;
}
input[type="range"].dial-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    border: 3px solid var(--bg-surface);
    box-shadow: 0 0 0 1.5px var(--teal);
    cursor: pointer;
}
.dial-slider-endpoints {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
}

/* Live range preview under the Low/High fields when adding a numeric factor —
   the closest honest equivalent of a "dial" for a range that doesn't exist
   yet (a slider needs a domain to drag within; here the user IS defining
   that domain, so there's nothing to drag until both ends are typed). */
.range-preview { margin-top: 2px; }
.range-preview-track {
    height: 6px;
    border-radius: 99px;
    background: var(--border-color);
    position: relative;
    overflow: hidden;
}
.range-preview-fill {
    position: absolute;
    top: 0; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(90deg, var(--agar), var(--teal));
    border-radius: 99px;
}
.range-preview-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 3px;
}

.dial-input-row {
    display: flex;
    gap: 6px;
}

.dial-list { margin-top: 10px; }

.dial-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 12px;
}

/* --- Goal cards (replaces the plain intent dropdown) --- */
.goal-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}
@media (max-width: 900px) {
    .goal-cards { grid-template-columns: 1fr; }
}
.goal-card {
    text-align: left;
    cursor: pointer;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-family: inherit;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.goal-card:hover { transform: translateY(-1px); }
.goal-card:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.goal-card .goal-glyph { font-size: 18px; }
.goal-card .goal-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-primary);
}
.goal-card.selected {
    border-color: var(--teal);
    background: var(--teal-light);
}
.goal-card.selected .goal-name { color: var(--teal-hover); }

/* --- Mobile sidebar drawer ---
   On a phone-width viewport the fixed 220px sidebar used to eat ~40% of the
   screen permanently with no way to hide it. Below 768px it becomes an
   off-canvas drawer: hidden by default, hamburger-toggled, closes on
   backdrop tap or on navigating. */
.btn-mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
}

@media (max-width: 768px) {
    .btn-mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 2px 0 16px rgba(15, 23, 42, 0.18);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-backdrop.mobile-open {
        display: block;
    }

    .main-content {
        width: 100%;
        min-width: 0;
    }

    /* The New Experiment wizard's sidebar+content layout assumes ~800px of
       room — at phone widths the fixed 200px sidebar left almost nothing for
       the content pane, clipping every field and button. Stack instead of
       side-by-side, and let it scroll as one column rather than fixing a
       550px height that doesn't fit every step's content on a small screen. */
    .wizard-container {
        width: 95vw;
        height: auto;
        max-height: 85vh;
        flex-direction: column;
        overflow-y: auto;
    }

    .wizard-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
    }

    .wizard-sidebar h3 {
        margin-bottom: 10px;
    }

    .wizard-steps {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 16px;
    }

    .wizard-steps li {
        padding: 2px 0;
    }

    .wizard-content {
        padding: 16px;
    }

    /* Topbar overflow: the rename hint, the upgrade button's price detail,
       and the signed-in user's name/role text together push the row past
       375px with no way to reach the clipped Upgrade button — .main-content
       has overflow-x:hidden, so it doesn't scroll into view, it just
       vanishes. Hide/shrink the non-essential pieces instead of letting the
       row wrap, since .topbar's fixed height feeds into other elements'
       calc(100vh - var(--topbar-height) - ...) sizing elsewhere. */
    .topbar {
        padding: 0 6px;
    }
    .topbar-right {
        gap: 4px;
    }
    .btn-mobile-menu-toggle {
        margin-right: 4px;
    }
    .page-title-row > span {
        display: none !important;
    }
    .page-title {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .breadcrumbs {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #header-user-plan-container {
        margin-right: 4px !important;
        gap: 4px !important;
    }
    .tier-badge-label,
    .upgrade-to-pro-suffix,
    .upgrade-price-suffix {
        display: none;
    }
    #btn-header-upgrade-pro {
        padding: 6px 10px !important;
    }
    #btn-open-login {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
    #user-profile-badge {
        margin-right: 4px !important;
        padding: 4px 6px !important;
        gap: 4px !important;
    }
    #user-profile-badge > div:nth-child(2) {
        display: none;
    }
    #btn-logout {
        margin-left: 0 !important;
        padding: 6px 8px !important;
    }
    .logout-label {
        display: none;
    }
}

/* Landing page (marketing site) mobile layout. Its sections are built with
   inline styles (see index.html), so overrides here need !important to win
   — these are the fixed multi-column grids that would otherwise force
   horizontal scrolling or illegibly narrow columns on a phone. */
@media (max-width: 860px) {
    #view-landing {
        padding: 16px 20px 60px !important;
    }
    #landing-nav-links {
        display: none !important;
    }
    #landing-nav-resources-mobile {
        display: flex !important;
    }
    #landing-hero-grid,
    #landing-features-grid,
    #landing-solutions-grid,
    #landing-pricing-grid {
        grid-template-columns: 1fr !important;
    }
    /* One card (Solution 5) spans 2 columns on desktop via grid-column:
       span 2 — with only one explicit column left on mobile, that forces
       the grid to auto-generate a second, content-sized implicit column
       instead of actually going full-width. Reset every card back to
       natural single-column placement. */
    #landing-solutions-grid > div {
        grid-column: auto !important;
    }
    #landing-hero-grid h1 {
        font-size: 30px !important;
    }
    #testimonial-section {
        grid-template-columns: 1fr !important;
        text-align: center;
        padding: 28px !important;
    }
    #testimonial-section img {
        margin: 0 auto;
    }
}

/* Clean print output for the Experimental Summary Report (#modal-report).
   The standard "hide everything, then re-show just the target" trick:
   without it, printing captures the whole app chrome as-is. The modal
   itself also needs its own fixed/overflow/height constraints reset —
   #modal-report is a position:fixed, height-capped, scrollable dialog on
   screen, so printing it unchanged would only capture its current on-screen
   scroll viewport instead of letting the full report flow across pages. */
@media print {
    body * {
        visibility: hidden;
    }
    #modal-report, #modal-report * {
        visibility: visible;
    }
    #modal-report {
        position: static !important;
        inset: auto !important;
        background: none !important;
        backdrop-filter: none !important;
        display: block !important;
    }
    #modal-report .wizard-container {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }
    #report-modal-content {
        overflow: visible !important;
        max-height: none !important;
    }
    #close-modal-report, #btn-print-report, #btn-export-report-csv {
        display: none !important;
    }
}

/* --- Pipetting Guide: setup modal --- */
.pg-general-grid {
    display: grid;
    /* minmax(0, …) lets the inputs shrink below their natural width. */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.pg-general-grid .input-field { width: 100%; box-sizing: border-box; }
.pg-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 3px;
}
.pg-section-title {
    font-size: 12px;
    font-weight: 800;
    color: #0F172A;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.pg-factor-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.1fr) minmax(200px, 1.3fr) minmax(200px, 1.4fr);
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid #E2E8F0;
}
.pg-factor-name strong { font-size: 13px; color: #0F172A; }
.pg-factor-levels { font-size: 11px; color: #64748B; margin-top: 2px; }
.pg-factor-detail { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pg-factor-detail .input-field { width: 110px; }
.pg-factor-detail .pg-unit-select { width: 90px; }
.pg-detail-label { color: #334155; font-weight: 600; }
.pg-detail-muted { color: #64748B; font-size: 12px; }
.pg-unit-fixed { color: #334155; font-weight: 600; }
.pg-empty { font-size: 13px; color: #64748B; padding: 10px 0; }
#pg-issues { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.pg-issue {
    font-size: 12.5px;
    line-height: 1.45;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid;
}
.pg-issue-error { background: #FEF2F2; border-color: #FCA5A5; color: #991B1B; }
.pg-issue-warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.pg-issue-ok { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
#btn-pg-open-guide:disabled, #btn-pg-download-csv:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 720px) {
    .pg-general-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pg-factor-row { grid-template-columns: 1fr; gap: 6px; }
}

/* --- Pipetting Guide: printable document --- */
#print-guide-root {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: #F1F5F9;
    overflow-y: auto;
}
.pg-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #CBD5E1;
}
.pg-doc {
    max-width: 1000px;
    margin: 20px auto 60px;
    background: white;
    padding: 32px 36px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    color: #0F172A;
}
.pg-doc h1 { font-size: 22px; font-weight: 900; margin: 0 0 4px; }
.pg-doc h2 { font-size: 17px; font-weight: 800; margin: 24px 0 8px; }
.pg-doc h3 { font-size: 13px; font-weight: 800; margin: 16px 0 6px; color: #334155; }
.pg-meta { font-size: 12px; color: #64748B; margin-bottom: 12px; }
.pg-steps { font-size: 13px; line-height: 1.6; padding-left: 20px; margin: 0 0 8px; }
.pg-plate-settings {
    font-size: 13px;
    font-weight: 700;
    background: #EEF2FF;
    color: #3730A3;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}
.pg-plate-svg { margin: 8px 0 4px; overflow-x: auto; }
.pg-plate-svg svg { max-width: 100%; height: auto; }
.pg-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 6px; }
.pg-table th, .pg-table td { border: 1px solid #CBD5E1; padding: 5px 7px; text-align: left; vertical-align: top; }
.pg-table th { background: #F8FAFC; font-weight: 700; }
.pg-mix-table td:not(:nth-child(2)):not(:nth-child(3)) { font-variant-numeric: tabular-nums; }
.pg-check {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid #475569;
    border-radius: 2px;
}
.pg-warnings {
    margin: 14px 0;
    padding: 10px 14px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    font-size: 12.5px;
    color: #92400E;
}
.pg-warnings ul { margin: 6px 0 0; padding-left: 18px; }

@page { margin: 12mm; }
@media print {
    /* display:none (not visibility:hidden like the report rule above), so
       the hidden app takes no space and the guide doesn't start after
       blank pages. Only active while printing the guide. */
    body.printing-guide > *:not(#print-guide-root) { display: none !important; }
    body.printing-guide #print-guide-root,
    body.printing-guide #print-guide-root * { visibility: visible !important; }
    body.printing-guide #print-guide-root {
        position: static !important;
        overflow: visible !important;
        background: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body.printing-guide .pg-doc { max-width: none; margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
    .pg-noprint { display: none !important; }
    .pg-plate { break-before: page; }
    .pg-table tr { break-inside: avoid; }
    .pg-table thead { display: table-header-group; }
}
