:root {
  --room-bg: #090d0b;
  --room-panel: #0f1511;
  --room-panel-2: #131a15;
  --room-line: #313a34;
  --room-fg: #eeeae2;
  --room-muted: #92978f;
  --room-orange: #e58b4c;
  --room-green: #8fcf91;
  --room-blue: #78a8df;
  --room-red: #db8177;
}

.room-body {
  min-height: 100vh;
  background:
    linear-gradient(rgba(143, 207, 145, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 207, 145, .035) 1px, transparent 1px),
    var(--room-bg);
  background-size: 44px 44px;
  color: var(--room-fg);
}

.room-body [hidden] { display: none !important; }

.room-nav {
  background: rgba(9, 13, 11, .92);
  border-color: var(--room-line);
}

.room-nav .nav-links a { color: var(--room-muted); }
.room-nav .nav-links a[aria-current] { color: var(--room-fg); }

.room-shell {
  width: min(1500px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 3rem 0 2rem;
}

.room-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3rem;
  align-items: end;
  padding: 2.25rem 0 2.5rem;
}

.room-hero .eyebrow { color: var(--room-muted); }
.room-hero h1 {
  max-width: 15ch;
  font-size: clamp(3rem, 6.5vw, 6.8rem);
  font-weight: 520;
  letter-spacing: -.055em;
  line-height: .9;
}

.room-lead {
  max-width: 54ch;
  margin-top: 1.35rem;
  color: var(--room-muted);
  font-size: clamp(.95rem, 1.25vw, 1.1rem);
}

.service-card {
  min-width: 285px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .8rem;
  align-items: start;
  padding: 1rem;
  border: 1px solid var(--room-line);
  background: rgba(15, 21, 17, .88);
}

.service-light {
  width: .58rem;
  aspect-ratio: 1;
  margin-top: .35rem;
  border-radius: 50%;
  background: var(--room-muted);
  box-shadow: 0 0 0 4px rgba(146, 151, 143, .08);
}

.service-card[data-state="online"] .service-light {
  background: var(--room-green);
  box-shadow: 0 0 0 4px rgba(143, 207, 145, .09), 0 0 18px rgba(143, 207, 145, .25);
}

.service-card[data-state="offline"] .service-light { background: var(--room-red); }
.service-label, .panel-label {
  margin: 0;
  color: var(--room-muted);
  font: .65rem var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.service-card strong { display: block; margin-top: .12rem; font-size: .9rem; font-weight: 520; }
.service-card small { display: block; margin-top: .25rem; color: var(--room-muted); font-size: .7rem; }

.room-honesty {
  display: flex;
  gap: .8rem;
  max-width: 850px;
  margin-bottom: 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--room-orange) 42%, var(--room-line));
  background: color-mix(in srgb, var(--room-orange) 5%, var(--room-panel));
  color: var(--room-muted);
  font-size: .8rem;
}

.room-honesty span, .room-honesty strong { color: var(--room-orange); }

.room-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 720px;
  border: 1px solid var(--room-line);
  background: rgba(9, 13, 11, .86);
}

.room-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--room-line);
}

.room-panel { padding: 1.25rem; }
.new-room-panel { border-bottom: 1px solid var(--room-line); }
.room-list-panel { min-height: 0; }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-heading.compact { align-items: end; }
.panel-heading h2 { margin-top: .2rem; font-size: 1.05rem; font-weight: 500; }

.mode-chip, .status-chip {
  padding: .2rem .45rem;
  border: 1px solid var(--room-line);
  color: var(--room-muted);
  font: .61rem var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mode-chip[data-mode="mock"] { color: var(--room-green); border-color: color-mix(in srgb, var(--room-green) 45%, var(--room-line)); }
.mode-chip[data-mode="cli"] { color: var(--room-orange); border-color: var(--room-orange); }

#room-form { display: grid; gap: .85rem; }
#room-form label {
  display: grid;
  gap: .35rem;
  color: var(--room-muted);
  font: .66rem var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

#room-form input, #room-form textarea, #room-form select, #decision-note {
  width: 100%;
  border: 1px solid var(--room-line);
  border-radius: 2px;
  background: #0a0f0c;
  color: var(--room-fg);
  font: .78rem/1.5 var(--mono);
}

#room-form input, #room-form select { min-height: 2.55rem; padding: .55rem .65rem; }
#room-form textarea, #decision-note { resize: vertical; padding: .65rem; }
#room-form :focus-visible, #decision-note:focus-visible {
  outline: 2px solid var(--room-orange);
  outline-offset: 2px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.form-note { color: var(--room-muted); font: .61rem/1.5 var(--mono); }

.room-button {
  min-height: 2.55rem;
  padding: .55rem .8rem;
  border: 1px solid #667168;
  border-radius: 3px;
  background: transparent;
  color: var(--room-fg);
  cursor: pointer;
  font: 700 .7rem var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.room-button.primary { border-color: var(--room-orange); background: var(--room-orange); color: #23160d; }
.room-button.danger { border-color: color-mix(in srgb, var(--room-red) 60%, var(--room-line)); color: var(--room-red); }
.room-button:disabled { opacity: .35; cursor: not-allowed; }
.room-button:not(:disabled):hover { filter: brightness(1.08); }

.text-control {
  padding: .25rem 0;
  border: 0;
  background: transparent;
  color: var(--room-muted);
  cursor: pointer;
  font: .65rem var(--mono);
}

.text-control:hover { color: var(--room-fg); }
.room-list { display: grid; gap: .35rem; max-height: 350px; overflow: auto; }
.empty-copy { color: var(--room-muted); font: .7rem/1.55 var(--mono); }

.room-list-item {
  display: grid;
  gap: .35rem;
  width: 100%;
  padding: .7rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--room-fg);
  text-align: left;
  cursor: pointer;
}

.room-list-item:hover { background: var(--room-panel); }
.room-list-item[data-active="true"] { border-color: #775138; background: #18140f; }
.room-list-top { display: flex; justify-content: space-between; gap: .5rem; align-items: start; }
.room-list-item strong { font-size: .78rem; font-weight: 500; }
.room-list-item em { color: var(--room-orange); font: normal .57rem var(--mono); text-transform: uppercase; }
.room-list-item small { color: var(--room-muted); font: .58rem var(--mono); }

.room-workspace { min-width: 0; }
.empty-room {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: start;
  padding: 3rem;
}

.table-mark {
  width: 110px;
  height: 64px;
  margin-bottom: 2rem;
  border: 1px solid var(--room-line);
  border-radius: 50%;
  transform: perspective(180px) rotateX(58deg);
  box-shadow: inset 0 0 0 12px var(--room-bg), inset 0 0 0 13px var(--room-line);
}

.empty-room h2 { font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 400; letter-spacing: -.035em; }
.empty-room > p:last-child { max-width: 48ch; margin-top: 1rem; color: var(--room-muted); }
.active-room { min-height: 100%; }

.active-room-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--room-line);
}

.active-room-head h2 { font-size: clamp(1.75rem, 3vw, 3.1rem); line-height: 1; font-weight: 500; letter-spacing: -.035em; }
.active-goal { max-width: 70ch; margin-top: .85rem; color: var(--room-muted); font-size: .83rem; }
.active-room-meta { display: flex; align-items: start; gap: .6rem; color: var(--room-muted); font: .65rem var(--mono); }
.status-chip[data-status="running"] { color: var(--room-green); border-color: var(--room-green); }
.status-chip[data-status="awaiting_decision"] { color: var(--room-orange); border-color: var(--room-orange); }
.status-chip[data-status="approved"] { color: var(--room-blue); border-color: var(--room-blue); }
.status-chip[data-status="error"], .status-chip[data-status="stopped"] { color: var(--room-red); border-color: var(--room-red); }

.protocol-line {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr auto;
  gap: .7rem;
  align-items: center;
  padding: .85rem 1.5rem;
  border-bottom: 1px solid var(--room-line);
}

.protocol-line span { color: var(--room-muted); font: .59rem var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.protocol-line span[data-done="true"] { color: var(--room-green); }
.protocol-line i { height: 1px; background: var(--room-line); }

.room-controls {
  display: flex;
  gap: .6rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--room-line);
}

.control-note { margin-left: auto; color: var(--room-muted); font: .63rem var(--mono); }
.transcript { display: grid; gap: .8rem; min-height: 250px; max-height: 660px; overflow: auto; padding: 1.5rem; }
.transcript-empty { padding: 4rem 0; text-align: center; }

.message {
  width: min(82%, 780px);
  border: 1px solid var(--room-line);
  background: var(--room-panel);
}

.message-claude { justify-self: start; border-left: 2px solid var(--room-orange); }
.message-codex { justify-self: end; border-right: 2px solid var(--room-blue); }
.message-system { width: min(92%, 850px); justify-self: center; background: transparent; border-style: dashed; }
.message-yuto { justify-self: end; border-right: 2px solid var(--room-green); }

.message header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .62rem .75rem;
  border-bottom: 1px solid var(--room-line);
  color: var(--room-muted);
  font: .58rem var(--mono);
  text-transform: uppercase;
}

.message header > div { display: flex; gap: .5rem; align-items: center; }
.message header strong { color: var(--room-fg); font-size: .64rem; font-weight: 600; }
.agent-mark {
  display: grid;
  width: 1.35rem;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid currentColor;
  color: var(--room-orange);
}

.message-codex .agent-mark { color: var(--room-blue); }
.message-yuto .agent-mark { color: var(--room-green); }
.message-system .agent-mark { color: var(--room-muted); }
.message-body { padding: .85rem; white-space: pre-wrap; color: #d9d9d1; font: .78rem/1.65 var(--mono); }

.decision-panel {
  display: grid;
  grid-template-columns: minmax(180px, .65fr) minmax(260px, 1fr);
  gap: 1rem 1.5rem;
  padding: 1.5rem;
  border-top: 1px solid var(--room-orange);
  background: color-mix(in srgb, var(--room-orange) 5%, var(--room-panel));
}

.decision-panel h3 { margin: .2rem 0; font-size: 1.1rem; }
.decision-panel p:not(.panel-label) { color: var(--room-muted); font-size: .72rem; }
.decision-actions { grid-column: 1 / -1; display: flex; gap: .6rem; align-items: center; }
.room-footer { display: flex; justify-content: space-between; gap: 1rem; padding-top: 1rem; color: var(--room-muted); font: .61rem var(--mono); }
.room-footer a { color: var(--room-fg); border-bottom: 1px solid var(--room-line); }

.room-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: 390px;
  padding: .8rem 1rem;
  border: 1px solid var(--room-orange);
  background: #17130f;
  color: var(--room-fg);
  box-shadow: 0 10px 35px rgba(0, 0, 0, .35);
  font: .7rem/1.5 var(--mono);
}

@media (max-width: 980px) {
  .room-grid { grid-template-columns: 1fr; }
  .room-sidebar { grid-template-columns: 1fr 1fr; grid-template-rows: auto; border-right: 0; border-bottom: 1px solid var(--room-line); }
  .new-room-panel { border-right: 1px solid var(--room-line); border-bottom: 0; }
  .room-list { max-height: 390px; }
}

@media (max-width: 700px) {
  .room-nav .brand { flex: 0 0 auto; white-space: nowrap; }
  .room-nav .nav-links { gap: .8rem; }
  .room-nav .nav-links a { display: none; }
  .room-nav .nav-links a[href="/studio/"],
  .room-nav .nav-links a[href="/room/"] { display: block; }
  .room-shell { width: min(100% - 1.25rem, 1500px); padding-top: 1.5rem; }
  .room-hero { grid-template-columns: 1fr; gap: 1.5rem; }
  .room-hero h1 { font-size: clamp(3rem, 16vw, 5.5rem); }
  .service-card { min-width: 0; }
  .room-sidebar { grid-template-columns: 1fr; }
  .new-room-panel { border-right: 0; border-bottom: 1px solid var(--room-line); }
  .active-room-head { grid-template-columns: 1fr; gap: 1rem; }
  .protocol-line { gap: .35rem; padding-inline: .8rem; }
  .protocol-line span { font-size: .5rem; }
  .room-controls { flex-wrap: wrap; padding-inline: .8rem; }
  .control-note { width: 100%; margin: .35rem 0 0; }
  .transcript { padding: .8rem; }
  .message { width: 94%; }
  .message header { align-items: start; }
  .message header > span { text-align: right; }
  .decision-panel { grid-template-columns: 1fr; padding: 1rem; }
  .decision-actions { grid-column: auto; flex-direction: column; align-items: stretch; }
  .room-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
