:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-soft: #f1f4ef;
  --ink: #1d2730;
  --muted: #667085;
  --line: #d9ded5;
  --brand: #2f7d68;
  --brand-dark: #245f50;
  --accent: #986f2d;
  --danger: #ad3f3f;
  --shadow: 0 16px 45px rgba(29, 39, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(217, 222, 213, 0.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 222, 213, 0.45) 1px, transparent 1px),
    linear-gradient(135deg, #f7f7f4 0%, #eef2ef 100%);
  background-size: 28px 28px, 28px 28px, auto;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  background: var(--brand-dark);
}

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

button.secondary:hover {
  background: var(--panel-soft);
}

button.full {
  width: 100%;
}

input,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 104, 0.14);
}

input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

h1,
h2,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--accent);
  cursor: default;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

#roleLabel {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

#roleLabel::after {
  background: transparent;
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 4px;
  opacity: 0;
  transform: translateY(-1px);
  width: 4px;
}

#roleLabel.has-background-activity::after {
  background: #8c7245;
  opacity: 0.72;
}

.login-view {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel,
.account-panel,
.create-box,
.account-settings,
.admin-drawer {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 16px;
  max-width: 390px;
  padding: 30px;
  width: 100%;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  font-weight: 800;
  gap: 7px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.admin-drawer,
.account-panel {
  border-bottom: 0;
  border-radius: 0;
  border-right: 0;
  border-top: 0;
  bottom: 0;
  box-shadow: -20px 0 45px rgba(29, 39, 48, 0.14);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  overflow-y: auto;
  padding: 20px;
  position: fixed;
  right: 0;
  top: 0;
  width: min(420px, 92vw);
  z-index: 8;
}

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

.drawer-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.drawer-section h3,
.account-settings h3 {
  font-size: 14px;
  margin: 0;
}

.drawer-header h2,
.topbar h1 {
  margin-bottom: 0;
}

.account-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.account-item {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 50px;
  text-align: left;
}

.account-item span {
  display: grid;
  gap: 2px;
}

.account-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.account-item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 125, 104, 0.12);
}

.account-item small {
  color: var(--muted);
  font-weight: 700;
}

.create-box {
  box-shadow: none;
  padding: 14px;
}

.create-box summary {
  cursor: pointer;
  font-weight: 900;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.conversation {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-self: center;
  min-height: 100vh;
  width: min(1180px, 100%);
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.account-settings {
  box-shadow: none;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.account-settings.hidden {
  display: none !important;
}

.settings-grid {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.account-settings {
  border-radius: 8px;
  box-shadow: none;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 42px;
}

.checkbox-label input {
  width: auto;
}

.messages {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  overflow-y: auto;
  padding: 22px;
}

.message {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-left: 4px solid #c9d3cc;
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(29, 39, 48, 0.05);
  max-width: 100%;
  padding: 13px 14px 13px 16px;
}

.message.mine {
  background: #fbfdfb;
  border-color: #cbd8d1;
  border-left-color: var(--brand);
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.message-text {
  line-height: 1.5;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.media-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.media-box img,
.media-box video {
  border-radius: 8px;
  max-height: 420px;
  max-width: 100%;
}

.media-box audio {
  width: min(360px, 100%);
}

.media-box a {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.composer {
  align-items: start;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: 14px 22px;
}

.composer-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

textarea {
  max-height: 160px;
  min-height: 44px;
  resize: none;
}

.attach-button {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 42px;
  min-width: 92px;
  padding: 0 14px;
}

.attach-button input {
  display: none;
}

.file-status-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.file-status {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 7px 10px;
}

.clear-file-button {
  color: var(--muted);
  font-size: 12px;
  min-height: 31px;
  padding: 0 10px;
}

.form-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

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

.empty {
  align-self: center;
  color: var(--muted);
  margin: auto;
  text-align: center;
}

@media (max-width: 1050px) {
  .conversation {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  .messages {
    padding: 14px;
  }

  .composer {
    padding: 12px 14px;
  }

  .attach-button {
    width: 100%;
  }
}
