:root {
  --bg-top: #ffd9a8;
  --bg-middle: #fff6da;
  --bg-bottom: #b7eadf;
  --surface: rgba(255, 251, 244, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #1d312d;
  --muted: #5d7168;
  --accent: #0c8b73;
  --accent-strong: #066451;
  --accent-soft: rgba(12, 139, 115, 0.12);
  --border: rgba(29, 49, 45, 0.09);
  --shadow: 0 24px 50px rgba(39, 77, 67, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.35), transparent 22%),
    linear-gradient(180deg, var(--bg-top), var(--bg-middle) 45%, var(--bg-bottom));
}

body.overlay-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.page {
  width: min(100%, 32rem);
  margin: 0 auto;
  padding: 0.75rem 0.85rem 1.25rem;
}

.hero {
  padding: 0.35rem 0 0.15rem;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 10vw, 3.3rem);
  line-height: 0.95;
  text-wrap: balance;
}

.card {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.message-form,
label {
  display: grid;
  gap: 0.45rem;
}

.identity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: start;
}

.name-field {
  min-width: 0;
}

.avatar-field {
  display: grid;
  gap: 0.3rem;
  justify-items: center;
}

.avatar-field span {
  color: var(--muted);
  font-size: 0.85rem;
}

.avatar-picker {
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 138, 107, 0.18);
  background: var(--surface-strong);
  overflow: hidden;
}

.avatar-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  font-size: 1.8rem;
  color: var(--accent-strong);
  line-height: 1;
}

.avatar-change {
  padding: 0.45rem 0.8rem;
  font-size: 0.84rem;
}

.avatar-actions {
  display: grid;
  gap: 0.35rem;
}

.avatar-remove {
  padding: 0.4rem 0.75rem;
  background: rgba(12, 139, 115, 0.12);
  color: var(--accent-strong);
  font-size: 0.8rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(15, 138, 107, 0.18);
  border-radius: 1rem;
  padding: 0.78rem 0.9rem;
  background: var(--surface-strong);
  color: var(--text);
}

input:focus,
textarea:focus,
button:focus {
  outline: 3px solid rgba(12, 139, 115, 0.2);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.82rem 1.1rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 1.2rem;
}

.open-message {
  margin-top: 0.65rem;
  width: 100%;
}

.messages {
  display: grid;
  gap: 0.7rem;
}

.message-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(15, 138, 107, 0.12);
  cursor: pointer;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 999px;
  background: rgba(12, 139, 115, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  min-width: 0;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.84rem;
}

.message-meta-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.message-name {
  font-weight: 700;
}

.message-time {
  color: var(--muted);
  white-space: nowrap;
}

.message-delete {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: rgba(164, 52, 52, 0.12);
  color: #a43434;
  font-size: 0.95rem;
  line-height: 1;
}

.message-text,
.empty,
.form-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.empty {
  padding: 0.8rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.5);
}

.form-status {
  font-size: 0.9rem;
}

.form-status[data-state="error"] {
  color: #a43434;
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 1rem 0.85rem;
}

.overlay[hidden] {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 29, 26, 0.42);
  backdrop-filter: blur(6px);
}

.overlay-card {
  position: relative;
  width: min(100%, 32rem);
  padding: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 1.35rem;
  background: rgba(255, 251, 244, 0.96);
  box-shadow: 0 24px 60px rgba(18, 33, 29, 0.26);
}

.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.overlay-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.close-message {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(12, 139, 115, 0.12);
  color: var(--accent-strong);
  font-size: 1.4rem;
  line-height: 1;
}

.admin-card {
  place-self: center;
}

.camera-card {
  place-self: center;
}

.camera-stage {
  display: grid;
  gap: 0.75rem;
}

.camera-video {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 1.1rem;
  background: rgba(17, 29, 26, 0.85);
  object-fit: cover;
}

.camera-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.detail-overlay[hidden] {
  display: none;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 29, 26, 0.62);
  backdrop-filter: blur(8px);
}

.detail-card {
  position: relative;
  width: min(100%, 30rem);
  padding: 1.35rem;
  border-radius: 1.4rem;
  background: rgba(255, 251, 244, 0.98);
  box-shadow: 0 24px 60px rgba(18, 33, 29, 0.3);
  text-align: center;
}

.detail-avatar-wrap {
  display: grid;
  place-items: center;
  margin-bottom: 0.8rem;
}

.detail-avatar,
.detail-avatar-fallback {
  width: 12.5rem;
  height: 12.5rem;
  border-radius: 999px;
}

.detail-avatar {
  object-fit: cover;
}

.detail-avatar[hidden],
.detail-avatar-fallback[hidden] {
  display: none !important;
}

.detail-avatar-fallback {
  display: grid;
  place-items: center;
  background: rgba(12, 139, 115, 0.12);
  color: var(--accent-strong);
  font-size: 3rem;
  font-weight: 700;
}

.detail-time,
.detail-message {
  margin: 0;
  color: var(--muted);
}

.detail-time {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.detail-name {
  margin: 0 0 0.75rem;
  font-size: 1.6rem;
}

.detail-message {
  font-size: 1.15rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

@media (min-width: 700px) {
  .page {
    padding-top: 2rem;
  }

  .card {
    padding: 1.25rem;
  }

  .overlay {
    place-items: center;
  }

  .detail-card {
    width: min(100%, 42rem);
    padding: 1.9rem;
  }

  .detail-avatar,
  .detail-avatar-fallback {
    width: 18rem;
    height: 18rem;
  }

  .detail-time {
    font-size: 1.1rem;
  }

  .detail-name {
    font-size: 2rem;
  }

  .detail-message {
    font-size: 1.35rem;
    line-height: 1.75;
  }
}
