/* ============================================================
   Guild — styles.css
   Light bento palette · accent #d97757 · Outfit + Noto Sans SC
   ============================================================ */

:root {
  --bg: #f9fafb;
  --card: #ffffff;
  --ink: #141413;
  --ink-2: #4b4a44;
  --ink-3: #8a887f;
  --line: #e8e6dc;
  --line-2: #eeece4;
  --accent: #d97757;
  --accent-soft: #fbe9e1;
  --green: #788c5d;
  --green-soft: #eef2e7;
  --red: #b8503f;
  --red-soft: #f9e7e4;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Outfit", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 9px;
  --shadow: 0 1px 2px rgba(20,20,19,.04), 0 8px 28px -12px rgba(20,20,19,.10);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.mono { font-family: var(--mono); }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(249,250,251,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-tag { font-size: 11.5px; color: var(--ink-3); border-left: 1px solid var(--line); padding-left: 10px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  border: none; background: transparent; padding: 8px 15px;
  border-radius: 99px; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  transition: all .25s var(--ease);
}
.nav-link:hover { background: var(--line-2); }
.nav-link.active { background: var(--ink); color: #fff; }

/* ---------- views ---------- */
.view { display: none; min-height: calc(100dvh - 62px); animation: viewIn .45s var(--ease); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- home ---------- */
.home-grid {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: 1.25fr .85fr; gap: 56px;
  padding: 72px 32px 60px;
}
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 18px;
}
.home-left h1 {
  font-size: clamp(34px, 4.2vw, 52px); font-weight: 800;
  letter-spacing: -.03em; line-height: 1.14; margin-bottom: 20px;
}
.lede { font-size: 16px; line-height: 1.75; color: var(--ink-2); max-width: 52ch; margin-bottom: 34px; }

.goal-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow);
}
.goal-box label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.goal-box textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 13px 15px; font-size: 14.5px; line-height: 1.6; resize: vertical;
  background: var(--bg); color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.goal-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.goal-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 12px; }
.budget-chip {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3);
  background: var(--bg); border: 1px solid var(--line-2); padding: 8px 14px; border-radius: 99px;
}
.budget-chip strong { color: var(--ink); font-family: var(--mono); font-size: 13px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; border: none;
  font-size: 14px; font-weight: 700; padding: 12px 22px; border-radius: 99px;
  transition: transform .18s var(--ease), box-shadow .18s, background .18s;
  box-shadow: 0 6px 18px -8px rgba(217,119,87,.55);
}
.btn-primary:hover { transform: translateY(-1.5px); background: #c96a4b; }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; padding: 11px 20px; border-radius: 99px;
  transition: all .2s var(--ease);
}
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-danger {
  background: var(--red); color: #fff; border: none;
  font-size: 13.5px; font-weight: 700; padding: 11px 20px; border-radius: 99px;
  transition: all .2s var(--ease);
}
.btn-danger:hover { background: #a34435; }

.sample-goals { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-3); }
.sample {
  border: 1px dashed var(--line); background: transparent; color: var(--ink-2);
  padding: 7px 13px; border-radius: 99px; font-size: 12.5px;
  transition: all .2s var(--ease);
}
.sample:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.home-right { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.principle-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px 20px 16px; position: relative; box-shadow: var(--shadow);
  transition: transform .3s var(--ease);
}
.principle-card:hover { transform: translateX(6px); }
.principle-num { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 500; margin-bottom: 6px; }
.principle-card h3 { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 5px; }
.principle-card p { font-size: 13px; line-height: 1.65; color: var(--ink-2); }

/* ---------- generic panel/page ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.panel-head {
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); padding: 16px 18px 10px; display: flex; align-items: center; gap: 8px;
}
.head-hint { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.page-head {
  max-width: 1240px; margin: 0 auto; padding: 44px 32px 26px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
}
.page-head h2 { font-size: 30px; font-weight: 800; letter-spacing: -.025em; }
.page-head .sub { color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.empty-note { color: var(--ink-3); font-size: 13px; line-height: 1.7; }

/* ---------- workbench ---------- */
.workbench {
  max-width: 1560px; margin: 0 auto;
  display: grid; grid-template-columns: 272px 1fr 360px; gap: 16px;
  padding: 20px 24px 28px; height: calc(100dvh - 62px);
}
.workbench .panel { overflow: hidden; display: flex; flex-direction: column; }

.task-panel { padding-bottom: 16px; overflow-y: auto; }
.task-goal { padding: 2px 18px 12px; font-size: 14.5px; font-weight: 600; line-height: 1.55; }
.task-meta { padding: 0 18px; display: flex; flex-direction: column; gap: 8px; }
.meta-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); }
.meta-row strong { color: var(--ink); font-weight: 600; }
.engine-mode { font-size: 11px; padding: 2px 9px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); }
.engine-mode.llm { background: var(--green-soft); color: var(--green); }
.engine-mode.degraded { background: var(--accent-soft); color: var(--accent); }
.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status-dot.run::before { background: var(--accent); animation: pulse 1.2s infinite; }
.status-dot.done::before { background: var(--green); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .45; transform: scale(.8);} }

.budget-bar { margin: 4px 18px 6px; height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.budget-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #e8a586); border-radius: 99px; transition: width .5s var(--ease); }
.budget-nums { display: flex; justify-content: space-between; padding: 0 18px; font-size: 12px; color: var(--ink-3); }
.budget-nums #budget-spent { color: var(--ink); font-weight: 600; }

.count-pill { background: var(--ink); color: #fff; font-size: 10.5px; padding: 2px 8px; border-radius: 99px; }
.roster { padding: 4px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.roster-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg);
  cursor: pointer; transition: all .2s var(--ease);
  animation: slideIn .4s var(--ease);
}
.roster-item:hover { border-color: var(--accent); }
.roster-item.fired { opacity: .45; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px);} to { opacity: 1; transform: none; } }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; background: var(--ink);
}
.avatar.ceo { background: var(--accent); }
.avatar.fired { background: var(--ink-3); text-decoration: line-through; }
.roster-info { min-width: 0; flex: 1; }
.roster-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-role { font-size: 11px; color: var(--ink-3); }
.roster-status { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 99px; }
.st-working { background: var(--accent-soft); color: var(--accent); }
.st-done { background: var(--green-soft); color: var(--green); }
.st-fired { background: var(--red-soft); color: var(--red); }

/* graph */
.graph-panel { position: relative; }
.graph-wrap { flex: 1; position: relative; }
.graph-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: var(--ink-3); font-size: 13px;
}
.graph-empty.hidden { display: none; }
#org-graph { display: block; }
.node { cursor: pointer; }
.node circle.body { transition: all .25s var(--ease); }
.node:hover circle.body { stroke-width: 2.6; }
.node-label { font-size: 11px; font-weight: 700; fill: var(--ink); }
.node-sub { font-size: 9.5px; fill: var(--ink-3); }
.node-status-working { animation: pulse 1.4s infinite; }
.edge { stroke: var(--line); stroke-width: 1.6; fill: none; }
.edge.new { stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw .7s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.agent-drawer {
  position: absolute; right: 14px; bottom: 14px; width: 320px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 12px 44px -12px rgba(20,20,19,.22);
  padding: 18px; transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: all .35s var(--ease); z-index: 5; max-height: 72%; overflow-y: auto;
}
.agent-drawer.open { transform: none; opacity: 1; pointer-events: auto; }
.drawer-close {
  position: absolute; top: 10px; right: 12px; border: none; background: transparent;
  font-size: 20px; color: var(--ink-3); line-height: 1;
}
.drawer-close:hover { color: var(--ink); }
.drawer-name { font-size: 16px; font-weight: 800; letter-spacing: -.01em; padding-right: 20px; }
.drawer-role { font-size: 12px; color: var(--accent); font-weight: 700; margin: 3px 0 12px; }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); color: var(--ink-3); }
.kv strong { color: var(--ink); font-weight: 600; text-align: right; max-width: 60%; }
.drawer-output { margin-top: 10px; font-size: 12.5px; line-height: 1.65; color: var(--ink-2); background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }
.progress-line { height: 5px; background: var(--line-2); border-radius: 99px; margin: 12px 0 4px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s var(--ease); }

/* timeline */
.timeline-panel { display: flex; flex-direction: column; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
.timeline { flex: 1; overflow-y: auto; padding: 4px 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: flex; gap: 10px; animation: slideIn .35s var(--ease); }
.tl-time { font-family: var(--mono); font-size: 10px; color: var(--ink-3); padding-top: 9px; flex-shrink: 0; width: 52px; }
.tl-body { flex: 1; min-width: 0; }
.tl-actor { font-size: 11px; font-weight: 800; margin-bottom: 2px; }
.tl-actor.CEO { color: var(--accent); }
.tl-actor.System { color: var(--ink-3); }
.tl-actor.User { color: var(--green); }
.tl-text { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); word-break: break-word; }
.tl-item.kind-hire .tl-text { color: var(--ink); font-weight: 600; }
.tl-item.kind-warn .tl-text { color: var(--red); }
.tl-item.kind-output .tl-text { background: var(--bg); border-left: 2.5px solid var(--green); padding: 7px 10px; border-radius: 0 8px 8px 0; }
.tl-item.kind-final .tl-text { background: var(--accent-soft); border-left: 2.5px solid var(--accent); padding: 8px 11px; border-radius: 0 8px 8px 0; color: var(--ink); font-weight: 700; }
.tl-item.kind-user .tl-text { background: var(--green-soft); padding: 8px 11px; border-radius: 8px; color: var(--ink); font-weight: 600; }
.tl-protocol {
  margin-top: 6px; background: #1d1c1a; color: #d8d4c8; border-radius: var(--r-sm);
  padding: 10px 12px; font-family: var(--mono); font-size: 10.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.tl-protocol .k { color: #e8a586; }

/* ---------- market ---------- */
.market-grid {
  max-width: 1240px; margin: 0 auto; padding: 0 32px 60px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px;
}
.agent-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
  transition: transform .25s var(--ease), border-color .25s;
}
.agent-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.ac-head { display: flex; gap: 12px; align-items: center; }
.ac-head .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }
.ac-name { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.ac-role { font-size: 12px; color: var(--accent); font-weight: 700; }
.ac-known { font-size: 12px; color: var(--ink-3); font-style: italic; }
.ac-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ac-stat { background: var(--bg); border-radius: var(--r-sm); padding: 8px 6px; text-align: center; }
.ac-stat b { display: block; font-size: 13.5px; font-family: var(--mono); font-weight: 600; }
.ac-stat span { font-size: 10px; color: var(--ink-3); }
.ac-skills { display: flex; flex-wrap: wrap; gap: 5px; }
.skill-tag { font-size: 10.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); padding: 3px 9px; border-radius: 99px; }
.ac-reviews { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.ac-review { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }
.ac-review .stars { color: var(--accent); font-size: 10px; letter-spacing: 1px; }
.ac-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.ac-price { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.ac-price span { font-size: 10.5px; color: var(--ink-3); font-family: var(--sans); }

/* ---------- evolution ---------- */
.evo-grid {
  max-width: 1240px; margin: 0 auto; padding: 0 32px 60px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.evo-card.wide { grid-column: 1 / -1; }
.evo-bars { padding: 6px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.evo-bar-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; font-size: 12.5px; }
.evo-bar-row .bar { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.evo-bar-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; animation: grow .9s var(--ease); }
@keyframes grow { from { width: 0; } }
.evo-bar-row .val { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--ink-2); }
.evo-versions { padding: 10px 22px 24px; display: flex; gap: 18px; overflow-x: auto; }
.version-card {
  flex-shrink: 0; border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; background: var(--bg); min-width: 168px;
}
.version-card.current { border-color: var(--accent); background: var(--accent-soft); }
.version-tag { font-family: var(--mono); font-size: 10.5px; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.version-tree { font-family: var(--mono); font-size: 11px; line-height: 1.7; color: var(--ink-2); white-space: pre; }

/* ---------- constitution ---------- */
.constitution-panel { max-width: 720px; margin: 0 auto; padding: 8px 0 16px; }
.rule-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px 26px; border-bottom: 1px solid var(--line-2);
}
.rule-row strong { font-size: 14.5px; }
.rule-row p { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.rule-row input {
  width: 90px; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 14px; font-family: var(--mono); text-align: center;
  background: var(--bg); outline: none; transition: border-color .2s;
}
.rule-row input:focus { border-color: var(--accent); }
.rule-note { padding: 14px 26px 4px; font-size: 12px; color: var(--ink-3); }

/* ---------- modals ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,20,19,.34);
  backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.open { display: flex; animation: fadeIn .25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  display: none; background: var(--card); border-radius: var(--r-lg); padding: 28px;
  width: min(460px, calc(100vw - 40px)); box-shadow: 0 24px 70px -18px rgba(20,20,19,.4);
  animation: pop .35s var(--ease);
}
.modal.open { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal h3 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.modal p { font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.modal-icon { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-actions.three { justify-content: stretch; }
.modal-actions.three button { flex: 1; }
.form-block { margin-top: 14px; }
.form-block label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.form-block input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 13px; font-size: 13.5px; background: var(--bg); outline: none;
}
.form-block input:focus { border-color: var(--accent); }

.report-modal { width: min(560px, calc(100vw - 40px)); }
.report-score { display: flex; align-items: center; gap: 20px; margin: 16px 0; }
.score-ring {
  width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line-2) 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 7px; background: var(--card); border-radius: 50%; }
.score-ring span { position: relative; font-family: var(--mono); font-size: 20px; font-weight: 600; }
.report-stats { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.report-stats b { font-family: var(--mono); }
.report-body { list-style: none; display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.report-body li {
  font-size: 13.5px; line-height: 1.65; color: var(--ink-2);
  padding-left: 18px; position: relative;
}
.report-body li::before {
  content: ""; position: absolute; left: 0; top: 9px;
  width: 7px; height: 7px; border-radius: 2px; background: var(--accent);
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .workbench { grid-template-columns: 240px 1fr; height: auto; }
  .timeline-panel { grid-column: 1 / -1; max-height: 420px; }
}
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; padding: 44px 20px; gap: 36px; }
  .workbench { grid-template-columns: 1fr; padding: 14px; }
  .graph-wrap { min-height: 380px; }
  .evo-grid { grid-template-columns: 1fr; padding: 0 20px 40px; }
  .page-head { flex-direction: column; align-items: flex-start; padding: 32px 20px 20px; }
  .market-grid { padding: 0 20px 40px; }
  .nav-links { overflow-x: auto; }
  .brand-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
