:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #18201d;
  --muted: #66706a;
  --line: #d9ded7;
  --accent: #156f5b;
  --accent-strong: #0f5949;
  --accent-soft: #dcefe9;
  --danger: #9d2b2b;
  --shadow: 0 16px 45px rgba(28, 42, 35, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button,
.icon-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

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

button:disabled,
.icon-button:has(+ input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  background: #eef1ed;
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary:hover {
  background: #e1e6df;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
}

.shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.brand p,
.chat-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.status-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.status-grid div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-grid div {
  padding: 12px;
}

.status-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.status-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  letter-spacing: 0;
}

.panel {
  padding: 12px;
  margin-top: 12px;
  box-shadow: 0 8px 24px rgba(28, 42, 35, 0.04);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

textarea,
.panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  background: #fbfcfa;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.panel input {
  min-height: 42px;
}

textarea:focus,
input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.chat {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.76)),
    radial-gradient(circle at 0 0, rgba(21, 111, 91, 0.16), transparent 28%),
    #eef2ef;
}

.chat-head {
  min-height: 76px;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
}

.messages {
  list-style: none;
  margin: 0;
  padding: 24px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
}

.message.mine {
  justify-content: flex-end;
}

.bubble {
  max-width: min(640px, 82%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 8px;
  box-shadow: var(--shadow);
}

.mine .bubble {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.payload {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.payload img {
  display: block;
  width: min(420px, 100%);
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
}

time {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 11px;
  text-align: right;
}

.mine time {
  color: rgba(255, 255, 255, 0.72);
}

.composer {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.composer input[type="text"],
.composer input:not([type]) {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #fff;
}

.system {
  align-self: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.error {
  color: var(--danger);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 48vh;
  }

  .chat {
    height: 52vh;
  }

  .messages {
    padding: 16px;
  }

  .composer {
    padding: 12px 16px 16px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 16px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head button {
    width: 100%;
  }

  .chat-head {
    padding: 14px 16px;
  }

  .bubble {
    max-width: 92%;
  }
}
