/*
 * The frame every signed-in page sits in: the sidebar on the left (a menu at the top on a phone) and the page beside
 * it. Pages use .page and its header; inside, .stack piles things up, .row sets them side by side (wrapping on a phone),
 * .grid-2 makes two columns (one on a phone) and .split puts the chat beside the spec on a wide screen.
 */
.shell { min-height: 100vh; min-height: 100dvh; }

.main { min-width: 0; background: var(--paper); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.main > .notice, .main > .alert, .main > .banner { margin: 16px 32px 0; }
@media (max-width: 599px) {
  .main > .notice, .main > .alert, .main > .banner { margin: 12px 16px 0; }
}

/* A phone's bar along the top: the wordmark and the menu button. Hidden on wide screens. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 17px; letter-spacing: 0.01em; text-decoration: none; }
.wordmark:hover { text-decoration: none; }

/* Kiln's mark: a flame in a jade tile (KilnMark). */
.mark {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(#6FB5A1, #2F6A5D);
  color: #06110E;
}
.mark svg { width: 56%; height: 56%; }
.mark--large { width: 56px; height: 56px; border-radius: 16px; }
.mark--small { width: 22px; height: 22px; border-radius: 6px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .topbar { display: none; }
}

/* Pages */
.page { padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page--reading { max-width: 900px; }
/* A page's heading and the line under it; with .page-actions inside, the actions sit beside them. */
.page-header { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-header:has(> .page-actions) { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.page-header-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 820px; }
.page-header:has(> .page-actions) > .page-header-text { flex: 1 1 340px; }
.page-title { font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; }
.page-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.page-subtitle { color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

@media (max-width: 599px) {
  .page { padding: 20px 16px 40px; gap: 16px; }
  .page-title { font-size: 22px; }
}

/*
 * A page that works like the Mac window: a header, then the chat beside the spec filling the rest of the window, each
 * side scrolling by itself. On narrower screens it's an ordinary page that scrolls.
 */
.workspace { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.workspace-head { padding: 24px 28px 14px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 599px) {
  .workspace-head { padding: 18px 16px 12px; }
}

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack--tight { gap: 8px; }
.stack--loose { gap: 28px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 719px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/*
 * The chat beside the spec (or the product analyst beside the brief and the map). One column on a phone, the chat
 * first, with a height of its own so what's beside it is never far away.
 */
.split { display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--rule); min-width: 0; flex: 1 1 auto; }
.split-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); }
.split-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--canvas); }

@media (max-width: 1099px) {
  .split-side { border-bottom: 1px solid var(--rule); }
}

@media (min-width: 1100px) {
  .main:has(.workspace) { height: 100vh; height: 100dvh; }
  .workspace { min-height: 0; }
  .split { grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); min-height: 0; }
  .split-side { border-right: 1px solid var(--rule); }
  .split-main { overflow: auto; }
}
