/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1rem; height: var(--topbar-h); border-bottom: 1px solid var(--border-soft); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand-sub { font-size: .7rem; color: var(--muted); }
.nav { padding: .5rem; overflow-y: auto; flex: 1; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .8rem .6rem .3rem; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--hover); }
.nav a[aria-current='page'] { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-strong); }
[data-theme='dark'] .nav a[aria-current='page'] { color: var(--brand-accent); }
.nav .count { margin-left: auto; font-size: .72rem; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 .45rem; min-width: 1.4rem; text-align: center; }
.nav .count.hot { background: var(--brand); color: #fff; }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid var(--border-soft); font-size: .75rem; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border-soft);
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; padding-left: 2.1rem; }
.topbar .search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.demo-banner {
  background: var(--warn-bg); color: var(--warn); font-size: .78rem; padding: .3rem 1rem; text-align: center;
  border-bottom: 1px solid var(--border-soft);
}
.content { flex: 1; overflow: auto; min-height: 0; position: relative; }
.page { padding: 1.25rem 1.5rem 2rem; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .85rem; margin: 0; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.topbar-logo { display: none; width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.bottom-nav { display: none; }
.more-sheet { display: none; }

/* Tablet: icon rail instead of the full sidebar */
@media (max-width: 1100px) and (min-width: 761px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .brand { padding: 0; justify-content: center; }
  .brand-text, .nav-label, .nav-section, .sidebar-foot { display: none; }
  .nav a { justify-content: center; position: relative; padding: .6rem; }
  .nav .count { position: absolute; top: 2px; right: 4px; margin: 0; font-size: .62rem; min-width: 1.1rem; padding: 0 .25rem; }
  .page { padding: 1rem 1.1rem 1.5rem; }
}

/* Phone: no sidebar, bottom tab bar, compact top bar */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { gap: .4rem; padding: 0 .6rem; }
  .topbar-logo { display: block; }
  .hide-sm, #theme-btn { display: none; }
  .topbar .spacer { display: none; }
  .topbar .search { min-width: 0; max-width: none; }
  .topbar .search input { padding-right: .5rem; font-size: 16px; }
  .thread-head { flex-wrap: wrap; gap: .4rem; }
  .thread-head > .input, .thread-head select.input { flex: 1; min-width: 120px; }
  .composer > .row:first-child { flex-wrap: wrap; }
  .composer .mode-switch { flex-shrink: 0; }
  .demo-banner { font-size: .7rem; padding: .25rem .6rem; }
  .page { padding: .85rem .75rem 1.25rem; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); flex-shrink: 0;
    background: var(--surface); border-top: 1px solid var(--border-soft);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bottom-nav a, .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; padding: .35rem .15rem; background: none; border: 0; color: var(--muted);
    font: inherit; font-size: .68rem; font-weight: 500; text-decoration: none; cursor: pointer;
  }
  .bottom-nav [aria-current='page'] { color: var(--brand-strong); }
  [data-theme='dark'] .bottom-nav [aria-current='page'] { color: var(--brand-accent); }
  .bn-count { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--brand); color: #fff; border-radius: 999px; font-size: .62rem; min-width: 1.05rem; padding: 0 .25rem; text-align: center; line-height: 1.05rem; }
  .more-sheet {
    display: block; position: fixed; left: .5rem; right: .5rem; bottom: calc(60px + env(safe-area-inset-bottom, 0)); z-index: 70;
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  }
  .more-sheet .menu a { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; color: var(--text); text-decoration: none; min-height: 44px; }
}

/* ---------- Split views (inbox, ticket detail) ---------- */
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; min-height: 0; }
.split > * { min-height: 0; }
.pane { background: var(--surface); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; min-height: 0; }
.pane-head { padding: .75rem; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: .5rem; }
.pane-body { flex: 1; overflow-y: auto; min-height: 0; }
.thread-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; height: 100%; }
.thread-wrap.no-side { grid-template-columns: minmax(0, 1fr); }
.thread { display: flex; flex-direction: column; min-height: 0; background-color: var(--chat-bg); background-image: var(--doodle); background-size: 380px auto; }
.side-panel { background: var(--surface); border-left: 1px solid var(--border-soft); overflow-y: auto; padding: 1rem; }

@media (max-width: 1200px) { .thread-wrap { grid-template-columns: minmax(0, 1fr); } .thread-wrap .side-panel { display: none; } .thread-wrap.show-side .side-panel { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 50; box-shadow: var(--shadow-lg); } }
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split.has-selection > .pane:first-child { display: none; }
  .split:not(.has-selection) > :last-child { display: none; }
}

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .detail-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Kanban ---------- */
.board { position: relative; display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.column { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); width: 280px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 260px); }
.column-head { padding: .65rem .75rem; border-bottom: 1px solid var(--border-soft); }
.column-body { padding: .5rem; display: flex; flex-direction: column; gap: .5rem; overflow-y: auto; min-height: 80px; }
.column.drag-over { outline: 2px dashed var(--brand); outline-offset: -2px; }
