/* ============================================================
   Ubongo Cloud 2.1 — Layout
   App rail, top bar, projects sidebar, controls panel, grid
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

/* ---------- App rail ---------- */
.rail {
  background: var(--paper);
  border-right: 1px solid var(--mist);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.rail .logo { width: 40px; height: 40px; margin-bottom: 10px; }
.rail-item {
  position: relative; width: 56px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
  text-decoration: none; transition: background .15s var(--ease);
}
.rail-item:hover { background: var(--cloud); text-decoration: none; }
.rail-item svg { width: 26px; height: 26px; }
.rail-item .rlabel { font-size: 9px; font-weight: 600; margin-top: 2px; color: var(--muted); }
.rail-item .ico-stack { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.rail-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 26px; background: var(--indigo); border-radius: 0 4px 4px 0;
}
.rail-item.active { background: var(--cloud); }
.rail-sep { width: 36px; height: 1px; background: var(--mist); margin: 8px 0; }
.rail-spacer { flex: 1; }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; background: var(--cream);
  border-bottom: 1px solid var(--mist);
  position: sticky; top: 0; z-index: 50;
}
.topbar .ws-name { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar .ws-name .mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; }
.topbar .ws-name .mark svg { width: 20px; height: 20px; }
.topbar .spacer { flex: 1; }
.topbar .switcher-anchor, .topbar .credit-anchor { position: relative; }

.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--paper);
  border: 1.5px solid var(--mist); border-radius: var(--radius-pill);
  padding: 9px 16px; min-width: 220px; color: var(--muted);
}
.search-box input { border: none; outline: none; background: transparent; flex: 1; font-family: inherit; font-size: 14px; }

/* ---------- Workspace body grid ---------- */
.ws-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr var(--controls-w); flex: 1; min-height: 0; }
.ws-body.no-controls { grid-template-columns: var(--sidebar-w) 1fr; }
.ws-body.full { grid-template-columns: 1fr; }

/* projects sidebar */
.sidebar {
  background: var(--cream); border-right: 1px solid var(--mist);
  padding: 18px 16px; overflow-y: auto;
}
.sidebar h5 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.proj-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px;
  cursor: pointer; font-size: 14px; color: var(--ink); transition: background .15s var(--ease);
}
.proj-item:hover { background: var(--cloud); }
.proj-item .dot-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--mist); flex: none; }

/* work surface */
.work { background: var(--cream); padding: 22px; overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.work-card { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius-card); box-shadow: var(--shadow-soft); flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* controls panel */
.controls { background: var(--cream); border-left: 1px solid var(--mist); padding: 18px 16px; overflow-y: auto; }
.controls h5 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.control-group { margin-bottom: 20px; }

/* generic page container (non-workspace pages) */
.page { padding: 32px 28px; max-width: 1180px; margin: 0 auto; width: 100%; }
.page-wide { max-width: 1320px; }

/* mobile bottom nav + sheet (hidden on desktop) */
.bottom-nav, .mobile-bar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ws-body { grid-template-columns: var(--sidebar-w) 1fr; }
  .ws-body .controls { display: none; }
  .ws-body .controls.sheet-open { display: block; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .ws-name { font-size: 16px; }
  .search-box { display: none; }

  .ws-body { grid-template-columns: 1fr; }
  .ws-body .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 80%; max-width: 320px; z-index: 80;
    transform: translateX(-100%); transition: transform .25s var(--ease);
    box-shadow: var(--shadow-lift);
  }
  .ws-body .sidebar.drawer-open { transform: translateX(0); }
  .ws-body .controls {
    position: fixed; left: 0; right: 0; bottom: 56px; z-index: 80;
    border-radius: var(--radius-tile) var(--radius-tile) 0 0;
    border: 1px solid var(--mist); max-height: 70vh; display: none;
    box-shadow: var(--shadow-lift);
  }
  .ws-body .controls.sheet-open { display: block; }

  .work { padding-bottom: 76px; }

  /* mobile top action bar (drawer + sheet triggers) */
  .mobile-bar {
    display: flex; gap: 8px; padding: 10px 14px; background: var(--cream);
    border-bottom: 1px solid var(--mist); position: sticky; top: var(--topbar-h); z-index: 40;
  }

  /* bottom nav with geometric marks */
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
    background: var(--paper); border-top: 1px solid var(--mist);
    justify-content: space-around; padding: 6px 4px; height: 56px;
  }
  .bottom-nav a { display: grid; place-items: center; color: var(--ink); flex: 1; border-radius: 12px; }
  .bottom-nav a.active { background: var(--cloud); }
  .bottom-nav a.active svg { filter: none; }
  .bottom-nav svg { width: 24px; height: 24px; }

  .page { padding: 22px 16px; }
  .switcher-panel { width: 92vw; }

  /* drawer scrim */
  .scrim { position: fixed; inset: 0; background: rgba(16,17,20,.4); z-index: 75; }
}

/* grids used on marketing pages */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2,1fr); }
.grid-3 { grid-template-columns: repeat(3,1fr); }
.grid-4 { grid-template-columns: repeat(4,1fr); }
.grid-6 { grid-template-columns: repeat(6,1fr); }
@media (max-width: 900px){ .grid-3,.grid-4,.grid-6 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px){ .grid-2,.grid-3,.grid-4,.grid-6 { grid-template-columns: 1fr; } .grid-6 { grid-template-columns: repeat(3,1fr);} }

.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.wrap { flex-wrap: wrap; }
.mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;} .mt-32{margin-top:32px;}
.mb-8{margin-bottom:8px;} .mb-16{margin-bottom:16px;} .mb-24{margin-bottom:24px;}
.text-center { text-align: center; }
