:root {
  color-scheme: light;
  --ink: #171a18;
  --muted: #69706b;
  --line: #d9dfda;
  --panel: #ffffff;
  --surface: #f4f6f2;
  --topbar: #141816;
  --topbar-ink: #f7faf5;
  --accent: #0f8b6f;
  --accent-strong: #096852;
  --warn: #a84e12;
  --danger: #a23636;
  --shadow: 0 18px 50px rgb(13 20 16 / 22%);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  height: 100dvh;
  min-height: 100%;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  color: var(--topbar-ink);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
}

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

.brand-mark {
  flex: 0 0 auto;
  height: 30px;
  width: 30px;
}

.brand-name {
  font-size: 1rem;
  font-weight: 750;
}

.status-pill {
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  color: #cfd7d0;
  font-size: 0.78rem;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.status-pill[data-state="online"] {
  color: #b9f2d4;
}

.status-pill[data-state="offline"] {
  color: #ffd0c7;
}

.name-button,
.icon-close,
.primary-button {
  align-items: center;
  border: 0;
  display: inline-flex;
  justify-content: center;
}

.name-button {
  background: rgb(255 255 255 / 9%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 7px;
  color: var(--topbar-ink);
  flex: 0 1 auto;
  gap: 8px;
  max-width: min(240px, 46vw);
  min-height: 38px;
  min-width: 0;
  padding: 7px 10px;
}

.name-button svg,
.icon-close svg {
  fill: none;
  flex: 0 0 auto;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.name-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panes {
  display: grid;
  grid-auto-columns: minmax(260px, 1fr);
  grid-auto-flow: column;
  height: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.chat-pane {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: min(82vw, 420px);
  position: relative;
}

.chat-pane[data-self="true"] {
  box-shadow: inset 0 3px 0 var(--accent);
}

.pane-name {
  align-items: center;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--pane-color, var(--accent)) 35%, var(--line));
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 700;
  gap: 7px;
  left: 12px;
  max-width: calc(100% - 24px);
  min-height: 28px;
  padding: 5px 8px;
  position: absolute;
  top: 12px;
  z-index: 1;
}

.pane-name::before {
  background: var(--pane-color, var(--accent));
  border-radius: 999px;
  content: "";
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.pane-name span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-text {
  background: transparent;
  border: 0;
  color: var(--ink);
  height: 100%;
  line-height: 1.46;
  min-height: 0;
  outline: none;
  padding: 56px 16px 18px;
  resize: none;
  width: 100%;
}

.chat-text[readonly] {
  color: #2e3430;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 650;
  justify-content: center;
  min-height: 100%;
}

.modal {
  background: transparent;
  border: 0;
  color: var(--ink);
  margin: auto;
  max-width: min(94vw, 460px);
  padding: 0;
  width: 100%;
}

.modal::backdrop {
  background: rgb(0 0 0 / 42%);
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  padding: 18px;
  position: relative;
}

.feedback-panel {
  padding-top: 24px;
}

.modal-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0;
}

.icon-close {
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
  height: 34px;
  width: 34px;
}

.name-button:hover {
  background: rgb(255 255 255 / 14%);
}

.icon-close:hover {
  background: #eef3ef;
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

.field textarea {
  line-height: 1.42;
  min-height: 130px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 139 111 / 18%);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-button {
  background: var(--accent);
  border-radius: 7px;
  color: white;
  font-weight: 750;
  min-height: 38px;
  padding: 8px 14px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  background: #96aaa1;
  cursor: default;
}

.form-status {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  margin: 0;
  min-height: 1.2em;
}

.form-status[data-tone="error"] {
  color: var(--danger);
}

.form-status[data-tone="ok"] {
  color: var(--accent-strong);
}

.build-corner {
  color: #87908a;
  font-size: 0.72rem;
  line-height: 1;
  position: absolute;
  right: 12px;
  top: 8px;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .topbar {
    gap: 8px;
  }

  .status-pill {
    display: none;
  }

  .panes {
    grid-auto-columns: minmax(84vw, 1fr);
  }

  .chat-pane {
    min-width: 84vw;
  }
}
