:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #24211c;
  --muted: #746f65;
  --line: #ddd5c8;
  --sent: #277765;
  --sent-ink: #ffffff;
  --received: #ffffff;
  --accent: #bf5148;
  --shadow: 0 18px 42px rgba(50, 43, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(244, 241, 234, 0.84), rgba(244, 241, 234, 0.84)),
    repeating-linear-gradient(135deg, #e9e1d2 0 1px, transparent 1px 14px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 860px);
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.round-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.settings-panel {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.link-guide {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.link-guide strong {
  color: var(--ink);
  font-size: 14px;
}

.danger-button {
  width: 100%;
  min-height: 40px;
  border: 1px solid #e6b7b2;
  border-radius: 8px;
  color: #8c2c25;
  background: #fff4f2;
  cursor: pointer;
}

.messages {
  padding: 18px;
  overflow-y: auto;
}

.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.message-row {
  display: flex;
  margin: 8px 0;
}

.message-row.sent {
  justify-content: flex-end;
}

.message-row.received {
  justify-content: flex-start;
}

.bubble {
  max-width: min(78%, 520px);
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.sent .bubble {
  color: var(--sent-ink);
  background: var(--sent);
  border-bottom-right-radius: 2px;
}

.received .bubble {
  color: var(--ink);
  background: var(--received);
  border: 1px solid var(--line);
  border-bottom-left-radius: 2px;
}

.bubble img {
  display: block;
  width: min(260px, 100%);
  max-height: 360px;
  object-fit: cover;
  border-radius: 6px;
}

.meta {
  margin-top: 5px;
  font-size: 11px;
  opacity: 0.72;
}

.translation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.translate-button {
  margin-top: 6px;
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
}

.composer {
  display: grid;
  grid-template-columns: 42px 42px 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.camera-button {
  cursor: pointer;
}

textarea {
  min-height: 42px;
  max-height: 96px;
  padding: 10px 12px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea:focus {
  border-color: var(--sent);
}

.send-button {
  min-width: 62px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--sent);
  cursor: pointer;
}

.send-button:disabled {
  color: #9c978e;
  background: #e3ded5;
  cursor: default;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(36, 33, 28, 0.9);
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
  }

  .chat-header {
    padding-inline: 12px;
  }

  .messages {
    padding: 12px;
  }

  .composer {
    grid-template-columns: 38px 38px 1fr auto;
    padding: 10px;
  }

  .icon-button,
  .round-button {
    width: 38px;
    height: 38px;
  }

  .send-button {
    min-width: 54px;
  }
}
