/* =================================================================
   SACRED STUDIOS — App Layout, Components, Views
   ================================================================= */

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
  position: relative;
}
/* Internal-build signal: a brighter-red hairline pinned to the very top edge,
   above every layer (drawers, toasts) so you always know this is the Studio. */
.app::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: var(--internal); box-shadow: 0 0 14px var(--internal-glow);
  z-index: 200; pointer-events: none;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, rgba(31,31,35,0.96), rgba(24,24,27,0.96));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px 12px 18px;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 16px;
}
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--text-1);
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(196, 18, 48, 0.45));
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; line-height: 1.15; color: var(--internal-ink); }
.brand-sub { font-size: 10px; color: var(--text-3); letter-spacing: 1.5px; text-transform: uppercase; font-family: var(--font-mono); }
.brand-tag {
  display: inline-block; margin-top: 4px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--internal-ink); background: var(--internal);
  padding: 1px 7px; border-radius: 5px; line-height: 1.6;
  box-shadow: 0 0 12px var(--internal-glow);
}

.nav-group { margin-top: 8px; }
.nav-group-label {
  display: flex; align-items: center; gap: 7px; width: 100%;
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-3); padding: 6px 12px; font-weight: 600;
  font-family: var(--font-mono); cursor: pointer; border-radius: var(--radius-sm);
  transition: color .14s var(--ease), background .14s var(--ease);
}
.nav-group-label:hover { color: var(--text-2); background: var(--bg-2); }
.ngl-text { flex: 1; text-align: left; }
.ngl-caret { font-size: 9px; opacity: .55; transition: transform .16s var(--ease); }
.nav-group.collapsed .ngl-caret { transform: rotate(-90deg); }
.ngl-count { padding: 0 6px; min-width: 16px; }
.nav-group-label .nav-dot { position: static; margin: 0; }
.nav-group-items { display: flex; flex-direction: column; gap: 1px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .16s var(--ease), color .16s var(--ease);
  position: relative; width: 100%; text-align: left;
}
.nav-item .nv-ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-item:hover { background: var(--bg-2); color: var(--text-0); }
.nav-item.active { background: var(--internal-wash); color: var(--text-0); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 99px; background: var(--internal); box-shadow: 0 0 10px var(--internal-glow);
}
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700;
  background: var(--accent-3); color: #fff;
  padding: 1px 7px; border-radius: 99px; min-width: 18px; text-align: center;
}
.nav-badge.warn { background: var(--ember-2); }

.sidebar-foot { margin-top: auto; padding: 12px 8px 2px; }
/* Settings pinned above the account chip — divider sets it apart from the nav groups */
.nav-foot { padding-top: 8px; margin-bottom: 8px; border-top: 1px solid var(--border); }
.nav-foot .nav-foot-item { color: var(--text-2); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: #fff; flex-shrink: 0;
}

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

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}
.topbar h1 { font-size: 16px; font-weight: 650; }
.topbar .crumb { color: var(--text-3); font-size: 12.5px; }
.spacer { flex: 1; }

.sage-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--radius-pill);
  background: var(--grad-sacred); color: #fff; font-weight: 650; font-size: 13px;
  box-shadow: var(--shadow-glow);
  transition: transform .15s var(--ease-bounce), filter .15s var(--ease);
}
.sage-btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.sage-btn kbd {
  background: rgba(0,0,0,0.22); padding: 1px 6px; border-radius: 5px;
  font-size: 11px; font-family: var(--font-mono); font-weight: 700;
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--border); background: var(--bg-2);
  transition: all .15s var(--ease); font-size: 16px;
}
.icon-btn:hover { color: var(--text-0); border-color: var(--border-strong); }

.view-scroll { flex: 1; overflow-y: auto; padding: 26px 24px 80px; }
.view-inner { max-width: var(--maxw); margin: 0 auto; }

/* ---------- Generic UI ---------- */
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.section-head h2 { font-size: 19px; font-weight: 680; }
.section-head .sub { color: var(--text-3); font-size: 13px; }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .16s var(--ease), transform .16s var(--ease);
}
.card.hover:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; transition: all .15s var(--ease);
  border: 1px solid var(--border-strong); color: var(--text-1); background: var(--bg-2);
}
.btn:hover { color: var(--text-0); border-color: var(--accent-3); }
.btn.primary { background: var(--grad-sacred); color: #fff; border: none; box-shadow: var(--shadow-glow); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 650; padding: 3px 10px;
  border-radius: var(--radius-pill); background: var(--bg-3); color: var(--text-1);
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- Stat cards ---------- */
.stat {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%; background: var(--grad-soft); opacity: .5;
}
.stat .label { font-size: 12px; color: var(--text-3); font-weight: 600; letter-spacing: .3px; }
.stat .value { font-size: 27px; font-weight: 760; margin-top: 4px; letter-spacing: -.5px; }
.stat .delta { font-size: 12px; font-weight: 650; margin-top: 3px; }
.delta.up { color: var(--emerald); }
.delta.down { color: var(--crimson); }

/* ---------- Dashboard focus block ---------- */
.focus {
  background: linear-gradient(135deg, rgba(196,18,48,0.16), rgba(200,161,88,0.10)), var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.focus .eyebrow { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.focus .headline { font-size: 22px; font-weight: 720; margin: 6px 0 4px; }
.focus .meta { color: var(--text-2); font-size: 13px; }

/* ---------- Briefing list ---------- */
.brief-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.brief-item:last-child { border-bottom: none; }
.brief-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); width: 58px; flex-shrink: 0; padding-top: 1px; }
.brief-body .t { font-weight: 600; font-size: 13.5px; }
.brief-body .s { color: var(--text-3); font-size: 12px; }

/* ---------- Empty / placeholder views ---------- */
.placeholder { display: grid; place-items: center; min-height: 56vh; text-align: center; }
.placeholder .ph-card {
  max-width: 560px; padding: 40px 38px; border-radius: var(--radius-lg);
  background: var(--bg-1); border: 1px solid var(--border);
}
.placeholder .ph-ico {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px;
  display: grid; place-items: center; font-size: 30px;
  background: var(--grad-soft); border: 1px solid var(--border-strong);
}
.placeholder h2 { font-size: 22px; font-weight: 720; }
.placeholder p { color: var(--text-2); margin-top: 8px; font-size: 14px; line-height: 1.65; }
.placeholder .phase-tag {
  display: inline-block; margin-top: 18px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .5px; color: var(--accent); padding: 5px 13px;
  border-radius: 99px; background: var(--grad-soft); border: 1px solid var(--border-strong);
}
.feat-list { text-align: left; margin: 20px auto 0; max-width: 420px; display: grid; gap: 9px; }
.feat-list li { list-style: none; display: flex; gap: 10px; color: var(--text-1); font-size: 13px; }
.feat-list .chk { color: var(--accent); flex-shrink: 0; }

/* ---------- Strengths Radar ---------- */
.radar-wrap { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px; align-items: start; }
@media (max-width: 880px) { .radar-wrap { grid-template-columns: 1fr; } }

.radar-stage {
  background: radial-gradient(circle at 50% 45%, rgba(196,18,48,0.10), transparent 70%), var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; display: grid; place-items: center; position: relative;
}
.ovr-badge {
  position: absolute; top: 16px; left: 16px; text-align: center;
  background: var(--bg-glass-strong); border: 1px solid var(--border-strong);
  padding: 8px 14px; border-radius: var(--radius); backdrop-filter: blur(8px);
}
.ovr-badge .n { font-size: 30px; font-weight: 820; letter-spacing: -1px; line-height: 1; }
.ovr-badge .l { font-size: 10px; letter-spacing: 1.5px; color: var(--text-3); text-transform: uppercase; margin-top: 2px; }

.attr-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.attr-row:last-child { border-bottom: none; }
.attr-name { width: 150px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.attr-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--bg-3); overflow: hidden; }
.attr-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--grad-sacred); transition: width 1s var(--ease-bounce); }
.attr-score { width: 34px; text-align: right; font-weight: 750; font-size: 14px; font-family: var(--font-mono); }
.attr-meta { width: 90px; text-align: right; font-size: 11px; color: var(--text-3); }

/* ---------- Sage drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(10,8,14,0.55);
  backdrop-filter: blur(3px); z-index: 80; opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.sage-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 92vw;
  background: var(--bg-1); border-left: 1px solid var(--border-strong);
  z-index: 81; transform: translateX(100%); transition: transform .26s var(--ease);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.sage-drawer.open { transform: translateX(0); }
.sage-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.sage-orb {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad-sacred); box-shadow: var(--shadow-glow);
  display: grid; place-items: center; font-size: 18px;
  animation: pulse 3.4s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 22px var(--accent-glow); } 50% { box-shadow: 0 0 40px var(--ember-glow); } }
.sage-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.sage-msg { padding: 12px 15px; border-radius: var(--radius); font-size: 13.5px; line-height: 1.6; max-width: 88%; }
.sage-msg.bot { background: var(--bg-2); border: 1px solid var(--border); align-self: flex-start; }
.sage-msg.me { background: var(--grad-soft); align-self: flex-end; }
.sage-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.sage-foot input {
  flex: 1; background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill); padding: 11px 16px; color: var(--text-0); font-size: 13.5px; outline: none;
}
.sage-foot input:focus { border-color: var(--accent-3); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-glass-strong); border: 1px solid var(--border-strong);
  padding: 11px 18px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md); backdrop-filter: blur(10px); animation: toastIn .25s var(--ease-bounce);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 80vw; max-width: 300px; z-index: 70; transform: translateX(-100%); transition: transform .24s var(--ease); }
  .sidebar.open { transform: none; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .view-scroll { padding: 18px 14px 80px; }
}
.menu-toggle { display: none; }
@media (max-width: 760px) { .menu-toggle { display: grid; } }
