:root {
  color-scheme: dark;
  font: 14px/1.5 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: #e7ebea;
  background: #101717;
  --surface: #151e1f;
  --raised: #1c292a;
  --line: #2b393a;
  --muted: #a1b4b4;
  --teal: #80e6c9;
  --on-teal: #07251f;
  --field: #0e1617;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
body:has(#workspace:not([hidden])) { height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.app-bar {
  height: 55px;
  flex: 0 0 auto;
  display: flex;
  padding: 0 clamp(14px, 3vw, 28px);
  gap: 11px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #111a1a;
}
.app-bar strong { letter-spacing: .18em; font-size: 13px; margin-right: auto; }
#account { color: var(--muted); overflow-wrap: anywhere; }
.orbita-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  aspect-ratio: 1;
  flex: none;
  border: 1px solid #477366;
  border-radius: 8px;
  background: #1b3730;
}
.orbita-mark::before {
  content: "";
  width: 52%;
  height: 38%;
  border: 2px solid var(--teal);
  border-radius: 50%;
  transform: rotate(-35deg);
}

button, input, textarea {
  min-width: 0;
  color: inherit;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 11px;
  background: var(--field);
}
button { cursor: pointer; font-weight: 600; background: var(--raised); white-space: nowrap; }
button:hover { border-color: #5b7971; background: #263939; }
button:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: #9bafae; }

body:has(#auth:not([hidden])) {
  background: radial-gradient(ellipse at 50% 25%, #23423b 0%, #131d1d 50%, #101717 78%);
}
#auth {
  width: min(454px, calc(100% - 32px));
  margin: clamp(24px, 10vh, 100px) auto 24px;
  padding: clamp(23px, 5vw, 38px);
  border: 1px solid #334946;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 70px #080d0e80;
}
.auth-mark { width: 44px; border-radius: 13px; margin-bottom: 14px; }
h1, h2, p { margin-top: 0; }
#auth h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.15; margin-bottom: 28px; letter-spacing: -.025em; }
#auth label { display: grid; gap: 7px; margin-bottom: 16px; color: var(--muted); }
#auth input { height: 44px; color: #e7ebea; }
.auth-actions { display: grid; gap: 8px; margin-top: 24px; }
.auth-actions button { min-height: 42px; }
.auth-actions button[type=submit], #composer button {
  background: var(--teal);
  border-color: transparent;
  color: var(--on-teal);
}
.auth-actions button[type=submit]:hover, #composer button:hover { background: #a5f7df; }
#auth-status { margin: 12px 0 0; color: #efd29c; }
#auth-status:empty { display: none; }

#workspace {
  display: grid;
  grid-template-columns: clamp(165px, 23vw, 265px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
}
aside {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 13px 13px;
  border-right: 1px solid var(--line);
  background: #142020;
}
aside h2 { color: var(--muted); margin: 0 9px 12px; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; }
#rooms { display: grid; align-content: start; gap: 4px; overflow-y: auto; flex: 1; padding: 3px; }
#rooms button {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  border-color: transparent;
  background: transparent;
}
#rooms button::before { content: "#"; color: var(--muted); }
#rooms button:hover { background: var(--raised); }
#rooms button[aria-current=true] { background: #244139; color: #b3f7e3; border-color: #42695c; }
#new-room { display: grid; gap: 8px; padding-top: 13px; border-top: 1px solid var(--line); }

.room-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
}
.room-empty .orbita-mark { width: 46px; border-radius: 13px; margin-bottom: 20px; }
.room-empty h1 { margin-bottom: 6px; font-size: 24px; }
.room-empty p { color: var(--muted); margin-bottom: 0; }
#workspace:has(#conversation:not([hidden])) .room-empty { display: none; }
#conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.room-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 13px clamp(12px, 2.5vw, 24px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.room-header h1 { margin: 0 auto 0 0; font-size: 18px; overflow-wrap: anywhere; }
.room-header h1::before { content: "#"; margin-right: 8px; color: var(--teal); }
.room-header form { display: flex; gap: 6px; max-width: 100%; }
.room-header input { width: clamp(100px, 16vw, 176px); }
#older { align-self: center; margin: 10px 0 0; white-space: normal; }
#history { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 14px clamp(12px, 2.5vw, 24px); }
#history li { position: relative; padding: 10px 10px 10px 16px; margin-bottom: 4px; border-radius: 8px; }
#history li:hover { background: var(--surface); }
#history li::before { content: ""; position: absolute; top: 15px; left: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--teal); }
#history .meta { color: var(--teal); font-size: 12px; font-weight: 600; }
#history p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 clamp(12px, 2.5vw, 24px) 18px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
#composer textarea { flex: 1; resize: vertical; min-height: 42px; max-height: 145px; }
#composer button { min-height: 42px; }
#status { grid-column: 1 / -1; margin: 0; padding: 7px 16px; color: #efd29c; background: var(--surface); }
#status:empty { padding: 0; }

@media (max-width: 580px) {
  #workspace { grid-template-columns: minmax(112px, 28vw) minmax(0, 1fr); }
  aside { padding: 12px 7px 8px; }
  aside h2 { margin-left: 4px; }
  .room-header form, .room-header input { width: 100%; }
  #composer { flex-wrap: wrap; }
  #composer textarea { flex-basis: 100%; }
  #composer button { margin-left: auto; }
}
