﻿/* Desktop navigation. Scoped to the desktop shell so device previews stay independent. */
@media (min-width:1024px) {
  :root .app-shell[data-preview="desktop"]:not(.phone-preview):not(.app-preview) {
    --sidebar-width:252px;
    width:100%;max-width:100%;min-width:0;
  }
  :root .app-shell[data-preview="desktop"]:not(.phone-preview):not(.app-preview) .main-wrapper {
    margin-left:var(--sidebar-width);width:calc(100% - var(--sidebar-width));
    max-width:calc(100% - var(--sidebar-width));min-width:0;
  }
  :root .app-shell[data-preview="desktop"]:not(.phone-preview):not(.app-preview) .sidebar {
    --ink:#23385b;--muted:#65748d;--accent:#0069fb;--accent-hover:#0054d5;
    --accent-soft:#eaf2ff;--accent-border:#cddffd;
    --paper:#fff;--surface:#f4f6fb;--line:#e5eaf3;
    --studio:#f3f2fc;--studio-line:#e5e1f5;--studio-ink:#53458b;
    --control:#e9e7f5;--control-selected:#fff;
    --nav-tint:#e9f1ff;--nav-color:#2167cc;
    position:fixed;inset:0 auto 0 0;width:var(--sidebar-width,252px);height:100dvh;
    display:flex;flex-direction:column;gap:0;padding:28px 18px 16px;
    overflow:hidden;isolation:isolate;
    background:var(--paper)!important;color:var(--ink)!important;
    border-right:1px solid var(--line)!important;box-shadow:4px 0 24px #19365c04;
  }
  :root .app-shell .sidebar-content {
    flex:1;display:flex;flex-direction:column;min-height:0;
    overflow:auto;overflow-x:hidden;padding:0 2px 14px;
    scrollbar-width:thin;scrollbar-color:var(--accent-border) transparent;
    overscroll-behavior:contain;
  }
  :root .app-shell .sidebar .brand {
    display:flex;flex-shrink:0;align-items:center;justify-content:flex-start;
    min-height:30px;margin:0 8px;padding:0;border:0;
  }
  :root .app-shell .sidebar .brand-image {
    display:block;width:100%;max-width:191px;height:auto;max-height:34px;
    object-fit:contain;filter:none;
  }
  :root .app-shell .sidebar .sidebar-brand-caption {
    margin:9px 8px 25px;color:var(--muted)!important;
    font-size:11px;line-height:1.5;letter-spacing:.05px;
  }
  :root .app-shell .sidebar .sidebar-book-actions {flex-shrink:0;margin:28px 0 27px}
  :root .app-shell .sidebar .sidebar-book-actions:empty {display:none}
  :root .app-shell .sidebar #addBookButton {
    display:flex;justify-content:center;align-items:center;gap:9px;
    width:100%;min-height:46px;padding:12px 16px;border-radius:13px;
    background:var(--accent)!important;border:1px solid var(--accent)!important;
    color:#fff!important;font-size:13px;font-weight:700;letter-spacing:.1px;
    box-shadow:0 5px 12px #0069fb20;
    transition:background .18s,box-shadow .18s,transform .18s;
  }
  :root .app-shell .sidebar #addBookButton .icon {width:18px;height:18px;color:#fff}
  :root .app-shell .sidebar #addBookButton:hover {
    background:var(--accent-hover)!important;border-color:var(--accent-hover)!important;
    box-shadow:0 7px 16px #0069fb30;transform:translateY(-1px);
  }
  :root .app-shell .sidebar :is(.sidebar-section-heading,.workspace-label) {
    margin:0 10px 10px;padding:0;color:var(--muted)!important;
    font-size:9px;font-weight:700;line-height:1.4;letter-spacing:1.5px;
  }
  :root .app-shell .sidebar .primary-nav {display:flex;flex-direction:column;gap:6px;flex-shrink:0}
  :root .app-shell .sidebar .primary-nav .nav-item {
    display:flex;align-items:center;gap:10px;width:100%;min-height:49px;
    margin:0;padding:7px 10px;border:1px solid transparent;border-radius:13px;
    background:transparent;color:var(--ink);box-shadow:none;
    text-align:left;font-size:13px;font-weight:600;line-height:1.3;
    transition:background .18s,color .18s;
  }
  :root .app-shell .sidebar :is(.sidebar-nav-icon,.soc-nav-profile) {
    display:inline-flex;align-items:center;justify-content:center;
    position:relative;flex:0 0 32px;width:32px;height:32px;border-radius:10px;
    background:var(--surface)!important;color:var(--muted)!important;
    overflow:hidden;
  }
  :root .app-shell .sidebar .primary-nav [data-tab="books"] {--nav-tint:#eee8fc;--nav-color:#7954c3}
  :root .app-shell .sidebar .primary-nav [data-tab="discover"] {--nav-tint:#def5f0;--nav-color:#137e73}
  :root .app-shell .sidebar .primary-nav [data-tab="social"] {--nav-tint:#fff0db;--nav-color:#a96410}
  :root .app-shell .sidebar .primary-nav .icon {width:18px;height:18px;color:inherit}
  :root .app-shell .sidebar .primary-nav .nav-item:hover {background:var(--surface)}
  :root .app-shell .sidebar .primary-nav .nav-item.active {
    background:var(--accent-soft)!important;color:var(--accent)!important;
    border-color:var(--accent-border);box-shadow:none;
  }
  :root .app-shell .sidebar .primary-nav .nav-item.active :is(.sidebar-nav-icon,.soc-nav-profile) {
    color:var(--accent)!important;background:var(--paper)!important;
  }
  :root .app-shell .sidebar .nav-count {
    margin-left:auto;padding:4px 7px;min-width:24px;border-radius:7px;
    background:var(--accent-soft)!important;color:var(--accent)!important;
    text-align:center;font-size:10px;font-weight:700;font-variant-numeric:tabular-nums;
  }
  :root .app-shell .sidebar .primary-nav .active .nav-count {background:var(--paper)!important;color:var(--accent)!important}
  :root .app-shell .sidebar .soc-nav-counts {display:flex;flex-wrap:wrap;justify-content:flex-end;gap:2px;margin-left:auto;max-width:64px}
  :root .app-shell .sidebar .soc-nav-counts:empty {display:none}
  :root .app-shell .sidebar .soc-count {font-size:9px;padding:3px 4px;min-width:18px}
  :root .app-shell .sidebar .soc-nav-counts .icon {width:9px;height:9px}
  :root .app-shell .sidebar .sidebar-studio {
    flex-shrink:0;margin:25px 0 0;padding:15px 12px 12px;
    border:1px solid var(--studio-line);border-radius:18px;
    background:var(--studio);
  }
  :root .app-shell .sidebar .sidebar-studio-heading {display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:18px}
  :root .app-shell .sidebar .workspace-label {margin:0 0 5px;font-size:8px;letter-spacing:1.25px;color:var(--studio-ink)!important}
  :root .app-shell .sidebar .sidebar-studio h2 {margin:0;color:var(--ink);font:650 18px/1.3 var(--sans);letter-spacing:-.5px}
  :root .app-shell .sidebar .sidebar-studio-icon {width:22px;height:22px;color:var(--studio-ink)}
  :root .app-shell .sidebar .sidebar-control-label {margin:0 0 7px;padding:0 1px;color:var(--studio-ink);font-size:11px;font-weight:600}
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) {
    display:flex;gap:4px;margin:0 0 14px;padding:4px;border:0;
    border-radius:10px;background:var(--control);
  }
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) button {
    display:flex;flex:1;align-items:center;justify-content:center;gap:6px;
    min-width:0;min-height:35px;padding:7px 3px;border:1px solid transparent;border-radius:7px;
    background:transparent;color:var(--studio-ink);box-shadow:none;
    font-size:11px;font-weight:550;line-height:1.3;
    transition:background .18s,color .18s,box-shadow .18s;
  }
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) button::before {content:none}
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) .icon {width:15px;height:15px;color:inherit}
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) button:hover {background:var(--studio);color:var(--ink)}
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight,.sidebar-room-view) button:is(.selected,[aria-pressed="true"]) {
    background:var(--control-selected);color:var(--studio-ink);
    border-color:var(--studio-line);box-shadow:0 2px 4px #2b26550a;font-weight:700;
  }
  :root .app-shell .sidebar .sidebar-room-daylight button[data-time-of-day="day"][aria-pressed="true"] {color:#8a5800;background:#fff7df;border-color:#f3e2b9}
  :root .app-shell .sidebar .sidebar-room-daylight button[data-time-of-day="night"][aria-pressed="true"] {color:#fff;background:#57508f;border-color:#57508f}
  :root .app-shell .sidebar .sidebar-room-view {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));background:transparent;padding:0;gap:6px;margin-bottom:12px}
  :root .app-shell .sidebar .sidebar-room-view button {min-height:37px;flex-direction:row;justify-content:flex-start;padding:8px 10px;background:var(--control);border-radius:9px}
  :root .app-shell .sidebar .sidebar-room-view button[aria-pressed="true"] {border-color:var(--studio-ink);background:var(--control-selected);box-shadow:0 0 0 1px var(--studio-ink)}
  :root .app-shell .sidebar #sidebarDecor {
    display:flex;align-items:center;justify-content:flex-start;gap:7px;min-height:40px;
    padding:9px 10px;border:1px solid var(--studio-line);border-radius:10px;
    color:var(--studio-ink);background:var(--control-selected);font-size:11px;font-weight:700;box-shadow:none;
  }
  :root .app-shell .sidebar #sidebarDecor:hover {background:var(--control)}
  :root .app-shell .sidebar #sidebarDecor .icon {width:16px;height:16px}
  :root .app-shell .sidebar .sidebar-design-arrow {margin-left:auto;font-size:17px;font-weight:400}
  :root .app-shell .sidebar .sidebar-preview-controls {display:none}
  :root .app-shell .sidebar .profile {
    display:flex;flex-shrink:0;align-items:center;gap:10px;width:100%;min-height:66px;
    margin:0;padding:12px;border:1px solid var(--line);border-radius:14px;
    color:var(--ink);background:var(--surface);box-shadow:none;text-align:left;
    transition:background .18s,border-color .18s;
  }
  :root .app-shell .sidebar .profile:is(:hover,.active) {background:var(--accent-soft);border-color:var(--accent-border)}
  :root .app-shell .sidebar .profile .avatar {
    flex-shrink:0;width:36px;height:36px;border:1px solid #dcd6f4;border-radius:12px;
    color:#6850ab;background:#eae4fa;font:700 15px var(--sans);
  }
  :root .app-shell .sidebar .profile>span:nth-child(2) {flex:1;min-width:0}
  :root .app-shell .sidebar .profile strong {display:block;color:var(--ink);font-size:11px;font-weight:700;letter-spacing:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  :root .app-shell .sidebar .profile small {display:block;margin-top:4px;color:var(--muted);font-size:10px;letter-spacing:0}
  :root .app-shell .sidebar .profile>.icon {width:15px;color:var(--muted);margin-left:auto}
  :root .app-shell .sidebar :is(button,a):focus-visible {outline:3px solid var(--accent)!important;outline-offset:3px}
  :root .app-shell .sidebar .primary-nav .active:focus-visible {outline-color:var(--ink)!important}
}

/* Flex children must shrink to the page, even when a room or catalog is wider. */
:root #appShell .main-wrapper {min-width:0}
:root #appShell:is(.phone-preview,.app-preview) .main-wrapper {
  margin-left:0;width:100%;max-width:100%;
}
@media (min-width:1024px) {
  :root #appShell[data-preview="desktop"]:not(.phone-preview):not(.app-preview) .mobile-nav {display:none}
}
@media (min-width:1024px) and (max-width:1100px) {
  :root .app-shell[data-preview="desktop"]:not(.phone-preview):not(.app-preview) {--sidebar-width:232px}
  :root .app-shell .sidebar {padding-left:12px;padding-right:12px}
}
@media (min-width:1024px) and (max-height:900px) {
  :root .app-shell .sidebar {padding-top:18px;padding-bottom:12px}
  :root .app-shell .sidebar .sidebar-brand-caption {margin-bottom:17px}
  :root .app-shell .sidebar .sidebar-book-actions {margin-bottom:18px}
  :root .app-shell .sidebar .primary-nav {gap:3px}
  :root .app-shell .sidebar .primary-nav .nav-item {min-height:44px;padding-top:5px;padding-bottom:5px}
  :root .app-shell .sidebar .sidebar-studio {margin-top:18px;padding-top:12px}
  :root .app-shell .sidebar .sidebar-studio-heading {margin-bottom:12px}
  :root .app-shell .sidebar :is(.sidebar-room-style,.sidebar-room-daylight) {margin-bottom:10px}
  :root .app-shell .sidebar .profile {min-height:60px;padding:10px}
}
@media (min-width:1024px) and (max-height:800px) {
  :root .app-shell .sidebar .sidebar-brand-caption {margin-top:6px;margin-bottom:12px}
  :root .app-shell .sidebar .sidebar-book-actions {margin-bottom:14px}
  :root .app-shell .sidebar .sidebar-studio {margin-top:14px}
  :root .app-shell .sidebar .sidebar-studio .sidebar-control-label {display:none}
  :root .app-shell .sidebar .sidebar-room-view {grid-template-columns:repeat(4,minmax(0,1fr));gap:4px}
  :root .app-shell .sidebar .sidebar-room-view button {flex-direction:column;justify-content:center;gap:4px;min-height:46px;padding:6px 1px;font-size:9px}
}
@media (min-width:1024px) {
  :root[data-app-theme="dark"] .app-shell .sidebar {
    --ink:#e7eefc;--muted:#a2b0c8;--accent:#2879ed;--accent-hover:#1769dc;
    --accent-soft:#1b3152;--accent-border:#365478;
    --paper:#111c2d;--surface:#1a273b;--line:#2a384e;
    --studio:#211f38;--studio-line:#3c3558;--studio-ink:#c6b8f0;
    --control:#302b49;--control-selected:#443b61;
    --nav-tint:#203956;--nav-color:#8fc4ff;
    background:var(--paper)!important;
  }
  :root[data-app-theme="dark"] .app-shell .sidebar .brand-image {filter:invert(1) hue-rotate(180deg);mix-blend-mode:screen}
  :root[data-app-theme="dark"] .app-shell .sidebar .primary-nav [data-tab="books"] {--nav-tint:#35294e;--nav-color:#c6abff}
  :root[data-app-theme="dark"] .app-shell .sidebar .primary-nav [data-tab="discover"] {--nav-tint:#173d3c;--nav-color:#7ce1ce}
  :root[data-app-theme="dark"] .app-shell .sidebar .primary-nav [data-tab="social"] {--nav-tint:#42351f;--nav-color:#f5cb89}
  :root[data-app-theme="dark"] .app-shell .sidebar .nav-count {color:#9bc8ff!important}
  :root[data-app-theme="dark"] .app-shell .sidebar .profile .avatar {background:#392e54;color:#d4bfff;border-color:#51436e}
  :root[data-app-theme="dark"] .app-shell .sidebar .profile.active {box-shadow:inset 3px 0 var(--accent)}
}
/* Retain the app's tablet navigation and hide the rail in device previews. */
@media (min-width:761px) {
  :root .app-shell:is(.phone-preview,.app-preview,[data-preview="mobile"],[data-preview="app"]) .sidebar {display:none!important}
}
@media (min-width:761px) and (max-width:1023px) {
  :root .app-shell .sidebar {display:none!important}
  :root .app-shell:not(.phone-preview):not(.app-preview) .main-wrapper {margin-left:0!important;width:100%!important;max-width:100%!important}
  :root .app-shell:not(.phone-preview):not(.app-preview) main {padding-bottom:85px}
  :root .app-shell:not(.phone-preview):not(.app-preview) .mobile-nav {
    display:flex!important;position:fixed;inset:auto 0 0;z-index:30;
    justify-content:space-around;align-items:center;padding:10px 0 max(12px,env(safe-area-inset-bottom));
    border-top:1px solid #dce9f5;background:#f9fcffed;backdrop-filter:blur(12px);
  }
  :root .app-shell:not(.phone-preview):not(.app-preview) .mobile-nav button {display:flex;flex-direction:column;align-items:center;gap:5px;color:#6d8dab;font-size:10px;min-width:0;flex:1}
  :root .app-shell:not(.phone-preview):not(.app-preview) .mobile-nav button.active {color:#067fc6}
  :root .app-shell:not(.phone-preview):not(.app-preview) .mobile-nav .icon {width:20px;height:20px}
}
@media (prefers-reduced-motion:reduce) {
  :root .app-shell .sidebar :is(button,a) {transition:none!important}
}

/* Navigation follows the application palette in light and dark themes. */
:root #appShell :is(.primary-nav,.mobile-nav,.profile) {
  font-family:'Avenir Next','Aptos','Segoe UI',sans-serif;
  -webkit-font-smoothing:antialiased;
}
:root #appShell .mobile-nav {
  align-items:stretch;gap:6px;
  padding:10px 10px max(12px,env(safe-area-inset-bottom));
  background:var(--paper)!important;border-top:1px solid var(--accent-border);
  box-shadow:0 -6px 24px color-mix(in srgb,var(--brand-navy) 8%,transparent);
}
:root #appShell .mobile-nav button {
  position:relative;display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;
  gap:6px;min-width:0;min-height:58px;width:auto;margin:0;padding:8px 2px;
  border:1px solid transparent;border-radius:16px;background:transparent;
  color:var(--ink);font-size:11px;font-weight:750;line-height:1.2;letter-spacing:-.25px;
  transition:background .18s,color .18s,box-shadow .18s;
}
:root #appShell .mobile-nav button.active {
  background:linear-gradient(135deg,var(--brand-royal),var(--brand-cyan));color:#fff;
  border-color:color-mix(in srgb,var(--brand-cyan) 65%,white);
  box-shadow:0 4px 12px color-mix(in srgb,var(--brand-blue) 24%,transparent),inset 0 1px #ffffff40;
}
:root #appShell .mobile-nav .icon {width:24px;height:24px;stroke-width:2.2;color:inherit}
:root #appShell .mobile-nav button:not(.active)>.icon {color:var(--brand-blue)}
:root #appShell .mobile-nav .soc-nav-profile {
  display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;
  margin:0;border-radius:8px;background:var(--accent-soft);color:var(--ink);overflow:hidden;
}
:root #appShell .mobile-nav .soc-nav-counts {position:absolute;top:0;right:1px;display:flex;gap:2px;margin:0;max-width:100%}
:root #appShell .mobile-nav .soc-nav-counts:empty {display:none}
:root #appShell .mobile-nav .soc-count {font-size:8px;min-width:14px;padding:2px 3px}
:root #appShell .mobile-nav .soc-count .icon {width:8px;height:8px}
:root #appShell .mobile-nav button:focus-visible {outline:2px solid var(--accent)!important;outline-offset:2px}
@media (hover:hover) {
  :root #appShell .mobile-nav button:not(.active):hover {background:var(--accent-soft)}
}
@media (min-width:1024px) {
  :root #appShell .sidebar {
    --ink:inherit;--muted:inherit;--paper:inherit;--line:inherit;
    --accent:inherit;--accent-soft:inherit;--accent-border:inherit;
    --surface:var(--accent-soft);
    background:linear-gradient(165deg,var(--accent-soft),var(--paper) 48%)!important;
    border-right:1px solid var(--accent-border)!important;box-shadow:4px 0 24px #0069fb08;
  }
  :root #appShell .sidebar .brand-image {filter:none;mix-blend-mode:normal}
  :root #appShell .sidebar .sidebar-section-heading {font-size:10px;font-weight:750;letter-spacing:1.3px}
  :root #appShell .sidebar #addBookButton {
    background:linear-gradient(110deg,var(--brand-royal),var(--brand-cyan))!important;
    border-color:transparent!important;border-radius:15px;font-family:'Avenir Next','Aptos','Segoe UI',sans-serif;
    font-size:14px;font-weight:750;box-shadow:0 5px 16px #0069fb25;
  }
  :root #appShell .sidebar .primary-nav {gap:8px}
  :root #appShell .sidebar .primary-nav .nav-item {
    min-height:56px;padding:9px 11px;gap:12px;border-radius:16px;
    font-size:15px;font-weight:750;letter-spacing:-.4px;color:var(--ink);
  }
  :root #appShell .sidebar :is(.sidebar-nav-icon,.soc-nav-profile) {
    flex-basis:36px;width:36px;height:36px;border-radius:11px;
    color:var(--brand-blue)!important;background:var(--accent-soft)!important;
  }
  :root #appShell .sidebar .primary-nav .icon {width:23px;height:23px;stroke-width:2.2}
  :root #appShell .sidebar .primary-nav .nav-item.active {
    color:#fff!important;background:linear-gradient(110deg,var(--brand-royal),var(--brand-cyan))!important;
    border-color:transparent;box-shadow:0 5px 15px #0069fb25;
  }
  :root #appShell .sidebar .primary-nav .nav-item.active :is(.sidebar-nav-icon,.soc-nav-profile) {background:#ffffff24!important;color:#fff!important}
  :root #appShell .sidebar .primary-nav .active .nav-count {background:#ffffff24!important;color:#fff!important}
  :root #appShell .sidebar .profile {background:var(--accent-soft);border-color:var(--accent-border);border-radius:16px}
  :root #appShell .sidebar .profile strong {font-size:13px;font-weight:750;letter-spacing:-.25px}
  :root #appShell .sidebar .profile small {font-size:11px;font-weight:650}
  :root #appShell .sidebar .profile .avatar {background:var(--brand-royal);color:#fff;border-color:var(--brand-blue);font-family:inherit;font-weight:750}
  :root[data-app-theme="dark"] #appShell .sidebar .brand-image {filter:brightness(0) invert(1)}
}
@media (prefers-reduced-motion:reduce) {
  :root #appShell .mobile-nav button {transition:none}
}
