/* M38 UI Reference — Shared Design Tokens & AppShell Layout */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");
:root {
  color-scheme: light;
  --bg-canvas: #eff4fb;
  --bg-sidebar: #f8faff;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f6f8fc;
  --bg-hover: #ebf1fa;

  --ink: #141e30;
  --ink-2: #334155;
  --muted: #5b6b84;
  --line: #dce4f0;
  --line-strong: #c2cee0;

  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: #e5efff;
  --blue-border: #bfd6fe;

  --ai: #6344e5;
  --ai-hover: #5235cc;
  --ai-soft: #f0edff;
  --ai-border: #cfc3ff;

  --ok: #15803d;
  --ok-soft: #e7f7ed;
  --ok-border: #9fe0b8;

  --warn: #b45309;
  --warn-soft: #fef3c7;
  --warn-border: #f3d27a;

  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --bad-border: #f7b4b4;

  --info: #0284c7;
  --info-soft: #e0f2fe;

  --sidebar-w: 228px;
  --topbar-h: 54px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-card: 0 2px 6px rgba(15, 28, 56, 0.045), 0 1px 2px rgba(15, 28, 56, 0.03);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--ink);
  font: 13px/1.45 var(--font-sans);
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 8px;
  text-decoration: none;
  color: var(--ink);
}
.brand-title { font-size: 13.5px; line-height: 1.15; font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 12px; font-weight: 600; color: var(--muted); }
.brand-edge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.nav-list { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink); }
.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue-hover);
  font-weight: 600;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

/* Right Column */
.workspace-col {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.proj-label { color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.proj-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: 600 13px var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.topbar-search {
  flex: 1.1;
  max-width: 460px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font: 12.5px var(--font-sans);
  color: var(--ink);
}
.ai-cmd-bar {
  flex: 1.1;
  max-width: 460px;
  height: 36px;
  border: 1.5px solid var(--ai-border);
  border-radius: 999px;
  background: #faf9ff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 6px;
  cursor: pointer;
}
.ai-cmd-chip {
  background: linear-gradient(135deg, #7455ff, #4f35d8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.ai-cmd-text { flex: 1; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd {
  font: 600 11px var(--font-mono);
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); }
.avatar-nd {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Main Page Body */
.page-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-title-group { display: flex; align-items: center; gap: 12px; }
.page-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--blue-soft);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.page-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.page-sub { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.screen-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .brand-text, .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .topbar-search { display: none; }
}
@media (max-width: 960px) {
  html, body { height: auto; overflow-y: auto; }
  .app-shell, .workspace-col { height: auto; min-height: 100vh; overflow: visible; }
  .page-wrap { overflow-y: visible; }
}
