/* ──────────────────────────────────────────────────────────────────
   V1-specific shell: dark icon rail + clean topbar.
   Layered on top of styles/shell.css and styles/prototype.css.
   ────────────────────────────────────────────────────────────────── */

#app-v1 {
    height: 100vh;
    display: grid;
    grid-template-columns: 64px 1fr;
    grid-template-rows: 56px 1fr;
    background: var(--bg-app);
    color: var(--ink-1);
}

/* ── Icon rail ─────────────────────────────────────────────────── */
.rail {
    grid-row: 1 / -1;
    background: #0E1620;
    color: var(--ink-on-rail-1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 4px;
    /* The hover tooltips (.tt) and user-menu flyout overflow the rail into the
       content column, but they're trapped inside this stacking context. Page
       chrome stacks higher than nav would normally sit — .filter-bar is z-60
       (+ backdrop-filter context), its date popover z-80 — so at the old z-40
       those elements painted over the tooltip. Lift the whole rail above all
       page content (max z-80) while staying below modal overlays (z-100+). */
    z-index: 90;
    position: relative;
}
.theme-dark .rail { background: #07101A; }

.rail .brand-mark {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,178,227,0.25);
}
.rail .brand-mark img { width: 30px; height: 30px; display: block; }
.rail .rail-divider {
    width: 28px; height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 6px 0;
}
.rail .rail-item {
    width: 44px; height: 44px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    color: #8A99AB;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s;
}
.rail .rail-item:hover { background: rgba(255,255,255,0.04); color: #E6ECF2; }
.rail .rail-item.active {
    background: rgba(0,178,227,0.16);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--brand);
}
.rail .rail-item svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.rail .rail-item .badge {
    position: absolute;
    top: 6px; right: 4px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #0E1620;
    box-sizing: content-box;
}
.theme-dark .rail .rail-item .badge { border-color: #07101A; }
.rail .rail-item .tt {
    position: absolute; left: 100%; margin-left: 14px;
    background: var(--ink-1); color: #fff;
    font-size: 12px; font-weight: 500;
    padding: 5px 10px; border-radius: 6px;
    white-space: nowrap;
    opacity: 0; pointer-events: none;
    transform: translateX(-6px);
    transition: opacity .15s, transform .15s;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.20);
}
.theme-dark .rail .rail-item .tt { background: #E6ECF2; color: #0E1620; }
.rail .rail-item .tt::before {
    content: "";
    position: absolute;
    right: 100%; top: 50%; transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--ink-1);
}
.theme-dark .rail .rail-item .tt::before { border-right-color: #E6ECF2; }
.rail .rail-item:hover .tt { opacity: 1; transform: translateX(0); }

.rail .add-tool {
    color: #5C6B7C;
    border: 1px dashed rgba(255,255,255,0.12);
}
.rail .add-tool:hover { color: #E6ECF2; border-color: rgba(255,255,255,0.20); }
.rail .rail-spacer { flex: 1; }
.rail .rail-avatar {
    --pct: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7C5BD9, #5638A8);
    color: #fff;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    margin-top: 4px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    /* Reset the default <button> border — its 3D bevel (light top-left, dark
       bottom-right) was rendering as a grey segment that made the ring look
       like it didn't fully circle. */
    border: none;
    -webkit-appearance: none;
            appearance: none;
}
/* Workday ring — a black ring fills clockwise around the photo as the day goes:
   nothing at 9:00 AM ET, a complete black ring by 5:00 PM ET. --pct (0–100) is
   set each minute in app.js. The filled portion is black; the rest is
   transparent (nothing) — there is no resting ring at the start of the day. The
   band is masked to a 2px stroke hugging the photo (photo edge → +2px). */
.rail .rail-avatar::before {
    content: "";
    position: absolute; inset: -2px;
    border-radius: 50%;
    background: conic-gradient(#000 calc(var(--pct) * 1%), transparent 0);
    -webkit-mask: radial-gradient(closest-side,
                  transparent calc(100% - 2px), #000 calc(100% - 2px));
            mask: radial-gradient(closest-side,
                  transparent calc(100% - 2px), #000 calc(100% - 2px));
    pointer-events: none;
}
.rail .rail-avatar::after {
    content: "";
    position: absolute;
    bottom: -1px; right: -1px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--ok);
    border: 2px solid #0E1620;
}
.theme-dark .rail .rail-avatar::after { border-color: #07101A; }

/* ── Top bar (V1: clean white/dark, breadcrumb-led) ───────── */
.v1-topbar {
    grid-column: 2;
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--hairline);
    padding: 0 24px;
    display: flex; align-items: center; gap: 16px;
    position: relative;
    z-index: 20;
}
.v1-topbar .crumbs {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
    flex: 1;
    min-width: 0;
}
.v1-topbar .crumbs .root {
    color: var(--ink-3);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    font-weight: 700;
    cursor: pointer;
}
.v1-topbar .crumbs .root:hover { color: var(--ink-2); }
.v1-topbar .crumbs .sep {
    color: var(--ink-3);
}
.v1-topbar .crumbs .here {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -0.01em;
    display: inline-flex; align-items: center; gap: 8px;
}
.v1-topbar .crumbs .tool-dot {
    width: 8px; height: 8px;
    border-radius: 2px;
}

.v1-topbar .search-pill {
    width: 320px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-sunken);
    border: 1px solid var(--hairline);
    display: flex; align-items: center; gap: 10px;
    padding: 0 12px;
    color: var(--ink-3);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    transition: border-color .15s, background .15s;
}
.v1-topbar .search-pill:hover { border-color: var(--brand-line); color: var(--ink-2); }
.v1-topbar .search-pill .kbd {
    margin-left: auto;
    font-size: 10px;
    background: var(--bg-canvas);
    border: 1px solid var(--hairline);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--ink-2);
    font-weight: 500;
}
.v1-topbar .util-row {
    display: flex; align-items: center; gap: 4px;
}
.v1-topbar .icon-btn {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-2);
}
.v1-topbar .icon-btn:hover { background: var(--bg-sunken); color: var(--ink-1); }

/* ── Main content area ────────────────────────────────────── */
.v1-main {
    grid-column: 2; grid-row: 2;
    overflow-y: auto;
    background: var(--bg-app);
    min-width: 0;
}

/* ── Tab-row supports section-grouping for tools with many sub-pages ── */
.tab-row .tab-group {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    position: relative;
}
.tab-row .tab-group + .tab-group {
    margin-left: 24px;
    padding-left: 24px;
    border-left: 1px solid var(--hairline);
    height: 32px;
    align-self: flex-end;
}
.tab-row .tab-group-label {
    display: none;
    position: absolute;
    top: -16px;
    left: 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--ink-3);
    font-weight: 700;
    white-space: nowrap;
}
.tab-row.show-section-labels {
    padding-top: 18px;
}
.tab-row.show-section-labels .tab-group-label { display: block; }
.tab-row.show-section-labels .tab-group + .tab-group .tab-group-label { left: 24px; }

/* ── Add-tool modal (when "+" on rail clicked) ───────────── */
.add-tool-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(11, 18, 27, 0.55);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.add-tool-modal {
    width: 540px;
    background: var(--bg-canvas);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    overflow: hidden;
}
.add-tool-modal .am-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--hairline);
}
.add-tool-modal .am-title {
    font-size: 16px; font-weight: 600; color: var(--ink-1);
}
.add-tool-modal .am-sub {
    font-size: 12px; color: var(--ink-3); margin-top: 4px;
}
.add-tool-modal .am-body { padding: 10px; }
.add-tool-modal .am-tool {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 12px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    margin: 6px 0;
    cursor: pointer;
    background: var(--bg-canvas);
    transition: border-color .12s, background .12s;
}
.add-tool-modal .am-tool:hover {
    border-color: var(--brand-line);
    background: var(--brand-soft);
}
.add-tool-modal .am-tool.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.add-tool-modal .am-tool-ic {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.add-tool-modal .am-tool-ic svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }
.add-tool-modal .am-tool-meta { flex: 1; }
.add-tool-modal .am-tool-name { font-size: 14px; font-weight: 600; color: var(--ink-1); }
.add-tool-modal .am-tool-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.add-tool-modal .am-tool-cta {
    font-size: 11px; font-weight: 600;
    color: var(--brand-deep);
    padding: 6px 10px;
    background: var(--brand-soft);
    border-radius: 6px;
}
.theme-dark .add-tool-modal .am-tool-cta { color: var(--brand); }
.add-tool-modal .am-foot {
    padding: 12px 22px;
    border-top: 1px solid var(--hairline);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* User menu dropdown from the rail avatar */
.user-menu {
    position: fixed;
    bottom: 16px;
    left: 80px;
    width: 260px;
    background: var(--bg-canvas);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    box-shadow: var(--shadow-lift);
    padding: 8px;
    z-index: 60;
    animation: flyout-in .15s ease;
}
.user-menu .um-head {
    padding: 10px 12px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 4px;
}
.user-menu .um-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7C5BD9, #5638A8);
    color: #fff;
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.user-menu .um-meta { display: flex; flex-direction: column; }
.user-menu .um-name { font-size: 13px; font-weight: 600; color: var(--ink-1); }
.user-menu .um-email { font-size: 11px; color: var(--ink-3); }
.user-menu .um-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--ink-2);
    border-radius: 8px;
    cursor: pointer;
    background: none; border: none;
    width: 100%;
    text-align: left;
    font: inherit;
}
.user-menu .um-item:hover { background: var(--bg-sunken); color: var(--ink-1); }
.user-menu .um-item svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.user-menu .um-sep { height: 1px; background: var(--hairline); margin: 4px 0; }
