/* Spindle — three-panel app layout */

/* ─── App Shell ──────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: 44px 1fr;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — shrinks when Safari chrome appears */
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* ─── Search panel ───────────────────────────────────────────────────────── */
/* Absolutely positioned so it overlays the app-body without affecting the
   grid track sizes — prevents the 1fr row from shrinking during skeleton load */
.search-panel {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  flex-wrap: wrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.search-input {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg-bright);
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--fg-dimmer); }
.search-input:focus { border-color: var(--fg-dim); }

.search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.search-label {
  font-size: 10.5px;
  color: var(--fg-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.search-btn {
  font-size: 11px;
  padding: 5px 12px;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.search-close-btn {
  font-size: 12px;
  color: var(--fg-dim);
  flex-shrink: 0;
}
.search-close-btn:hover { color: var(--fg-bright); }

/* ─── Shell entrance animations ─────────────────────────────────────────── */
.app-topbar  { animation: rise 0.45s cubic-bezier(0.16,1,0.3,1) both; }
.sidebar     { animation: rise 0.45s cubic-bezier(0.16,1,0.3,1) 50ms both; }
.content-pane{ animation: rise 0.45s cubic-bezier(0.16,1,0.3,1) 100ms both; }

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.app-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg-dim);
  flex-shrink: 0;
}
.app-topbar .tb-left,
.app-topbar .tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-topbar .tb-right { justify-content: flex-end; }
.app-topbar .tb-center {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-bright);
}
.app-topbar .tb-user {
  font-size: 11.5px;
  color: var(--fg-dim);
}
.app-topbar .tb-user .em { color: var(--fg-bright); }

/* ─── Body grid ──────────────────────────────────────────────────────────── */
.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
  overflow: hidden;
}
.app-body.has-list {
  grid-template-columns: 240px 320px 1fr;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section {
  padding: 14px 16px 8px;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-section .sb-add {
  color: var(--fg-dim);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
  background: none;
  border: none;
  font-family: inherit;
  line-height: 1;
}
.sidebar-section .sb-add:hover { color: var(--fg-bright); }

.folder-list { display: flex; flex-direction: column; }
.folder {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 16px;
  border-left: 2px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
  align-items: baseline;
  transition: background 0.1s;
}
.folder:hover { background: var(--bg-hover); }
.folder.active {
  background: var(--bg-active);
  border-left-color: var(--fg-bright);
}
.folder .f-name  { color: var(--fg-bright); }
.folder .f-count { color: var(--fg-dim); font-size: 11px; }
.folder .f-meta  { grid-column: 1 / -1; color: var(--fg-dim); font-size: 11px; }

/* All Inboxes card */
.folder-all .f-name {
  color: var(--fg-bright);
  letter-spacing: 0.04em;
}

/* Separator between All Inboxes and individual accounts */
.folder-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 12px;
  flex-shrink: 0;
}

/* Account row when its folder tree is expanded */
.folder.folder-open {
  background: var(--bg-subtle);
  border-left-color: var(--fg-bright);
}

/* ── Folder tree sub-items ─────────────────────────────────────────── */
.folder-tree-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 5px 16px 5px 30px;
  cursor: pointer;
  font-size: 11.5px;
  border-left: 2px solid transparent;
  transition: background 0.1s;
  align-items: baseline;
}
.folder-tree-item.animating { animation: rise 0.28s cubic-bezier(0.16,1,0.3,1) calc(var(--i, 0) * 30ms) both; }
.folder-tree-item:hover { background: var(--bg-hover); }
.folder-tree-item.active {
  background: var(--bg-active);
  border-left-color: var(--fg-bright);
}
.folder-tree-item .ft-name  { color: var(--fg); }
.folder-tree-item .ft-count { color: var(--fg-dim); font-size: 10.5px; }

.folder-tree-loading {
  padding: 5px 16px 5px 30px;
  font-size: 11px;
  color: var(--fg-dimmer);
  letter-spacing: 0.04em;
}

/* Account badge on merged inbox rows */
.tr-acct-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-dimmer);
  border: 1px solid var(--line-2);
  padding: 1px 5px;
  margin-right: 7px;
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
}
.tr-preview-all {
  display: flex;
  align-items: baseline;
  gap: 0;
  overflow: hidden;
}

/* Spacer pushes system section to bottom */
.sidebar-spacer { flex: 1; }

/* ─── Thread list pane ───────────────────────────────────────────────────── */
.thread-list {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#thread-list-rows {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.thread-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ─── Main content pane ──────────────────────────────────────────────────── */
.content-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ─── Auth shell (login / register / recover pages) ─────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-shell > * { flex-shrink: 0; }

/* Split layout variant */
.layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.layout-split .split-left {
  border-right: 1px solid var(--line);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.layout-split .split-right {
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.layout-split .pitch {
  font-size: 28px;
  line-height: 1.3;
  color: var(--fg-bright);
  letter-spacing: -0.005em;
}
.layout-split .pitch .dim { color: var(--fg-dim); }
.layout-split .marketing-meta {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .auth-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .layout-split {
    grid-template-columns: 1fr;
  }

  .layout-split .split-left {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 32px 20px;
  }

  .layout-split .split-right {
    padding: 32px 20px;
  }
}

/* ─── Mobile inbox layout ────────────────────────────────────────────────── */

/* Back button — hidden on desktop, shown inside list panel on mobile */
.mobile-list-back {
  display: none;
}

/* Hamburger — hidden on desktop */
.mobile-only { display: none !important; }

@media (max-width: 768px) {
  /* Show hamburger */
  .mobile-only { display: inline-flex !important; }

  /* Hide "logged in as" text — too cramped */
  .tb-user { display: none; }

  /* Collapse grid to single column regardless of has-list */
  .app-body,
  .app-body.has-list {
    grid-template-columns: 1fr;
  }

  /* Default: sidebar and list hidden, reader shown */
  .sidebar      { display: none; }
  .thread-list  { display: none !important; }

  /* Sidebar panel open */
  .app-shell[data-mobile-panel="sidebar"] .sidebar     { display: flex; }
  .app-shell[data-mobile-panel="sidebar"] .content-pane{ display: none; }

  /* List panel open */
  .app-shell[data-mobile-panel="list"] .thread-list  { display: flex !important; }
  .app-shell[data-mobile-panel="list"] .content-pane { display: none; }

  /* Back button inside list panel */
  .mobile-list-back {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 11.5px;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--line-2);
    cursor: pointer;
    flex-shrink: 0;
    letter-spacing: 0.04em;
    transition: color 0.1s;
  }
  .mobile-list-back:hover { color: var(--fg-bright); }
}
