/* ==========================================================================
   WaytoAGI · Agent Workbench — Notion 风格（见仓库根目录 DESIGN.md）
   --------------------------------------------------------------------------
   暖白侧栏、白色工作区、近黑文字、单一品牌橙强调；全部使用系统字体
   （macOS 苹方）。令牌名沿用 --ln-*，场景应用的样式也依赖它们；
   不要在组件里写死颜色。公众号成稿预览（.wx-*）是成品的样子，不受这里约束。
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* ---- Surfaces: warm paper sidebar, white work area ---- */
  --ln-bg-sidebar: #f6f5f4;
  --ln-bg-app: #ffffff;
  --ln-bg-surface: #fbfbfa;
  --ln-bg-elevated: #ffffff;
  --ln-bg-hover: #efeeec;
  --ln-bg-active: #e9e8e6;
  --ln-bg-control: #ffffff;
  --ln-bg-control-hover: #f6f5f4;

  /* ---- Hairlines ---- */
  --ln-border: #e6e6e6;
  --ln-border-subtle: #efefef;
  --ln-border-strong: #d9d8d6;

  /* ---- Ink ---- */
  --ln-text-primary: #191919;
  --ln-text-secondary: #31302e;
  --ln-text-tertiary: #615d59;
  --ln-text-inverse: #ffffff;

  /* ---- Brand: WaytoAGI orange. #ff4900 for the mark; a deeper shade for
     buttons and links so white/regular text keeps 4.5:1 contrast. ---- */
  --ln-brand: #ff4900;
  --ln-accent: #d93e00;
  --ln-accent-hover: #b83500;
  --ln-accent-soft: #ffefe6;

  --sem-ok-fg: #1f7a3a;
  --sem-ok-bg: #e7f5ea;
  --sem-warn-fg: #b25000;
  --sem-warn-bg: #fcefe3;
  --sem-err-fg: #c4352b;
  --sem-err-bg: #fbe9e7;

  /* ---- Legacy Alias Tokens (for JS compatibility) ---- */
  --n-bg-page: var(--ln-bg-sidebar);
  --n-bg-card: var(--ln-bg-app);
  --n-bg-soft: var(--ln-bg-surface);
  --n-bg-hover: var(--ln-bg-hover);
  --n-line: var(--ln-border);
  --n-line-strong: var(--ln-border-strong);
  --n-text-1: var(--ln-text-primary);
  --n-text-2: var(--ln-text-secondary);
  --n-text-3: var(--ln-text-tertiary);
  --n-text-4: var(--ln-text-tertiary);

  /* ---- Font Stacks: system fonts only (PingFang SC on macOS) ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ln-bg-sidebar: #202020;
    --ln-bg-app: #191919;
    --ln-bg-surface: #222222;
    --ln-bg-elevated: #252525;
    --ln-bg-hover: #2c2c2c;
    --ln-bg-active: #333333;
    --ln-bg-control: #252525;
    --ln-bg-control-hover: #2f2f2f;

    --ln-border: #2f2f2f;
    --ln-border-subtle: #262626;
    --ln-border-strong: #3a3a3a;

    --ln-text-primary: #e9e9e7;
    --ln-text-secondary: #c4c4c2;
    --ln-text-tertiary: #9b9a97;
    --ln-text-inverse: #191919;

    --ln-brand: #ff4900;
    --ln-accent: #ff6a2b;
    --ln-accent-hover: #ff8a57;
    --ln-accent-soft: #3a2418;

    --sem-ok-fg: #5bbd72;
    --sem-ok-bg: #1f2e23;
    --sem-warn-fg: #e8964f;
    --sem-warn-bg: #33261a;
    --sem-err-fg: #ef7a6f;
    --sem-err-bg: #3a2220;
  }
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ln-bg-app);
  color: var(--ln-text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  color: var(--ln-text-primary);
}

p {
  margin: 4px 0;
}

.muted {
  color: var(--ln-text-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

.caption {
  font-size: 11px;
  font-weight: 500;
  color: var(--ln-text-tertiary);
}

.ln-truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   1. Linear Auth Screen (#login)
   ========================================================================== */
.ln-auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ln-bg-sidebar);
  padding: 24px;
}

.ln-auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--ln-bg-app);
  border: 1px solid var(--ln-border);
  border-radius: 10px;
  padding: 28px 24px;
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.06);
}

.ln-auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.ln-logo-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--ln-brand);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ln-brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ln-text-primary);
}

.ln-brand-sub {
  font-size: 12px;
  color: var(--ln-text-tertiary);
}

/* ==========================================================================
   2. Full-Viewport Linear App Shell (.ln-shell)
   ========================================================================== */
.ln-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--ln-bg-app);
}

/* ---- Left Sidebar Rail (228px) ---- */
.ln-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ln-bg-sidebar);
  border-right: 1px solid var(--ln-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  user-select: none;
}

.ln-sidebar-header {
  min-height: 44px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--ln-border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
}

.ln-sidebar-header .badge {
  white-space: nowrap;
}

.ln-ws-ident {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ln-ws-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ln-ws-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ln-text-primary);
  line-height: 1.2;
}

.ln-ws-user {
  font-size: 11px;
  color: var(--ln-text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ln-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ln-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ln-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ln-text-tertiary);
}

.ln-new-proj-drawer {
  padding: 8px;
  margin: 2px 0 6px;
  background: var(--ln-bg-app);
  border: 1px solid var(--ln-border);
  border-radius: 6px;
}

.ln-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ln-nav-item,
#projects > li {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 8px;
  width: 100%;
  height: auto;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ln-text-secondary);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background 100ms var(--ease), color 100ms var(--ease);
}

.ln-nav-item:hover:not(:disabled),
#projects > li:hover {
  background: var(--ln-bg-hover);
  color: var(--ln-text-primary);
}

.ln-nav-item.active,
.ln-nav-item.active:hover:not(:disabled),
#projects > li.active-project {
  background: var(--ln-bg-active);
  color: var(--ln-text-primary);
  font-weight: 600;
}

.ln-nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ln-border-strong);
  flex-shrink: 0;
}

.ln-nav-item.active .ln-nav-dot,
.ln-dot-accent {
  background: var(--ln-accent);
}

.ln-dot-ok {
  background: var(--sem-ok-fg);
}

.ln-dot-warn {
  background: var(--sem-warn-fg);
}

/* Sidebar Project Item specifics */
.ln-proj-badge {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--ln-accent-soft);
  color: var(--ln-accent);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ln-proj-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.ln-proj-role {
  font-size: 12px;
  color: var(--ln-text-tertiary);
}

/* Sidebar Footer: Personal DSH Runtime Dock */
.ln-runtime-dock {
  padding: 10px 12px;
  border-top: 1px solid var(--ln-border);
  background: var(--ln-bg-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ln-dock-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ln-text-primary);
}

.ln-dock-meta {
  margin: 0;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ln-dock-actions {
  display: flex;
  gap: 4px;
}

.ln-dock-actions > * {
  flex: 1;
  justify-content: center;
}

/* ==========================================================================
   3. Main Workspace Area (.ln-main & .ln-topbar)
   ========================================================================== */
.ln-main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ln-bg-app);
}

.ln-topbar {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--ln-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--ln-bg-app);
}

.ln-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.ln-crumb-root {
  color: var(--ln-text-tertiary);
  font-weight: 500;
}

.ln-crumb-sep {
  color: var(--ln-border-strong);
}

.ln-crumb-current {
  font-size: 15px;
  font-weight: 600;
  color: var(--ln-text-primary);
}

.ln-workspace-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ln-banner-err:not(:empty) {
  margin: 0;
  padding: 6px 16px;
  border-bottom: 1px solid var(--ln-border);
}

.ln-panel-fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ln-panel-pad {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ---- Linear Segmented Control (.ln-segmented) ---- */
.ln-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--ln-bg-sidebar);
  border: 1px solid var(--ln-border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.ln-segmented .chip {
  flex: 1;
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ln-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 100ms var(--ease);
}

.ln-segmented .chip:hover:not(:disabled) {
  background: transparent;
  color: var(--ln-text-primary);
}

.ln-segmented .chip.active,
.ln-segmented .chip.active:hover:not(:disabled) {
  background: var(--ln-bg-elevated);
  color: var(--ln-text-primary);
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.06);
}

/* ==========================================================================
   5. Linear Property Sections & Immersive Markdown Editor
   ========================================================================== */
.ln-section {
  padding: 0 0 16px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--ln-border-subtle);
}

.ln-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.ln-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ln-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ln-text-primary);
}

.ln-surface-box,
.subcard {
  background: var(--ln-bg-surface);
  border: 1px solid var(--ln-border);
  border-radius: 6px;
  padding: 12px;
}

/* ==========================================================================
   6. Controls: Buttons, Inputs, Tags, Lists
   ========================================================================== */
.row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ln-text-primary);
  background: var(--ln-bg-control);
  border: 1px solid var(--ln-border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 100ms var(--ease), border-color 100ms var(--ease);
}

button:hover:not(:disabled),
.button:hover {
  background: var(--ln-bg-control-hover);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary,
.btn-brand,
.btn-lime {
  background: var(--ln-accent);
  color: var(--ln-text-inverse);
  border-color: transparent;
}

.btn-primary:hover:not(:disabled),
.btn-brand:hover:not(:disabled),
.btn-lime:hover:not(:disabled) {
  background: var(--ln-accent-hover);
  border-color: transparent;
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
}

.btn-xs,
.btn-icon {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 6px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ln-text-primary);
  background: var(--ln-bg-elevated);
  border: 1px solid var(--ln-border-strong);
  border-radius: 4px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  border-color: var(--ln-accent);
  box-shadow: 0 0 0 2px var(--ln-accent-soft);
}

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.6;
}

.full-input {
  width: 100%;
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ln-text-secondary);
  margin: 10px 0 4px;
}

/* ---- Badges & Tags ---- */
.badge,
.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--ln-accent-soft);
  color: var(--ln-accent);
  border: none;
}

.tag-green {
  background: var(--sem-ok-bg);
  color: var(--sem-ok-fg);
  border-color: transparent;
}

.tag-lime {
  background: var(--ln-accent-soft);
  color: var(--ln-accent);
  border-color: transparent;
}

.tag-red {
  background: var(--sem-err-bg);
  color: var(--sem-err-fg);
  border-color: transparent;
}

.err:not(:empty) {
  color: var(--sem-err-fg);
  background: var(--sem-err-bg);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

.warn:not(:empty) {
  color: var(--sem-warn-fg);
  background: var(--sem-warn-bg);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

/* ---- Generic List Items (Artifacts, Sessions, Members) ---- */
ul, ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--ln-border-subtle);
  border-radius: 6px;
  transition: background 100ms var(--ease);
}

.list-item:hover {
  background: var(--ln-bg-hover);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.stamp-44 {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--ln-bg-surface);
  border: 1px solid var(--ln-border);
  color: var(--ln-text-secondary);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stamp-green {
  background: var(--sem-ok-bg);
  color: var(--sem-ok-fg);
  border-color: transparent;
}

.item-body {
  min-width: 0;
  flex: 1;
}

.item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ln-text-primary);
  text-decoration: none;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: 12px;
  color: var(--ln-text-tertiary);
  margin-top: 1px;
}


pre {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--ln-bg-surface);
  border: 1px solid var(--ln-border);
  border-radius: 6px;
  padding: 12px;
  margin: 6px 0;
  max-height: 260px;
  overflow: auto;
  color: var(--ln-text-secondary);
}

.step-done { color: var(--ln-text-tertiary); }
.step-open { color: var(--sem-err-fg); font-weight: 600; }

/* File picker: the native control is hidden behind a labelled button. */
.file-pick {
  position: relative;
  overflow: hidden;
  max-width: 320px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-pick input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Scenario app links in the sidebar */
.ln-app-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ln-text-secondary);
  text-decoration: none;
}
.ln-app-link:hover {
  background: var(--ln-bg-hover);
  color: var(--ln-text-primary);
}

/* ---- Layout utilities (CSP style-src 'self' safe) ---- */
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.flex-1 { flex: 1; }
.sec-title-sm { font-size: 12px; }

@media (max-width: 900px) {
  .ln-shell {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .ln-sidebar {
    width: 100%;
    height: auto;
  }
  .ln-main {
    height: auto;
  }
}
