/* The app shell: the side menu (six sections, app/modules.py), the tabs of the current section, the page header,
   and on phones a top bar, a drawer and a bottom bar. */

.skip { position:absolute; right:-999px; top:8px; background:var(--primary); color:#fff; padding:8px 14px; border-radius:6px; z-index:1000; }
.skip:focus { right:8px; }

.app { display:grid; grid-template-columns:var(--side) 1fr; min-height:100dvh; }
main { padding:var(--s6) 36px 60px; max-width:1240px; width:100%; margin:0 auto; min-width:0; }

/* ---- the side menu ---- */
.side { background:var(--grad-side); color:#d9d6f5; position:sticky; top:0; height:100dvh; overflow:auto;
        display:flex; flex-direction:column; padding:20px 14px; gap:4px; }
.brand { display:flex; align-items:center; gap:10px; color:#fff; font-weight:700; font-size:var(--t-md); padding:0 8px 18px; line-height:1.5; }
.brand .logo { width:34px; height:34px; border-radius:11px; background:var(--grad); display:grid; place-items:center; flex:none;
               box-shadow:0 6px 18px -4px rgba(139,92,246,.7); }
.side nav { display:flex; flex-direction:column; gap:2px; }
.side .new-chat { display:flex; align-items:center; justify-content:center; gap:8px; margin:0 0 10px; padding:10px 12px; min-height:44px;
                  border-radius:12px; background:rgba(255,255,255,.14); color:#fff; font-weight:600; text-decoration:none;
                  border:1px solid rgba(255,255,255,.18); }
.side .new-chat:hover { background:rgba(255,255,255,.22); }
.side .side-sec { font-size:11.5px; color:#a5a1d6; margin:12px 10px 4px; }
.side nav.chats a { min-height:38px; padding:7px 12px; gap:10px; font-size:13.5px; }
.side nav.chats a span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.side nav.chats { max-height:34vh; overflow-y:auto; }
.side nav a { display:flex; align-items:center; gap:12px; color:#e0e7ff; padding:10px 12px; border-radius:12px; min-height:44px;
              font-weight:500; font-size:var(--t-base); text-decoration:none; transition:background .15s var(--ease); }
.side nav a .ic { opacity:.85; }
.side nav a:hover { background:rgba(255,255,255,.07); color:#fff; }
.side nav a[aria-current="page"] { background:rgba(255,255,255,.13); color:#fff; box-shadow:inset -3px 0 0 #a78bfa; }
.badge { margin-inline-start:auto; background:var(--spark); color:#fff; font-size:var(--t-xs); font-weight:700;
         border-radius:99px; padding:0 8px; min-width:22px; line-height:22px; text-align:center; }
.app-tools { display:flex; flex-direction:column; gap:6px; margin:auto 0 10px; }
.app-tools button { width:100%; justify-content:flex-start; background:rgba(255,255,255,.06); color:#e0e7ff;
                    border:1px solid rgba(255,255,255,.14); box-shadow:none; }
.app-tools button:hover { background:rgba(255,255,255,.12); color:#fff; box-shadow:none; transform:none; }
.app-tools .hint { font-size:11.5px; opacity:.75; color:#c7d2fe; }
.me { border-top:1px solid rgba(255,255,255,.08); padding:12px 8px 0; font-size:var(--t-sm); color:#a5b4fc; }
.me b { display:block; color:#eef2ff; font-weight:600; }
.me form { margin-top:8px; }
.me select { background:rgba(255,255,255,.08); color:#fff; border-color:rgba(255,255,255,.16); }
.me button { background:transparent; border:1px solid rgba(255,255,255,.16); color:#e0e7ff; width:100%; justify-content:center; box-shadow:none; }
.me button:hover { background:rgba(255,255,255,.08); transform:none; box-shadow:none; }
.topbar { display:none; }

/* ---- the current section's tabs ---- */
.hub-tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin:-8px 0 var(--s5); overflow-x:auto; scrollbar-width:none; }
.hub-tabs a { display:inline-flex; align-items:center; gap:6px; padding:10px 14px; font-weight:500; color:var(--muted);
              border-bottom:2px solid transparent; white-space:nowrap; text-decoration:none; min-height:44px; }
.hub-tabs a:hover { color:var(--ink); }
.hub-tabs a[aria-current="page"] { color:var(--accent); border-bottom-color:var(--accent); }
.hub-tabs .badge { margin-inline-start:2px; }

/* ---- a page's header: title, one line, one main action ---- */
.page-head, .page-title { display:flex; align-items:center; justify-content:space-between; gap:var(--s4); flex-wrap:wrap;
                          margin:0 0 var(--s5); animation:enter .3s var(--ease) both; }
.page-head h1, .page-title h1 { margin:0; font-size:var(--t-lg); font-weight:700; line-height:1.5; }
.page-head p { margin:2px 0 0; color:var(--muted); }
.page-head .actions { margin-inline-start:auto; }
.page-title .spacer { flex:1; }
@keyframes enter { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ---- tablet: the menu becomes a drawer ---- */
@media (max-width: 1023px) {
  .app { grid-template-columns:1fr; }
  /* closed menu: hidden, not just moved off-screen (in RTL an off-screen fixed element widens the page) */
  .side { position:fixed; top:0; bottom:0; right:0; width:min(280px, 86vw); height:100dvh; visibility:hidden;
          transform:translateX(100%); transition:transform .2s var(--ease), visibility 0s linear .2s; z-index:40;
          box-shadow:-8px 0 24px rgba(0,0,0,.25); }
  .side.open { transform:none; visibility:visible; transition:transform .2s var(--ease); }
  .scrim { position:fixed; inset:0; background:rgba(27,24,64,.5); z-index:30; display:none; }
  .scrim.open { display:block; }
  .topbar { display:flex; align-items:center; gap:10px; background:var(--primary); color:#fff; padding:8px 12px;
            position:sticky; top:0; z-index:20; }
  .topbar button { background:transparent; border:0; color:#fff; min-width:44px; min-height:44px; justify-content:center; box-shadow:none; }
  .topbar button:hover { background:transparent; transform:none; box-shadow:none; }
  main { padding:var(--s5) var(--s4) 48px; }
}

/* ---- phone: a bottom bar with the main sections ---- */
.bottombar { display:none; }
@media (max-width: 640px) {
  main { padding:var(--s4) var(--s3) 96px; }
  .page-head h1, .page-title h1 { font-size:20px; }
  .bottombar { display:flex; position:fixed; bottom:0; left:0; right:0; z-index:25; background:rgba(255,255,255,.95);
               border-top:1px solid var(--line); padding:4px 4px calc(4px + env(safe-area-inset-bottom));
               box-shadow:0 -8px 24px -16px rgba(76,29,149,.35); }
  .bottombar a, .bottombar button { flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; font-size:var(--t-xs);
               color:var(--muted); background:transparent; border:0; padding:6px 0; min-height:54px; text-decoration:none;
               position:relative; box-shadow:none; font-weight:500; }
  .bottombar button:hover { background:transparent; transform:none; box-shadow:none; color:var(--muted); }
  .bottombar a[aria-current="page"] { color:var(--accent); font-weight:600; }
  .bottombar a[aria-current="page"]::before { content:""; position:absolute; top:0; width:26px; height:3px; border-radius:0 0 4px 4px; background:var(--grad); }
  .bottombar .badge { position:absolute; top:2px; left:calc(50% - 24px); margin:0; }
  .toast { bottom:80px; }
}
