/* layout.css — app shell, sidebar navigation, top bar, and mobile layout */
/* ---------- app shell ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; transition: width .16s, transform .2s; z-index: 60;
}
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--player) + 14px); }
body.player-open .main { padding-bottom: calc(var(--player) + 20px); }
.page { padding: 14px 18px 24px; max-width: 1680px; margin: 0 auto; }

.brand {
  display: flex; align-items: center; gap: 9px; padding: 0 16px; height: var(--top);
  flex: none; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
.brand-m { display: none !important; }
.brand-t {
  font-family: var(--f-display) !important;
  font-size: 22px;
  font-weight: 500;
  color: var(--tx);
  letter-spacing: -0.02em;
  flex: 1;
}
/* ---------- sidebar collapse ----------
   Collapsed shows a 64px icon rail. Because a collapsed rail hides labels,
   we keep THREE ways back: the chevron button, a dedicated edge expander that
   only appears while collapsed, and hover-to-open. State is persisted. */
body.nav-collapsed .sidebar { width: 64px; }
body.nav-collapsed .brand { padding: 0 8px; justify-content: center; cursor: pointer; gap: 4px; }
body.nav-collapsed .brand-t, body.nav-collapsed .nav-t, body.nav-collapsed .nav-n,
body.nav-collapsed .nav-sec, body.nav-collapsed .nav-foot .nav-t { display: none; }
body.nav-collapsed .brand .icon {
  display: inline-flex;
  font-size: 16px;
  font-weight: 700;
  color: var(--tx2);
}
body.nav-collapsed .brand .icon:hover { color: var(--accent); }
body.nav-collapsed .nav-i { justify-content: center; padding: 0; gap: 0; }
body.nav-collapsed .nav-i i { font-size: 17px; }
body.nav-collapsed .nav { padding: 8px 6px; }
body.nav-collapsed .nav-foot { padding: 7px 6px; display: flex; flex-direction: column; gap: 6px; }
body.nav-collapsed .nav-expand-foot-btn {
  height: 32px; border-radius: 8px; background: var(--panel2);
  color: var(--accent); font-weight: bold; font-size: 16px;
}
body.nav-collapsed .nav-expand-foot-btn:hover { background: var(--accent); color: #fff; }
body.nav-collapsed .nav-badge {
  position: absolute; top: 2px; right: 4px; font-size: 9px; padding: 0 4px;
}

/* Also show topbar menu icon on desktop when rail is collapsed */
body.nav-collapsed .topbar #btn-menu { display: inline-flex !important; }

/* the expander handle: sits cleanly on the 64px rail edge, clearly visible */
.nav-expand {
  position: fixed; left: 64px; top: 50%; transform: translateY(-50%);
  z-index: 100; width: 24px; height: 60px; border-radius: 0 10px 10px 0;
  background: var(--panel2); border: 1px solid var(--line2); border-left: 0;
  color: var(--tx2); cursor: pointer; display: none;
  align-items: center; justify-content: center; font-size: 17px; font-weight: 700; padding: 0;
  box-shadow: 3px 6px 18px rgba(0,0,0,0.45); transition: width .16s ease, background .14s ease, color .14s ease;
}
body.nav-collapsed .nav-expand { display: flex; }
.nav-expand:hover { width: 30px; background: var(--accent); color: #fff; }
.nav-expand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* hover-peek: the collapsed rail previews the full sidebar, floats above content */
body.nav-collapsed.nav-peek .sidebar { width: var(--sidebar); box-shadow: var(--sh); }
body.nav-collapsed.nav-peek .brand { padding: 0 10px 0 14px; justify-content: flex-start; }
body.nav-collapsed.nav-peek .brand-t,
body.nav-collapsed.nav-peek .nav-t,
body.nav-collapsed.nav-peek .nav-n,
body.nav-collapsed.nav-peek .nav-sec,
body.nav-collapsed.nav-peek .nav-foot .nav-t { display: block; }
body.nav-collapsed.nav-peek .nav-i { justify-content: flex-start; padding: 0 9px; gap: 9px; }
body.nav-collapsed.nav-peek .nav-expand { display: none; }
@media (max-width: 820px) { .nav-expand { display: none !important; } }

.nav { padding: 8px 7px; display: flex; flex-direction: column; gap: 2px; flex: none; }
.nav-i {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border-radius: 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13.5px; font-weight: 500; text-align: left; transition: background .14s ease, color .14s ease;
}
.nav-i svg, .nav-i .svg-icon, .nav-i i {
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); flex: none; font-style: normal;
}
.nav-i:hover { background: var(--panel2); color: var(--tx); }
.nav-i:hover svg, .nav-i:hover .svg-icon { color: var(--tx); }
.nav-i.on {
  background: var(--panel2); color: var(--tx); font-weight: 500;
  box-shadow: none; border: none;
}
.nav-i.on svg, .nav-i.on .svg-icon { color: var(--tx); }
.nav-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-badge { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 10.5px; font-weight: 700; }
.nav-sec { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 7px; }
.nav-sech {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 9px 4px;
  font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-foot { padding: 7px; border-top: 1px solid var(--line); flex: none; }
.shelf-i { position: relative; }
.shelf-i .dotc { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-left: 2px; }
.shelf-i.on { background: var(--panel2); }

/* ---------- topbar ---------- */
.topbar {
  min-height: var(--top); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
}
.pastebar {
  flex: 1; min-width: 0; position: relative; display: flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px 0 10px;
  min-height: 36px; max-height: 168px;
  transition: border-color .15s, box-shadow .15s;
}
.pastebar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.paste-ico { color: var(--muted); font-size: 13px; flex: none; }
.paste-input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-size: 13px; font-family: inherit; line-height: 1.45; color: var(--tx);
  resize: none; overflow-y: hidden; padding: 8px 0; display: block;
}
.paste-input::placeholder { color: var(--muted); }
/* A long placeholder is not truncated by the browser, it just clips mid-word
   against the Add button on narrow screens. Let it shrink instead. */
@media (max-width: 820px) { .paste-input { font-size: 12px; } }
.paste-hint {
  position: absolute; left: 8px; right: 8px; top: calc(100% + 5px); font-size: 11.5px; color: var(--tx2);
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px;
  opacity: 0; pointer-events: none; transition: opacity .13s; z-index: 5; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; box-shadow: var(--sh2);
}
.paste-hint.on { opacity: 1; }
.top-right { display: flex; align-items: center; gap: 4px; flex: none; }
.search-box { position: relative; display: flex; align-items: center; }
.search {
  width: 190px; height: 32px; padding: 0 28px 0 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--tx); outline: none; font-size: 12.5px;
  transition: width .2s ease, border-color .15s ease, box-shadow .15s ease;
}
.search:focus { border-color: var(--accent); width: 240px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search-clear-btn {
  position: absolute; right: 7px; width: 18px; height: 18px; border-radius: 50%;
  border: 0; background: var(--panel2); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; font-size: 10px; line-height: 1; padding: 0;
  transition: color .12s, background .12s;
}
.search-clear-btn:hover { color: var(--tx); background: var(--panel3); }

/* Topbar Cloud Sync & Device Pairing */
.topbar-sync-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; cursor: pointer; color: var(--tx2); font-size: 11.5px;
  font-weight: 600; transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap; flex: none;
}
.topbar-sync-btn:hover { background: var(--panel2); border-color: var(--line2); color: var(--tx); }
.topbar-sync-btn .sync-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); flex: none;
}
.topbar-sync-btn.syncing .sync-dot {
  background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
  animation: pulseSyncDot 0.8s infinite alternate ease-in-out;
}
.topbar-sync-btn.err .sync-dot {
  background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
}
.topbar-sync-btn.local .sync-dot {
  background: var(--muted); box-shadow: none;
}
@keyframes pulseSyncDot {
  from { opacity: 0.35; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.2); }
}

.pair-qr-wrap svg { display: block; border-radius: 12px; }

.statusbar {
  height: 26px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-top: 1px solid var(--line); background: var(--bg2); font-size: 11.5px;
}
/* the player bar is fixed, so lift the status bar clear of it */
body.player-open .statusbar { margin-bottom: var(--player); }
.statusbar .net::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
body.is-offline .statusbar .net::before { background: var(--err); }
.scrim { display: none; }


/* ---------- mobile bottom navigation ---------- */
.mobile-nav { display: none; }

@media (max-width: 820px) {
  :root { --top: 50px; --player: 54px; }
  .only-desktop { display: none !important; }
  .only-mobile { display: inline-flex !important; }

  /* Mobile Slide-Over Sidebar Drawer */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: 0 10px 40px rgba(0,0,0,0.65); z-index: 150;
    transition: transform .26s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg2);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.68);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 140;
  }
  body.nav-collapsed .sidebar { width: 280px; }

  /* Mobile Topbar */
  .topbar { padding: 0 8px; gap: 6px; }
  .search, .search-box { display: none !important; }
  #btn-install, #btn-lock { display: none !important; }
  .topbar-sync-btn {
    height: 32px;
    padding: 0 8px;

/* ---------- Header Paste Shelf Selector ---------- */
.paste-shelf-select {
  height: 32px;
  background: var(--bg2, #181614);
  color: var(--tx, #f4efe6);
  border: 1px solid var(--line2, #332f2a);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  max-width: 140px;
}
.paste-shelf-select:hover,
.paste-shelf-select:focus {
  border-color: var(--accent, #d4784a);
  box-shadow: 0 0 0 2px rgba(212, 120, 74, 0.15);
}
@media (max-width: 640px) {
  .paste-shelf-select {
    max-width: 100px;
    font-size: 11px;
    padding: 0 4px;
  }
}

