/* Desktop layout. Every rule that changes size or position is inside a min-width
   query so phone (<=768px) and the existing tablet tab bar (768px to 1023px) stay as they are.
   Wide layout starts at 1024px. Nothing here reads the user agent. */

.ag-side,
.ag-backbar,
.ag-side-brand { display: none; }

@media (min-width: 1024px) {
  :root { --ag-side: 240px; }

  /* The signed-in tab shell does not load this file (its script already mentions the
     header class, which skips chrome injection). Those rules live in _tabs.html.
     Detail pages get the same rail here. */
  .ag-side .ag-side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 18px;
    color: #fff !important;
    text-decoration: none !important;
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: 1px;
    font-size: 15px;
  }
  .ag-side .ag-side-brand img {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    border-radius: 50%;
    border: 1.5px solid #D4AF37;
    object-fit: cover;
  }

  /* Detail pages keep the same rail, plus a back link in the content column. */
  body:has(> .ag-side) { padding-left: var(--ag-side); }
  .ag-side {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--ag-side);
    z-index: 60;
    padding: 22px 14px 24px;
    background: #0a0a0a;
    border-right: 1px solid rgba(212,175,55,.28);
    box-sizing: border-box;
  }
  .ag-side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,.72) !important;
    text-decoration: none !important;
    font: 600 15px Inter, sans-serif;
  }
  .ag-side-link .ti { font-size: 18px; width: 1.5em; text-align: center; filter: grayscale(1) brightness(1.3); opacity: .75; }
  .ag-side-link:hover { background: rgba(212,175,55,.08); color: #fff !important; }
  .ag-side-link[aria-current="page"] { background: rgba(212,175,55,.14); color: #D4AF37 !important; }
  .ag-side-link[aria-current="page"] .ti { filter: none; opacity: 1; }
  .ag-side-link:focus-visible,
  .ag-back:focus-visible { outline: 2px solid #D4AF37; outline-offset: 2px; }
  .ag-backbar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 40;
    max-width: 720px;
    margin: 0 auto;
    padding: 4px 18px 0;
    background: #0a0a0a;
  }
  .ag-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 2px;
    color: #D4AF37 !important;
    font: 700 15px Inter, sans-serif;
    text-decoration: none !important;
  }
  .ag-back:hover { color: #fff !important; }
  body:has(> .ag-side) .ag-top { justify-content: flex-end; max-width: 720px; }
  body:has(> .ag-side) .ag-top .ag-brand { display: none; }

  /* Public pages and the signed-in detail column. Phone max-widths stay in each page. */
  body:not(.tabbed) .wrap { max-width: 560px; }
  body:not(.tabbed) .wrap > h1 { font-size: 48px; }
  body:not(.tabbed):not(.bl) .w { max-width: 720px; }
  body:not(.tabbed):not(.bl) .w h1 { font-size: 42px; }
  body .ag-top { max-width: 720px; }
  body.tabbed .ag-top { max-width: 800px; }

  body:has(#planetTable) .w,
  body:has(#planetTable) .ag-top,
  body:has(#planetTable) .ag-backbar { max-width: 1040px; }
  body:has(#planetTable) h2 { font-size: 30px !important; }
  body:has(#planetTable) .kundli { width: 100%; max-width: 520px; height: auto; }
  body:has(#planetTable) .kchat {
    display: grid;
    grid-template-columns: minmax(300px, 520px) minmax(0, 1fr);
    gap: 8px 32px;
    align-items: center;
    text-align: left;
  }
  body:has(#planetTable) .kchat .kbox,
  body:has(#planetTable) .kchat > .meta { grid-column: 1; }
  body:has(#planetTable) .kchat .msg,
  body:has(#planetTable) .kchat .qchips { grid-column: 2; }
  body:has(#planetTable) .kchat .qchips { justify-content: flex-start; }
  body:has(#planetTable) .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body:has(#planetTable) .ptable { font-size: 15px; }
  body:has(#planetTable) .ptable th,
  body:has(#planetTable) .ptable td { padding: 12px 10px; }
  body:has(#planetTable) #houses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 32px;
  }
  body:has(#planetTable) #houses > .badge,
  body:has(#planetTable) #houses > h2,
  body:has(#planetTable) #houses > p { grid-column: 1 / -1; }
  body:has(#planetTable) #houses .hrow h3 { font-size: 17px; }
  body:has(#planetTable) #houses .hrow p { font-size: 15.5px; }

  body.bl .w { max-width: 780px !important; }
  body.bl .ag-top { max-width: 780px; }
  body.bl .ph h1 { font-size: 44px; }
  body.bl .art { max-width: 700px; }
}
