:root {
  --paper: #f6f1e7;
  --surface: #fffdf8;
  --ink: #23231f;
  --muted: #77756c;
  --line: #ded8ca;
  --orange: #e66a35;
  --orange-soft: #f7d8c5;
  --green: #277f68;
  --green-soft: #d9ebe3;
  --blue: #4e6e96;
  --blue-soft: #dce6f0;
  --shadow: 0 18px 50px rgba(47, 43, 34, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: .01em;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 18px; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  color: white; background: var(--ink); font-family: Georgia, serif; font-size: 14px;
}
.welcome {
  min-height: 100vh; padding: 48px clamp(24px, 7vw, 110px);
  display: grid; grid-template: auto 1fr / minmax(0, 1.2fr) minmax(320px, 440px);
  column-gap: 8vw; align-items: center; position: relative;
}
.welcome::before {
  content: ""; position: absolute; width: 40vw; height: 40vw; max-width: 600px; max-height: 600px;
  border: 1px solid #d8cbbb; border-radius: 50%; left: -22vw; bottom: -18vw;
  box-shadow: 0 0 0 80px rgba(255,255,255,.18), 0 0 0 160px rgba(255,255,255,.1);
}
.welcome > .brand { grid-column: 1 / -1; align-self: start; }
.welcome-copy { max-width: 700px; position: relative; z-index: 1; }
.eyebrow { color: var(--orange); font-weight: 800; letter-spacing: .15em; font-size: 10px; }
.welcome h1 {
  margin: 18px 0 24px; font-family: Georgia, "STSong", serif;
  font-size: clamp(44px, 5.4vw, 80px); line-height: 1.08; letter-spacing: -.045em; font-weight: 500;
}
.welcome-copy > p:last-child { color: var(--muted); font-size: 17px; line-height: 1.9; max-width: 590px; }
.join-card {
  position: relative; z-index: 2; display: grid; gap: 20px; background: rgba(255,253,248,.91);
  border: 1px solid rgba(214,205,190,.9); padding: 36px; border-radius: 24px; box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.join-card label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; }
.join-card label span { color: var(--muted); font-weight: 400; float: right; }
.join-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px;
  color: var(--ink); background: white; outline: none; transition: .2s;
}
.join-card input:focus, .composer textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(230,106,53,.12); }
.join-card button {
  display: flex; justify-content: space-between; border: 0; border-radius: 12px; padding: 15px 18px;
  background: var(--ink); color: white; font-weight: 700; margin-top: 4px;
}
.form-error { color: #b23828; min-height: 18px; margin: -8px 0 0; font-size: 12px; }
.room-shell { min-height: 100vh; position: relative; }
.topbar {
  height: 78px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 28px; background: rgba(246,241,231,.88); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px);
}
.brand.compact .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.room-title { display: flex; align-items: center; gap: 10px; }
.room-title small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.room-title strong { font-size: 15px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 11px; }
.ghost-button { border: 1px solid var(--line); border-radius: 8px; background: transparent; padding: 7px 11px; color: var(--ink); }
.workspace { display: grid; grid-template-columns: 250px minmax(380px, 1fr) 360px; min-height: calc(100vh - 78px); }
.people-panel, .conversation-panel, .work-panel { min-width: 0; padding: 26px; }
.people-panel { border-right: 1px solid var(--line); }
.work-panel { border-left: 1px solid var(--line); background: rgba(255,253,248,.35); }
.conversation-panel { display: flex; flex-direction: column; max-height: calc(100vh - 78px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.panel-heading h2 { font-family: Georgia, "STSong", serif; font-weight: 500; font-size: 21px; margin: 5px 0 0; }
.count, .sequence { border: 1px solid var(--line); border-radius: 99px; padding: 5px 9px; color: var(--muted); font-size: 10px; }
.member-group { margin-bottom: 24px; }
.member-group-title { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; margin-bottom: 9px; }
.member { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.avatar.human, .legend-icon.human { color: #8d481f; background: var(--orange-soft); }
.avatar.agent, .legend-icon.agent { color: #25566f; background: var(--blue-soft); }
.avatar.node, .legend-icon.node { color: #1e6856; background: var(--green-soft); }
.member-copy { min-width: 0; flex: 1; }
.member-copy b { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.member-copy small { color: var(--muted); font-size: 10px; }
.online { width: 7px; height: 7px; border-radius: 50%; background: #bcb8ae; }
.online.yes { background: var(--green); }
.legend { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 32px; display: grid; gap: 13px; }
.legend > div { display: flex; gap: 10px; align-items: center; }
.legend-icon { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.legend p { margin: 0; }
.legend b, .legend small { display: block; font-size: 10px; }
.legend small { color: var(--muted); margin-top: 2px; }
.conversation-heading { margin-bottom: 10px; }
.messages { flex: 1; overflow: auto; padding: 14px 4px 24px; scrollbar-width: thin; }
.empty-state { text-align: center; color: var(--muted); margin: 15vh auto 0; }
.empty-state span { font-size: 28px; color: var(--orange); }
.empty-state p { margin: 12px 0 4px; color: var(--ink); font-family: Georgia, serif; font-size: 18px; }
.empty-state small { font-size: 11px; }
.message { display: grid; grid-template-columns: 36px 1fr; gap: 11px; margin: 18px 0; }
.message .avatar { width: 36px; height: 36px; }
.message-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.message-head b { font-size: 12px; }
.message-head time { color: var(--muted); font-size: 9px; }
.message-body { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 13px; box-shadow: 0 8px 25px rgba(43,39,30,.06); }
.composer textarea { border: 0; resize: none; width: 100%; min-height: 48px; outline: none; background: transparent; color: var(--ink); line-height: 1.5; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 9px; }
.composer-footer button { border: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--orange); color: white; font-size: 20px; }
.approval-card { border: 1px solid #d89d76; background: #fff6ed; border-radius: 14px; padding: 15px; margin-bottom: 18px; }
.approval-label { display: flex; justify-content: space-between; color: #a65328; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.approval-card h3 { font-size: 13px; margin: 11px 0 7px; line-height: 1.4; }
.approval-card p { color: var(--muted); font-size: 10px; margin: 0 0 13px; word-break: break-all; }
.approval-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.approval-actions button { border: 0; border-radius: 8px; padding: 9px; font-size: 11px; font-weight: 700; }
.deny { color: #8d3e30; background: #f2ddd7; }
.approve { color: white; background: var(--green); }
.task-card { border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 14px; margin-bottom: 10px; }
.task-card.child { margin-left: 15px; border-left: 3px solid var(--blue); }
.task-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; }
.status { text-transform: uppercase; font-weight: 800; color: var(--blue); }
.status.completed { color: var(--green); }
.status.blocked, .status.failed { color: #b44a35; }
.task-card h3 { margin: 9px 0 10px; font-size: 12px; line-height: 1.55; }
.task-people { display: flex; flex-wrap: wrap; gap: 5px; }
.task-people span { padding: 4px 6px; background: #eee9df; border-radius: 6px; font-size: 9px; color: var(--muted); }
.review { border-top: 1px dashed var(--line); margin-top: 11px; padding-top: 9px; font-size: 9px; color: var(--orange); }
.task-evidence { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; display: grid; gap: 3px; }
.task-evidence span { color: var(--green); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-label { margin: 28px 0 10px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.action-card { border-bottom: 1px solid var(--line); padding: 11px 2px; }
.action-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.action-head b { font-size: 11px; }
.action-head .status { font-size: 8px; }
.action-card p { margin: 5px 0; color: var(--muted); font-size: 9px; }
.action-card small { color: var(--green); font-size: 9px; line-height: 1.5; }
.artifacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.artifacts span { background: var(--blue-soft); color: var(--blue); border-radius: 5px; padding: 4px 6px; font-size: 8px; word-break: break-all; }
.action-error { margin-top: 7px; padding: 6px; border-radius: 6px; color: #a13c2c; background: #f4ded8; font-size: 9px; }
.empty-mini { border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 11px; text-align: center; padding: 24px 15px; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 15px; border-radius: 10px; font-size: 11px; transition: .25s; z-index: 30; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 210px minmax(360px, 1fr) 300px; }
  .people-panel, .conversation-panel, .work-panel { padding: 20px; }
}
@media (max-width: 820px) {
  .welcome { grid-template: auto auto auto / 1fr; gap: 40px; padding-top: 30px; }
  .welcome > .brand { grid-column: 1; }
  .welcome h1 { font-size: 48px; }
  .join-card { max-width: 500px; width: 100%; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar > .brand { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .people-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .people-panel .legend { display: none; }
  #members { display: flex; gap: 18px; overflow: auto; }
  .member-group { min-width: 170px; margin: 0; }
  .conversation-panel { height: 70vh; }
  .work-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .welcome { padding: 24px 18px 40px; }
  .welcome h1 { font-size: 40px; }
  .join-card { padding: 24px; border-radius: 18px; }
  .topbar { padding: 0 16px; }
  .top-actions > span { display: none; }
  .people-panel, .conversation-panel, .work-panel { padding: 18px 15px; }
}
