:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ee;
  --text: #15201b;
  --muted: #66736b;
  --line: #dce5dd;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d9f4ef;
  --warn: #925b00;
  --danger: #a83232;
  --shadow: 0 20px 60px rgba(21, 32, 27, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.unlock-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.unlock-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.unlock-card h1,
.conversation-header h1,
.brand-row h2 {
  margin: 0;
  letter-spacing: 0;
}

.unlock-card h1 {
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.08;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.unlock-form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.unlock-form label {
  font-weight: 700;
}

.unlock-form input {
  min-height: 48px;
  padding: 0 14px;
}

.error {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px;
}

.brand-row,
.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-row h2 {
  font-size: 21px;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.icon-button:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-panel,
.share-box,
.room-list-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.status-panel {
  display: grid;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-row span,
.share-box span,
.section-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-row strong {
  text-align: right;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions button:first-child {
  grid-column: 1 / -1;
}

.actions button:nth-child(2),
.actions button:nth-child(3) {
  background: #1f3d36;
}

.actions button:nth-child(2):hover:not(:disabled),
.actions button:nth-child(3):hover:not(:disabled) {
  background: #12251f;
}

.share-box {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.share-box input {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
}

.room-list-block {
  min-height: 140px;
  overflow: hidden;
}

.section-title {
  padding: 12px 14px 8px;
}

.room-list {
  display: grid;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  padding: 0 8px 10px;
}

.room-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  min-height: 58px;
  padding: 9px 10px;
  text-align: left;
}

.room-item:hover,
.room-item.is-active {
  border-color: var(--line);
  background: var(--surface-2);
}

.room-item strong,
.room-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.danger-button {
  margin-top: auto;
  background: #fff4f1;
  color: var(--danger);
  border: 1px solid #f0c5bd;
}

.danger-button:hover:not(:disabled) {
  background: #ffe6df;
  color: #802020;
}

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

.conversation-header {
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 243, 0.88);
  padding: 18px 24px;
}

.conversation-header h1 {
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.2;
}

.session-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
}

.session-badge.is-ready {
  border-color: #95dbc8;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 24px;
}

.empty-state {
  margin: auto;
  max-width: 520px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(72ch, 78%);
}

.message.is-me {
  align-self: flex-end;
}

.message.is-peer {
  align-self: flex-start;
}

.message-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.message.is-me .message-bubble {
  border-color: #9fd6cb;
  background: #e8f8f4;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.message.is-me .message-meta {
  text-align: right;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
}

.composer textarea {
  min-height: 48px;
  max-height: 160px;
  resize: none;
  padding: 12px 14px;
  line-height: 1.4;
}

.composer button {
  min-width: 88px;
}

@media (max-width: 820px) {
  .chat-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .room-list {
    max-height: 140px;
  }

  .conversation {
    min-height: calc(100vh - 420px);
  }
}

@media (max-width: 560px) {
  .unlock-view {
    padding: 14px;
  }

  .unlock-card {
    padding: 22px;
  }

  .sidebar {
    gap: 14px;
    padding: 16px;
  }

  .conversation-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .messages {
    padding: 16px;
  }

  .message {
    max-width: 92%;
  }

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

  .composer button {
    width: 100%;
  }
}
