/* The application shell: page, rail, top bar, main column, tab bar. */

#root { height: 100%; }

.app {
  height: 100dvh; width: 100vw; overflow: hidden;
  padding: clamp(6px, 1.2vh, 20px);
  background: var(--page-grad);
}

.shell {
  height: 100%; width: 100%;
  background: var(--shell);
  border-radius: var(--r-shell);
  box-shadow: var(--shadow-shell);
  display: flex;
  padding: clamp(7px, 1.1vh, 15px);
  gap: clamp(8px, 1.1vw, 18px);
  overflow: hidden;
}

/* --- Brand -------------------------------------------------------------- */
/* The app's own icon, wherever only a square fits. It is drawn on black, so
 * it reads as a tile on any surface. */
.mark { flex: 0 0 auto; display: block; width: 22px; height: 22px; border-radius: 23%; }

/* --- Sidebar rail ------------------------------------------------------- */
.rail {
  flex: 0 0 auto;
  width: clamp(190px, 15vw, 224px);
  background: var(--dark);
  border-radius: var(--r-rail);
  display: flex; flex-direction: column;
  padding: clamp(10px, 1.6vh, 20px) 12px;
  overflow: hidden;
}
.rail-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px clamp(10px, 2.2vh, 24px);
}
/* The wordmark while the rail is wide, the icon once it collapses. */
.rail-brand .wordmark { display: block; width: 100%; max-width: 156px; height: auto; }
.rail-brand .mark { display: none; width: 36px; height: 36px; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; }

.navitem {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border: 0; border-radius: var(--r-nav);
  background: transparent; color: #b6b2be;
  font-size: var(--t-body); font-weight: 400;
  text-align: left; cursor: pointer; width: 100%;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.navitem:hover { background: rgba(255, 255, 255, .05); color: #e6e3ec; }
.navitem svg { flex: 0 0 auto; color: #cfccd6; }
.navitem[aria-current="page"] { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 500; }
.navitem[aria-current="page"] svg { color: #fff; }
.navitem .label { white-space: nowrap; }
.navitem .badge {
  margin-left: auto; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 600;
}

.rail-spacer { flex: 1 1 auto; min-height: 6px; }
.rail-foot {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .08);
}
.rail-drive {
  display: flex; align-items: center; gap: 9px; padding: 0 10px;
  font-size: var(--t-micro); color: #8d8996;
}
.rail-drive span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signout {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 0; border-radius: var(--r-nav);
  background: rgba(255, 255, 255, .05); color: #b6b2be;
  font-size: var(--t-body); cursor: pointer; width: 100%; text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.signout:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.signout svg { color: #b6b2be; }
.signout:hover svg { color: #fff; }

/* Between 860 and 1079px the rail keeps only its icons, as in the design. */
@media (max-width: 1079px) {
  .rail { width: 66px; padding-left: 10px; padding-right: 10px; }
  .rail-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .rail-brand .wordmark, .rail-drive { display: none; }
  .rail-brand .mark { display: block; }
  .navitem, .signout { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
  .navitem .label, .signout .label { display: none; }
  .navitem .badge {
    position: absolute; top: 6px; right: 10px; margin: 0;
    min-width: 16px; height: 16px; padding: 0 4px; font-size: 9px;
  }
}

/* --- Main column -------------------------------------------------------- */
.main {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  gap: var(--gap); overflow: hidden;
}
.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); overflow: hidden; }
.screen-scroll { overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }

/* --- Top bar ------------------------------------------------------------ */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: clamp(6px, .8vw, 12px);
  background: var(--panel); border-radius: var(--r-head);
  padding: clamp(5px, .8vh, 10px) clamp(6px, .7vw, 12px);
}
.searchwrap {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--sub-2); border-radius: var(--r-ctl);
  padding: 0 13px; height: clamp(38px, 4.4vh, 48px);
}
.searchwrap svg { flex: 0 0 auto; color: var(--ink); }
.searchwrap input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font-size: var(--t-body); color: var(--ink);
}
.searchwrap:focus-within { box-shadow: inset 0 0 0 2px var(--accent-ring); }
.searchwrap .clear {
  flex: 0 0 auto; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.searchwrap .clear:hover { background: #e7e3ee; color: var(--ink); }

.bartitle {
  flex: 1 1 auto; min-width: 0; margin: 0;
  padding: 0 4px;
  font-size: var(--t-h2); font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.rolechip {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 7px;
  background: var(--sub-2); border-radius: var(--r-ctl);
  padding: 0 12px; height: clamp(38px, 4.4vh, 48px);
  font-size: var(--t-small); color: var(--ink-2); white-space: nowrap;
}
.rolechip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.rolechip .dot.warn { background: var(--warn); }

.refresh {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: clamp(38px, 4.4vh, 48px); padding: 0 16px;
  border: 0; border-radius: var(--r-ctl);
  background: var(--dark); color: #fff;
  font-size: var(--t-body); font-weight: 500; cursor: pointer;
  transition: background .16s var(--ease);
}
.refresh:hover { background: var(--dark-2); }
.refresh[disabled] { opacity: .6; cursor: default; }
@media (max-width: 1079px) { .refresh { padding: 0 12px; } .refresh .label { display: none; } }
@media (max-width: 759px)  { .rolechip { display: none; } }

/* --- Mobile header + tab bar (hidden until the phone breakpoint) --------- */
.mobilebar { display: none; }
.tabbar { display: none; }
