/* The frame: left panel, header, content area. */

.shell {
  --panel-sidebar-width: var(--sidebar-width);
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100%;
}

.shell.is-collapsed {
  --panel-sidebar-width: 0px;
  grid-template-columns: minmax(0, 1fr);
}

.shell.is-collapsed .sidebar {
  display: none;
}

.shell-scrim {
  display: none;
}

.shell-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* The screen for the address. It stays in place, as it was left, under any
   records that are open on top of it. */
.shell-screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* --- Left panel ------------------------------------------------------------ */

.sidebar {
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-sidebar);
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-height);
  flex: none;
  padding: 0 10px 0 18px;
}

.sidebar-top-spacer {
  flex: 1;
}

.wordmark {
  font-size: var(--text-l);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.wordmark-large {
  font-size: 24px;
}

.env-tag {
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
}

.nav-section + .nav-section {
  margin-top: 14px;
}

.nav-heading {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text-3);
  font-size: var(--text-s);
}

.nav-heading:hover {
  color: var(--text-2);
}

.nav-heading-chevron {
  display: inline-flex;
  opacity: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.nav-heading:hover .nav-heading-chevron,
.nav-heading:focus-visible .nav-heading-chevron,
.nav-heading-chevron.is-closed {
  opacity: 1;
}

.nav-heading-chevron.is-closed {
  transform: rotate(-90deg);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-m);
  color: var(--text);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-hover);
}

.nav-item.is-current {
  background: var(--bg-selected);
}

.nav-item-icon {
  display: inline-flex;
  color: var(--text-2);
}

.nav-item.is-current .nav-item-icon {
  color: var(--text);
}

.sidebar-bottom {
  flex: none;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}

.sidebar-bottom .menu-anchor {
  display: flex;
}

.sidebar-bottom .menu {
  right: 0;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-m);
  background: transparent;
  text-align: left;
}

.account:hover,
.account.is-open {
  background: var(--bg-hover);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary-text);
  font-size: var(--text-s);
  font-weight: 600;
}

.account-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.account-name,
.account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-name {
  font-weight: 500;
}

.account-email {
  color: var(--text-3);
  font-size: var(--text-s);
}

.account-chevron {
  display: inline-flex;
  color: var(--text-3);
}

/* --- Header ---------------------------------------------------------------- */

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
  flex: none;
  padding: 0 calc(var(--gutter) - 8px) 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}

.header-left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.header-left > .icon-btn:first-child {
  margin-left: -8px;
}

.header-title {
  overflow: hidden;
  font-size: var(--text-l);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-left > .pill {
  margin-left: 6px;
}

.header-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}

/* --- Content --------------------------------------------------------------- */

.content {
  flex: 1;
  min-height: 0;
  padding: 24px var(--gutter) 48px;
  overflow-y: auto;
}

.content-column {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.content-column-narrow {
  max-width: 720px;
}

.content-column > .notice {
  margin-bottom: 16px;
}

/* --- Open records (shell/Panels.js) -----------------------------------------

   Each open record is anchored to the right. A record can fill the viewport
   or leave a dimmed strip of what is underneath; clicking it goes back one.
   Narrow: the whole content area. */

.panels {
  --panel-default-width: min(1120px, 100% - var(--panel-sidebar-width) - 56px);
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
}

/* The dimmed strip. One for the whole stack, so it does not darken with depth. */
.panels-scrim {
  position: absolute;
  inset: 0;
  left: min(var(--panel-sidebar-width), 100% - var(--under-panel-width, 0px));
  z-index: 1;
  width: calc(100% - min(var(--panel-sidebar-width), 100% - var(--under-panel-width, 0px)));
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--scrim);
  cursor: default;
  pointer-events: auto;
  animation: panels-dim 0.2s ease backwards;
  transition: opacity 0.17s ease;
}

.panels.is-closing .panels-scrim {
  opacity: 0;
}

/* A layer per record, in order, so a higher one covers a lower one and
   everything inside a panel (menus, its "+ New" pill) stays inside its layer. */
.panel-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.panel-layer.is-top {
  z-index: 2;
}

.panel-layer.is-leaving {
  z-index: 3;
}

.panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: var(--panel-preview-width, var(--panel-width, var(--panel-default-width)));
  background: var(--bg);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: panel-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.panel:focus {
  outline: none;
}

/* The grab strip along the top panel's left edge: nothing to see until the
   pointer is over it or the keyboard is on it. */
.panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  width: 7px;
  cursor: col-resize;
  touch-action: none;
  transition: background-color 0.12s ease;
}

.panel-resizer:hover,
.is-resizing-panel .panel-resizer {
  background: var(--line-strong);
}

.panel-resizer:focus-visible {
  outline: none;
  background: var(--focus);
}

/* While it is dragged: no text gets selected, and the pointer keeps its shape
   wherever it goes. */
.is-resizing-panel,
.is-resizing-panel * {
  cursor: col-resize !important;
  -webkit-user-select: none;
  user-select: none;
}

/* Open already when the page loaded: nothing to slide. */
.panel-layer.is-still .panel {
  animation: none;
}

.panel-layer.is-leaving .panel {
  animation: panel-out 0.17s ease-in forwards;
}

@keyframes panel-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes panel-out {
  to {
    transform: translateX(100%);
  }
}

@keyframes panels-dim {
  from {
    opacity: 0;
  }
}

@media (max-width: 820px) {
  .panel {
    width: 100%;
    box-shadow: none;
  }

  .panel-resizer {
    display: none;
  }

  .panels-scrim {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .panel-layer.is-leaving .panel,
  .panels-scrim {
    animation: none;
  }
}

/* --- Narrow screens: the left panel becomes a drawer ----------------------- */

@media (max-width: 820px) {
  .shell,
  .shell.is-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .shell.is-collapsed .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: flex;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .shell.is-drawer-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-pop);
  }

  .shell.is-drawer-open .shell-scrim {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    background: var(--scrim);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* --- Splash and sign-in ---------------------------------------------------- */

.splash,
.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.splash {
  color: var(--text-3);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 28px;
}

.auth-title {
  font-size: var(--text-xl);
  font-weight: 600;
}

.auth-text {
  margin-top: -8px;
  color: var(--text-2);
}

.input-code {
  height: 52px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  text-align: center;
}
