/* === Granny's Grimoire === */
/* Aesthetic: witchy-cozy-magical. Tarot by the fire. Hot chocolate. Kind friend. */
/* Dark botanical palette. Candlelight warmth. Rich textures. No sterility. */

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
    /* Dark botanical base */
    --bg: #161d1a;
    --bg-surface: #1e2825;
    --bg-card: #243028;
    --bg-elevated: #2c3a32;
    --bg-glow: rgba(196, 122, 90, 0.04);

    /* Text — warm parchment tones */
    --text: #e8dfd0;
    --text-dim: #a89e8f;
    --text-muted: #6b6358;

    /* Accent — candlelight copper/amber */
    --ember: #c47a5a;
    --ember-glow: #d4956f;
    --ember-deep: #a35d3f;
    --ember-soft: rgba(196, 122, 90, 0.12);
    --ember-ghost: rgba(196, 122, 90, 0.06);

    /* Secondary accents */
    --gold: #b8965a;
    --plum: #7a4a6b;
    --sage: #5a8a6f;
    --moss: #3d5c47;

    /* Functional */
    --border: rgba(255, 255, 255, 0.06);
    --border-warm: rgba(196, 122, 90, 0.15);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 4px 20px rgba(196, 122, 90, 0.1);
    --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Yarn colors (user's) */
    --yarn-a: rgb(0, 75, 45);
    --yarn-b: rgb(140, 175, 60);
    --yarn-c: rgb(140, 100, 75);
}

html, body {
    height: 100%;
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Subtle texture overlay */
body::before {
    content: '';
    position: fixed; inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.015'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* === App Shell === */
#app { display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; }

/* === Header === */
.app-header {
    display: flex; align-items: center; padding: 0.6rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    z-index: 20; gap: 0.6rem; flex-shrink: 0;
}
.app-header .logo {
    font-family: 'Georgia', serif;
    font-weight: 700; font-style: italic;
    color: var(--ember-glow); font-size: 1.05rem;
    letter-spacing: 0.3px;
}
.app-header .project-info {
    flex: 1; font-size: 0.75rem; color: var(--text-dim);
    text-align: center; font-family: -apple-system, system-ui, sans-serif;
}
.app-header .project-info strong { color: var(--text); font-weight: 600; }
.header-btn {
    background: none; border: none; font-size: 1.1rem; cursor: pointer;
    padding: 0.35rem 0.4rem; color: var(--text-dim);
    border-radius: var(--radius-sm); transition: all var(--transition);
}
.header-btn:hover { background: var(--ember-soft); color: var(--ember-glow); }
.wake-lock-on { color: var(--ember-glow) !important; }

/* === Tab Bar === */
.tab-bar {
    display: flex; background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; z-index: 15;
}
.tab {
    flex: 1; padding: 0.6rem; text-align: center;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: -apple-system, system-ui, sans-serif;
    color: var(--text-muted); cursor: pointer;
    border: none; border-bottom: 2px solid transparent;
    background: none; transition: all var(--transition);
}
.tab.active {
    color: var(--ember-glow);
    border-bottom-color: var(--ember);
    background: var(--ember-ghost);
}
.tab:hover:not(.active) { color: var(--text-dim); background: var(--bg-card); }

/* === Views === */
.view { display: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view.active { display: flex; flex-direction: column; }

/* === Project View === */
.project-view { padding: 0; gap: 0; }
.plan-view { padding: 0.75rem; padding-bottom: 0; gap: 0.5rem; }
.plan-toggle {
    display: flex;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-warm);
    overflow: hidden;
}
.plan-toggle-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: -apple-system, system-ui, sans-serif;
    cursor: pointer;
    transition: all var(--transition);
}
.plan-toggle-btn.active {
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: #fdf6f0;
}
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-warm); box-shadow: var(--shadow-glow); }
.card-title {
    font-size: 0.7rem; font-weight: 700;
    font-family: -apple-system, system-ui, sans-serif;
    color: var(--ember); letter-spacing: 1px;
    text-transform: uppercase; margin-bottom: 0.5rem;
}
.card-row {
    display: flex; gap: 0.5rem; padding: 0.3rem 0;
    font-size: 0.85rem; font-family: -apple-system, system-ui, sans-serif;
}
.card-row .label { color: var(--text-dim); }
.card-row .value { font-weight: 600; color: var(--text); }
.yarn-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.6rem; border-radius: 20px;
    font-size: 0.8rem; font-weight: 600;
    font-family: -apple-system, system-ui, sans-serif;
    background: var(--bg-elevated); border: 1px solid var(--border);
    margin: 0.15rem 0.1rem;
}
.yarn-dot {
    width: 12px; height: 12px; border-radius: 50%;
    box-shadow: 0 0 6px rgba(255,255,255,0.1);
}

/* Section list */
.section-list { display: flex; flex-direction: column; gap: 0.15rem; }
.section-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.6rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; cursor: pointer;
    font-family: -apple-system, system-ui, sans-serif;
    transition: all var(--transition);
}
.section-item:hover { background: var(--ember-ghost); transform: translateX(3px); }
.section-item .status {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; flex-shrink: 0; transition: all var(--transition);
}
.section-item .status.done {
    background: var(--ember); border-color: var(--ember);
    color: var(--bg); box-shadow: 0 0 8px rgba(196,122,90,0.3);
}
.section-item .status.active {
    border-color: var(--ember-glow);
    box-shadow: 0 0 6px rgba(196,122,90,0.2);
}
.section-item .name { flex: 1; color: var(--text); }
.section-item .detail { font-size: 0.7rem; color: var(--text-muted); }

/* Progress */
.progress-mini {
    width: 100%; height: 4px;
    background: var(--bg-elevated); border-radius: 2px; overflow: hidden;
}
.progress-mini-fill {
    height: 100%; border-radius: 2px;
    background: linear-gradient(90deg, var(--ember-deep), var(--ember-glow));
    box-shadow: 0 0 8px rgba(196,122,90,0.3);
    transition: width 0.5s ease;
}

/* === Section View (Knitting) === */
.section-view.active { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.section-header {
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.section-name { font-size: 1rem; font-weight: 700; color: var(--text); font-family: Georgia, serif; }
.section-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; font-family: -apple-system, sans-serif; }

/* Row strip */
.row-strip {
    display: flex; align-items: center; padding: 0.4rem 1rem;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    gap: 0.5rem; flex-shrink: 0; min-height: 36px;
    font-family: -apple-system, system-ui, sans-serif;
}
.row-num { font-weight: 700; color: var(--ember-glow); font-size: 1rem; }
.row-side {
    font-size: 0.65rem; font-weight: 700; padding: 0.15rem 0.4rem;
    border-radius: 4px; letter-spacing: 0.3px;
}
.row-side.rs { background: rgba(90, 138, 111, 0.2); color: var(--sage); }
.row-side.ws { background: rgba(184, 150, 90, 0.15); color: var(--gold); }
.row-segments { flex: 1; display: flex; gap: 0.2rem; overflow-x: auto; scrollbar-width: none; }
.row-segments::-webkit-scrollbar { display: none; }
.seg {
    display: inline-flex; align-items: center; gap: 0.15rem;
    padding: 0.15rem 0.4rem; border-radius: 4px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
    background: var(--bg-elevated); border: 1px solid var(--border);
}
.seg-dot { width: 8px; height: 8px; border-radius: 2px; box-shadow: 0 0 4px rgba(255,255,255,0.1); }
.row-total { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }

/* Instructions */
.instructions {
    overflow-y: auto; padding: 1rem;
    -webkit-overflow-scrolling: touch;
    max-height: 30vh;
    font-family: -apple-system, system-ui, sans-serif;
}
.instruction-step {
    padding: 0.6rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.88rem; line-height: 1.6; color: var(--text);
}
.instruction-step:last-child { border-bottom: none; }
.instruction-step .step-label {
    font-weight: 700; color: var(--ember);
    font-size: 0.75rem; margin-bottom: 0.2rem;
    letter-spacing: 0.3px;
}
.tip-box {
    background: rgba(184, 150, 90, 0.08);
    border-left: 3px solid var(--gold);
    padding: 0.5rem 0.75rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0.5rem 0; font-size: 0.8rem; color: var(--text-dim);
}

/* === Chart + Cuts Layout === */
.chart-and-cuts {
    display: flex; flex: 1; overflow: hidden;
    border-top: 1px solid var(--border);
    min-height: 0;
}

/* === Integrated Row Strip (inside chart panel) === */
.integrated-row-strip {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.irs-arrow {
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    color: var(--ember-glow);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.irs-arrow:hover { background: var(--ember-ghost); }
.irs-arrow:active { background: var(--ember-soft); }
.irs-arrow:disabled { opacity: 0.2; cursor: not-allowed; }
.irs-arrow.active { color: var(--ember); background: var(--ember-ghost); }

.irs-center {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 0.35rem 0.3rem;
    transition: background var(--transition);
}
.irs-center:active { background: var(--ember-ghost); }

.irs-row-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.25rem;
}

/* === Strip Position Picker === */
.strip-pos-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 50;
}
.spp-option {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    border: none;
    background: none;
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    font-family: -apple-system, system-ui, sans-serif;
    transition: all var(--transition);
}
.spp-option.active {
    background: var(--ember);
    color: var(--bg);
}
.spp-option:not(.active):hover {
    background: var(--bg-surface);
    color: var(--text);
}
.irs-inline-exit {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    opacity: 0.6;
    transition: all var(--transition);
}
.irs-inline-exit:hover {
    opacity: 1;
    color: var(--ember-glow);
    border-color: var(--ember);
}

/* === Bottom Bar (tabbed: progress/yarn/instructions) === */
.bottom-bar {
    flex-shrink: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.bottom-bar-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 2;
}
.bb-tab {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: -apple-system, system-ui, sans-serif;
    border-bottom: 2px solid transparent;
}
.bb-tab.active {
    color: var(--ember-glow);
    border-bottom-color: var(--ember);
    background: var(--ember-ghost);
}
.bb-tab:not(.active):hover {
    color: var(--text-dim);
    background: var(--bg-elevated);
}
.bottom-bar-content {
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
}

/* === Yarn & Progress Panel === */
.yarn-progress-panel {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.yp-progress { margin-bottom: 0.1rem; }
.yp-bar {
    height: 3px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.15rem;
}
.yp-bar-fill {
    height: 100%;
    background: var(--sage);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.yp-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    color: var(--text-muted);
}
.yp-skeins {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.yp-skein-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.yp-skein-label {
    color: var(--dot-color);
    font-size: 0.8rem;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}
.yp-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
}
.yp-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--dot-color);
    background: none;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.4;
}
.yp-dot.current {
    opacity: 1;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--dot-color);
}
.yp-dot.done {
    background: var(--dot-color);
    opacity: 1;
}
.yp-dot:hover { opacity: 1; transform: scale(1.2); }
.yp-skein-count {
    font-size: 0.6rem;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}
.yp-weigh {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.62rem;
    color: var(--text-muted);
    padding-top: 0.3rem;
    border-top: 1px solid var(--border);
}
.yp-weigh-btn {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: none;
    color: var(--text-dim);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all var(--transition);
}
.yp-weigh-btn:hover { border-color: var(--ember); color: var(--ember); }

.irs-row-num {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ember-glow);
    font-family: -apple-system, system-ui, sans-serif;
}
.irs-side {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.12rem 0.35rem;
    border-radius: 3px;
}
.irs-side.rs { background: rgba(90, 138, 111, 0.2); color: var(--sage); }
.irs-side.ws { background: rgba(184, 150, 90, 0.15); color: var(--gold); }
.irs-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}
.irs-segments {
    display: flex;
    height: 28px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}
.irs-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2px;
    position: relative;
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 1px rgba(0,0,0,0.4);
}
.irs-prev-row {
    display: flex;
    height: 6px;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
    opacity: 0.9;
    margin-top: 2px;
    filter: brightness(0.9);
}
.irs-prev-seg {
    height: 100%;
}
.chart-container {
    flex: 1; overflow: auto; background: var(--bg);
    -webkit-overflow-scrolling: touch; min-width: 0;
    position: relative;
}
.chart-container canvas { display: block; }

.panel-divider {
    width: 5px; cursor: col-resize;
    background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; touch-action: none;
    transition: background var(--transition);
}
.panel-divider:hover, .panel-divider:active { background: var(--ember); }
.panel-divider::after {
    content: ''; width: 1.5px; height: 20px;
    background: var(--text-muted); border-radius: 1px; opacity: 0.4;
}

.cuts-panel {
    width: 220px; min-width: 120px; max-width: 50%;
    overflow-y: auto; background: var(--bg-surface);
    border-left: 1px solid var(--border);
    font-size: 0.78rem; -webkit-overflow-scrolling: touch; flex-shrink: 0;
    font-family: -apple-system, system-ui, sans-serif;
}
.cuts-panel-header {
    padding: 0.5rem 0.6rem; font-weight: 700; font-size: 0.75rem;
    color: var(--ember); letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-surface); z-index: 2;
}
.cuts-panel-body { padding: 0.4rem 0.5rem; }
.cut-row {
    display: flex; justify-content: space-between;
    padding: 0.25rem 0; font-size: 0.75rem; color: var(--text-dim);
    cursor: pointer;
}
.cut-row.total {
    font-weight: 700; color: var(--text);
    border-top: 1px solid var(--border); margin-top: 0.3rem; padding-top: 0.4rem;
}
.cut-color-header {
    display: flex; align-items: center; gap: 0.4rem;
    font-weight: 700; font-size: 0.8rem; color: var(--text);
    margin-top: 0.6rem; margin-bottom: 0.2rem;
}
.cut-dot {
    width: 10px; height: 10px; border-radius: 3px;
    box-shadow: 0 0 4px rgba(255,255,255,0.1);
}

@media (max-width: 700px) {
    .panel-divider { width: 3px; }
    .cuts-panel {
        width: 160px; min-width: 100px;
    }
}

/* === PDF View === */
.pdf-view { align-items: center; justify-content: center; padding: 2rem; }
.pdf-placeholder {
    text-align: center; padding: 3rem; color: var(--text-muted);
    font-size: 0.9rem; font-style: italic;
}

/* === Bottom Bar === */
.bottom-bar {
    display: flex; align-items: center; justify-content: center;
    padding: 0.6rem 1rem; background: var(--bg-surface);
    border-top: 1px solid var(--border); z-index: 20;
    gap: 0.75rem; flex-shrink: 0;
}
.btn-advance {
    display: flex; flex-direction: column; align-items: center;
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: #fdf6f0; border: none;
    border-radius: var(--radius); padding: 0.6rem 2.5rem;
    cursor: pointer; font-family: Georgia, serif;
    transition: all var(--transition); min-width: 160px;
    box-shadow: 0 2px 12px rgba(196, 122, 90, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-advance:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(196, 122, 90, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-advance:active { transform: scale(0.97); }
.btn-advance .adv-row { font-size: 1.05rem; font-weight: 700; }
.btn-advance .adv-hint { font-size: 0.6rem; opacity: 0.7; font-family: -apple-system, sans-serif; }

.btn-sm {
    background: none; border: 1px solid var(--border-warm); color: var(--ember);
    padding: 0.4rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 600; cursor: pointer;
    font-family: -apple-system, sans-serif; white-space: nowrap;
    transition: all var(--transition);
}
.btn-sm:hover { background: var(--ember); color: var(--bg); border-color: var(--ember); }
.btn-sm:disabled { opacity: 0.2; cursor: not-allowed; }

/* === Modals === */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 15, 12, 0.8);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 1.5rem; max-width: 480px; width: 90%;
    max-height: 85vh; overflow-y: auto;
    border: 1px solid var(--border-warm);
    box-shadow: var(--shadow-deep), 0 0 40px rgba(196,122,90,0.05);
    font-family: -apple-system, system-ui, sans-serif;
}
.modal h3 { font-size: 1.05rem; margin-bottom: 0.75rem; font-family: Georgia, serif; color: var(--text); }
.modal-close {
    width: 100%; padding: 0.5rem; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-dim); font-size: 0.85rem;
    cursor: pointer; font-family: inherit; margin-top: 0.75rem;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-surface); border-color: var(--border-warm); color: var(--text); }

/* Yarn modal */
.yarn-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.yarn-row:last-child { border-bottom: none; }
.yarn-color-pick {
    width: 40px; height: 40px; border: none; padding: 0;
    cursor: pointer; border-radius: 8px; background: none;
}
.yarn-input {
    flex: 1; padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.9rem;
    font-family: inherit; background: var(--bg-elevated);
    color: var(--text); transition: border-color var(--transition);
}
.yarn-input:focus { outline: none; border-color: var(--ember); }
.yarn-role-label { font-size: 0.7rem; color: var(--text-muted); }
.btn-primary {
    width: 100%; padding: 0.6rem;
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: #fdf6f0; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: inherit; margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(196,122,90,0.2);
    transition: all var(--transition);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(196,122,90,0.3); }

/* Settings */
.setting {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0; font-size: 0.88rem; color: var(--text);
}
.setting input[type="checkbox"] { accent-color: var(--ember); width: 18px; height: 18px; }
.setting input[type="range"] { flex: 1; accent-color: var(--ember); }

/* === Safe Areas === */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header { padding-top: calc(0.6rem + env(safe-area-inset-top)); }
    .bottom-bar { padding-bottom: calc(0.6rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 700px) {
    .app-header .logo { font-size: 0.95rem; }
    .bottom-bar { padding: 0.5rem 0.75rem; }
}


/* === RESEARCH-BACKED ADDITIONS (Session 5) === */

/* Progress strip — measurement + percentage + history */
.progress-strip {
    padding: 0.35rem 1rem 0.4rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-family: -apple-system, system-ui, sans-serif;
}
.progress-strip-bar {
    height: 3px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}
.progress-strip-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ember-deep), var(--ember-glow));
    border-radius: 2px;
    transition: width 0.4s ease;
    box-shadow: 0 0 6px rgba(196,122,90,0.3);
}
.progress-strip-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.row-measurement {
    font-size: 0.72rem;
    color: var(--text-dim);
}
.progress-pct {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ember-glow);
}
.advance-history {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.2rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    overflow: hidden;
}
.advance-history span {
    white-space: nowrap;
}

/* Technique terms — tappable inline */
.technique-term {
    display: inline;
    color: var(--ember-glow);
    border-bottom: 1px dotted var(--ember);
    cursor: pointer;
    transition: all var(--transition);
}
.technique-term:hover, .technique-term:active {
    color: var(--ember);
    background: var(--ember-soft);
    border-radius: 3px;
    padding: 0 2px;
}

/* Technique tooltip */
.technique-tooltip {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-warm);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    max-width: 320px;
    width: 90%;
    z-index: 50;
    box-shadow: var(--shadow-glow);
    font-family: -apple-system, system-ui, sans-serif;
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.5;
    animation: fadeUp 0.2s ease;
}
.technique-tooltip .tt-title {
    font-weight: 700;
    color: var(--ember-glow);
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}
.technique-tooltip .tt-close {
    position: absolute;
    top: 0.4rem;
    right: 0.6rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Cat warning animation */
.cat-warning {
    animation: fadeUp 0.2s ease;
}


/* === SECTION NAVIGATION (separate from row advancement) === */
.section-header-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-header-center {
    flex: 1;
    text-align: center;
}
.section-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-warm);
    background: var(--bg-elevated);
    color: var(--ember-glow);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.section-nav-btn:hover:not(:disabled) {
    background: var(--ember);
    color: var(--bg);
    border-color: var(--ember);
}
.section-nav-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}


/* Knit view content wrapper (so bottom bar isn't destroyed by innerHTML) */
#view-knit-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}


/* === Horizontal divider (chart vs instructions) === */
.h-divider {
    height: 6px;
    cursor: row-resize;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: none;
    transition: background var(--transition);
}
.h-divider:hover, .h-divider:active, .h-divider.dragging {
    background: var(--ember);
}
.h-divider::after {
    content: '';
    width: 30px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 1px;
    opacity: 0.5;
}

/* === Fit to screen button === */
.fit-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-warm);
    background: var(--bg-elevated);
    color: var(--ember-glow);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.fit-btn:hover, .fit-btn:active {
    background: var(--ember);
    color: var(--bg);
}
.chart-container {
    position: relative;
}

/* === Help overlay === */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 12, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeUp 0.2s ease;
}
.help-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-warm);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-deep);
    font-family: -apple-system, system-ui, sans-serif;
}
.help-modal h3 {
    font-family: Georgia, serif;
    color: var(--text);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.help-section {
    margin-bottom: 1rem;
}
.help-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--ember);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}
.help-item {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.82rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.help-item:last-child { border-bottom: none; }
.help-key {
    font-weight: 600;
    color: var(--text);
}
.help-close {
    width: 100%;
    padding: 0.6rem;
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: #fdf6f0;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.75rem;
}


/* === Cuts panel toggle (when closed) === */
.cuts-closed-toggle {
    writing-mode: vertical-rl;
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ember-glow);
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    font-family: -apple-system, system-ui, sans-serif;
    transition: background var(--transition);
}
.cuts-closed-toggle:hover, .cuts-closed-toggle:active {
    background: var(--ember-soft);
}
.cuts-panel-header {
    cursor: pointer;
}


/* Row strip wrapper — keeps fit button persistent alongside row info */
.row-strip-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-left: 0.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.row-strip-wrapper .row-strip {
    border-bottom: none;
    flex: 1;
}


/* === Row Advance Strip (integrated advance control) === */
.row-advance-strip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.row-strip-center {
    flex: 1;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: #fdf6f0;
    transition: all var(--transition);
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.row-strip-center:active {
    transform: scale(0.97);
    opacity: 0.9;
}
.row-strip-main {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: -apple-system, system-ui, sans-serif;
}
.row-strip-main .row-num {
    color: #fdf6f0;
    font-size: 1rem;
    font-weight: 700;
}
.row-strip-main .row-side {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: rgba(255,255,255,0.15);
    color: #fdf6f0;
}
.row-strip-main .seg {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.2);
    color: #fdf6f0;
}
.row-strip-main .seg-dot {
    box-shadow: 0 0 4px rgba(255,255,255,0.3);
}
.row-strip-main .row-total {
    color: rgba(255,255,255,0.7);
}
.row-strip-hint {
    font-size: 0.6rem;
    opacity: 0.6;
    text-align: center;
    font-family: -apple-system, system-ui, sans-serif;
    margin-top: 0.15rem;
}
.row-strip-prev {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    opacity: 0.5;
    margin-top: 3px;
}
.row-strip-prev-seg {
    height: 100%;
}
.strip-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-warm);
    background: var(--bg-elevated);
    color: var(--ember-glow);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.strip-btn:active:not(:disabled) {
    background: var(--ember);
    color: var(--bg);
}
.strip-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}
.strip-btn.active {
    background: var(--ember);
    color: var(--bg);
    border-color: var(--ember);
}


/* Cuts panel collapse (smooth, no layout jump) */
.cuts-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden;
}


/* Active strand highlight in cuts list */
.strand-highlight.active-strand {
    background: var(--ember-soft);
    border-radius: 4px;
    padding: 0.25rem 0.3rem;
    color: var(--text);
}

/* === Cuts View Tabs === */
.cuts-view-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 0.5rem;
    background: var(--bg);
    border-radius: 6px;
    padding: 2px;
}
.cuts-tab {
    flex: 1;
    padding: 0.3rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: -apple-system, system-ui, sans-serif;
}
.cuts-tab.active {
    background: var(--bg-elevated);
    color: var(--ember-glow);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cuts-tab:not(.active):hover {
    color: var(--text-dim);
}

/* Cuts section labels */
.cuts-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.2rem;
}

/* Strand status styles */
.cuts-active {
    background: rgba(196, 122, 90, 0.08);
    border-left: 2px solid var(--ember);
    padding-left: 0.4rem;
    border-radius: 0 4px 4px 0;
}
.cuts-upcoming {
    opacity: 0.75;
    border-left: 2px solid var(--gold);
    padding-left: 0.4rem;
    border-radius: 0 4px 4px 0;
}
.cuts-done {
    opacity: 0.4;
    font-size: 0.7rem;
}
.cuts-status-icon {
    font-size: 0.6rem;
    margin-right: 3px;
    vertical-align: middle;
}
.cuts-progress {
    font-size: 0.6rem;
    color: var(--ember-glow);
    font-weight: 600;
    margin-left: 4px;
}
.cuts-main-tag {
    color: var(--ember);
    font-size: 0.65rem;
    font-weight: 700;
}
.cuts-yards {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.cuts-estimate {
    color: var(--text-dim);
    font-size: 0.65rem;
    font-style: italic;
}
.cuts-yards-toggle {
    cursor: pointer;
    border-bottom: 1px dotted var(--text-dim);
    padding-bottom: 1px;
}
.cuts-border-tag {
    font-size: 0.6rem;
    color: var(--gold);
    font-weight: 600;
    margin-left: 4px;
}
.cuts-done-summary {
    font-size: 0.7rem;
    color: var(--sage);
    padding: 0.4rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    opacity: 0.7;
}
.cuts-dup {
    opacity: 0.75;
    font-size: 0.7rem;
    border-left: 2px dashed var(--text-muted);
    padding-left: 8px;
    font-style: italic;
    background: rgba(255, 255, 255, 0.03);
}
.cuts-empty {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.3rem 0;
}

/* === Row Focus Panel === */
.row-focus {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.row-focus-hero {
    padding: 0.8rem;
    background: var(--bg-surface);
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 1px solid var(--border);
}
.row-focus-hero:active {
    background: var(--bg-elevated);
}
.row-focus-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}
.row-focus-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}
.row-focus-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ember-glow);
    font-family: -apple-system, system-ui, sans-serif;
}
.row-focus-side {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}
.row-focus-side.rs { background: rgba(90, 138, 111, 0.2); color: var(--sage); }
.row-focus-side.ws { background: rgba(184, 150, 90, 0.15); color: var(--gold); }
.row-focus-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* The hero: color segments showing the actual row */
.row-focus-segments {
    display: flex;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.row-focus-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2px;
    position: relative;
    transition: all 0.2s ease;
}
.row-focus-seg-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.row-focus-seg:hover {
    filter: brightness(1.15);
}
.row-focus-prev {
    display: flex;
    height: 8px;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
    opacity: 0.5;
    margin-top: 1px;
}
.row-focus-prev-seg {
    height: 100%;
}
.row-focus-direction {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    font-family: -apple-system, system-ui, sans-serif;
}
.row-focus-tap-hint {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-top: 0.2rem;
}

/* === Strand Timeline (Gantt chart) === */
.strand-timeline {
    padding: 0.5rem 0.6rem;
    background: var(--bg);
}
.strand-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.strand-timeline-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.strand-timeline-body {
    position: relative;
}
.strand-timeline-row {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    margin-bottom: 2px;
    cursor: pointer;
    border-radius: 3px;
    padding: 0 2px;
    transition: background var(--transition);
}
.strand-timeline-row:hover {
    background: var(--bg-elevated);
}
.strand-timeline-row.st-done {
    opacity: 0.35;
}
.strand-timeline-row.st-future {
    opacity: 0.6;
}
.strand-timeline-row.st-active {
    background: rgba(196, 122, 90, 0.06);
}
.st-label {
    width: 32px;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}
.st-track {
    flex: 1;
    height: 12px;
    background: var(--bg-elevated);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.st-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 3px;
    opacity: 0.85;
    transition: all 0.3s ease;
}
.strand-timeline-row.st-active .st-bar {
    opacity: 1;
    box-shadow: 0 0 4px rgba(255,255,255,0.2);
}
.st-info {
    width: 28px;
    font-size: 0.58rem;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
}

/* Strand lifecycle current-row marker */
.st-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--ember);
    opacity: 0.6;
    pointer-events: none;
}

/* Strand intro/retire row highlights */
.strand-timeline-row.st-intro {
    background: rgba(140, 175, 60, 0.1);
    border-left: 2px solid rgba(140, 175, 60, 0.6);
}
.strand-timeline-row.st-retire {
    background: rgba(196, 122, 90, 0.08);
    border-left: 2px solid rgba(196, 122, 90, 0.5);
}

/* === Strand Lifecycle Notifications === */
.strand-lifecycle {
    padding: 0.4rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.lifecycle-event {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    line-height: 1.4;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
}
.lifecycle-intro {
    background: rgba(140, 175, 60, 0.08);
    border: 1px solid rgba(140, 175, 60, 0.25);
    color: var(--text);
}
.lifecycle-retire {
    background: rgba(196, 122, 90, 0.06);
    border: 1px solid rgba(196, 122, 90, 0.2);
    color: var(--text-dim);
}
.lifecycle-icon {
    font-size: 0.8rem;
    flex-shrink: 0;
    width: 1.2em;
    text-align: center;
}
.lifecycle-text {
    flex: 1;
}
.lifecycle-strand {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    border-left: 3px solid;
    background: var(--bg-elevated);
    font-size: 0.68rem;
    margin: 0 0.15rem;
    white-space: nowrap;
}
.strand-active-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-left: auto;
}

/* Strand introduction marker in row segments */
.seg-intro {
    position: relative;
    outline: 1.5px solid rgba(255, 255, 255, 0.7);
    outline-offset: -1px;
}
.seg-intro-mark {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.55rem;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* === Panel Layout System (Long-press drag, stacked + side-by-side) === */

.panels-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Scrollable variant for Plan/Project views */
.panels-container-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem;
    gap: 0.75rem;
}

.panel-row {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex-shrink: 0;
}

/* Chart panel row should expand to fill available space */
.panel-row-flex {
    flex: 1;
    flex-shrink: 1;
    overflow: hidden;
}

.panel-row-flex > .panel {
    flex: 1;
    overflow: hidden;
}

.panel-row.side-by-side {
    flex-direction: row;
}

.panel-row.side-by-side > .panel {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
}

.panel-row.side-by-side > .panel:last-child {
    border-right: none;
}

.panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
    min-height: 28px;
    touch-action: none;
}

.panel-header:active {
    cursor: grabbing;
    background: var(--bg-elevated);
}

.panel-header-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: -apple-system, system-ui, sans-serif;
}

.panel-header-label::before {
    content: '⋮⋮';
    margin-right: 0.4rem;
    color: var(--ember);
    opacity: 0.5;
    font-size: 0.7rem;
    letter-spacing: -1px;
}

.panel-collapse-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel-collapsed .panel-body {
    display: none;
}

.panel-collapsed .panel-header {
    border-bottom: none;
    background: var(--bg-card);
}

.panel-collapsed .panel-header-label {
    color: var(--text-dim);
}

/* --- Long-press drag states --- */

.panel-lifting {
    opacity: 0.92;
    transform: scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--ember);
    border-radius: var(--radius);
    background: var(--bg-card);
    z-index: 1000;
    pointer-events: none;
}

.layout-editing .panel.layout-edit-panel {
    border: 1px dashed var(--border-warm);
    border-radius: var(--radius-sm);
    margin: 2px;
}

/* Drop zones */
.drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-warm);
    border-radius: var(--radius-sm);
    background: rgba(196, 122, 90, 0.04);
    transition: all 0.15s ease;
    opacity: 0.6;
    overflow: hidden;
}

.drop-zone-row {
    height: 32px;
    margin: 4px 0;
}

.drop-zone-beside {
    min-width: 60px;
    width: 60px;
    align-self: stretch;
    flex-shrink: 0;
    margin: 0 4px;
}

.drop-zone-active {
    opacity: 1;
    border-color: var(--ember);
    background: rgba(196, 122, 90, 0.12);
    box-shadow: 0 0 12px rgba(196, 122, 90, 0.2);
}

.drop-zone-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ember-glow);
    font-family: -apple-system, system-ui, sans-serif;
    white-space: nowrap;
    padding: 0 0.5rem;
}

.panel-drop-placeholder {
    border: 2px dashed var(--ember-glow);
    border-radius: var(--radius-sm);
    background: rgba(196, 122, 90, 0.06);
    transition: height 0.15s ease;
    margin: 4px 0;
}

/* First-time hint animation (subtle breathing glow on panel headers) */
@keyframes panelHint {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 0 1px rgba(196, 122, 90, 0.15); }
}

.panel.hint-movable {
    animation: panelHint 2s ease-in-out 1;
}

/* Smooth panel row transitions */
.panel-row {
    transition: all 0.2s ease;
}

/* === Tips === */
.tips-fab {
    background: var(--bg-elevated);
    border: 1px solid var(--border-warm);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    margin-left: 0.25rem;
}
.tips-fab:hover {
    background: var(--ember-soft);
    border-color: var(--ember);
}
.section-header {
    position: relative;
}
.tips-modal {
    max-width: 420px;
    max-height: 70vh;
    overflow-y: auto;
}
.tips-body {
    margin: 0.75rem 0;
}
.tips-group {
    margin-bottom: 0.75rem;
}
.tips-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--ember-glow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border);
}
.tips-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.tips-item:last-child {
    border-bottom: none;
}
.tips-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
}
.tips-text {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.4;
}
