:root {
  color-scheme: light;
  --bg: #eef3f0;
  --panel: #ffffff;
  --panel-soft: #f7faf8;
  --text: #1f2a25;
  --muted: #6d7a73;
  --line: #dfe8e2;
  --green: #25b864;
  --green-dark: #168849;
  --blue: #3c78d8;
  --danger: #d94b4b;
  --shadow: 0 12px 30px rgba(31, 42, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.view {
  min-height: 100vh;
}

.auth-view {
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(150deg, #dff5ea, #eef6ff 50%, #f7f3ea);
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
}

.brand h1,
.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.brand p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tab,
.ghost-btn,
.secondary-btn,
.primary-btn,
.send-btn,
.attach-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
}

.tab {
  background: var(--panel-soft);
  color: var(--muted);
}

.tab.active,
.primary-btn,
.send-btn {
  background: var(--green);
  color: #fff;
}

.primary-btn:hover,
.send-btn:hover {
  background: var(--green-dark);
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-btn,
.attach-btn {
  background: #e8f4ee;
  color: var(--green-dark);
}

.form-panel {
  display: none;
  gap: 14px;
}

.form-panel.active {
  display: grid;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: none;
}

.message-line,
.activation-result {
  min-height: 20px;
  color: var(--danger);
  word-break: break-word;
}

.rooms-view,
.admin-view {
  padding: 24px;
}

.topbar,
.chat-topbar,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.rooms-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.room-card,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(31, 42, 37, 0.06);
}

.room-card {
  text-align: left;
}

.room-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.room-meta {
  color: var(--muted);
  font-size: 14px;
}

.unread-badge {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  margin-left: 8px;
}

.chat-view {
  height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  background: #e7efe9;
}

.chat-topbar {
  grid-column: 1 / -1;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.room-switcher {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.room-select {
  min-width: 220px;
}

.members-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  overflow: auto;
}

.members-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.member-pill {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.member-role {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.messages-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

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

.message {
  max-width: min(680px, 86%);
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 3px 12px rgba(31, 42, 37, 0.08);
}

.message.own {
  align-self: flex-end;
  background: #dcf8e7;
}

.message-author {
  font-weight: 700;
  font-size: 13px;
}

.message-time {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}

.message-content {
  margin-top: 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attachment-card {
  margin-top: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}

.attachment-card img,
.attachment-card video {
  max-width: 320px;
  max-height: 240px;
  border-radius: 10px;
}

.attachment-link {
  display: inline-block;
  max-width: min(320px, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-form {
  --composer-height: 35px;
  display: grid;
  grid-template-columns: var(--composer-height) minmax(0, 1fr) var(--composer-height);
  align-items: stretch;
  gap: 14px;
  padding: 12px 18px;
  background: #f7f7f7;
  border-top: 1px solid var(--line);
}

.file-input {
  display: none;
}

.input-icon-btn {
  width: var(--composer-height);
  height: var(--composer-height);
  border: 3px solid #1d1d1d;
  border-radius: 50%;
  background: transparent;
  color: #1d1d1d;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.voice-mode-btn {
  position: relative;
}

.voice-mode-btn.active {
  background: #1d1d1d;
  color: #fff;
}

.speaker-icon {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-box {
  min-width: 0;
  height: var(--composer-height);
}

.composer-box textarea,
.hold-talk-btn {
  width: 100%;
  height: var(--composer-height);
  min-height: var(--composer-height);
  border: 0;
  border-radius: 10px;
  background: #fff;
}

.composer-box textarea {
  resize: none;
  padding: 7px 12px;
  line-height: 1.4;
}

.hold-talk-btn {
  color: var(--text);
  user-select: none;
  touch-action: none;
  display: grid;
  place-items: center;
  padding: 0 16px;
}

.hold-talk-btn.recording {
  background: #1f9d55;
  color: #fff;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 16px;
}

.admin-card {
  display: grid;
  gap: 12px;
}

.admin-card h2 {
  margin: 0;
}

.admin-member-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.small-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 9px;
}

@media (max-width: 760px) {
  .rooms-view,
  .admin-view {
    padding: 14px;
  }

  .chat-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .members-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 150px;
  }

  .message-form {
    --composer-height: 32px;
    grid-template-columns: var(--composer-height) minmax(0, 1fr) var(--composer-height);
    gap: 10px;
    padding: 10px 12px;
  }

  .input-icon-btn {
    border-width: 2px;
    font-size: 13px;
  }

  .composer-box textarea {
    padding: 10px 12px;
  }

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

  .topbar,
  .chat-topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .room-select {
    min-width: 0;
  }
}

.messages-panel > .message-form {
  --composer-height: 35px;
  grid-template-columns: var(--composer-height) minmax(0, 1fr) var(--composer-height);
  align-items: stretch;
}

.messages-panel > .message-form .input-icon-btn {
  width: var(--composer-height);
  height: var(--composer-height);
  min-width: var(--composer-height);
  min-height: var(--composer-height);
  border: 3px solid #1d1d1d;
  border-radius: 50%;
  background: transparent;
  color: #1d1d1d;
  padding: 0;
}

.messages-panel > .message-form .composer-box,
.messages-panel > .message-form textarea,
.messages-panel > .message-form .hold-talk-btn {
  height: var(--composer-height);
  min-height: var(--composer-height);
}

.messages-panel > .message-form .hold-talk-btn {
  width: 100%;
  border-radius: 10px;
}

.messages-panel > .message-form .speaker-icon {
  display: block;
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: currentColor;
}

@media (max-width: 760px) {
  .messages-panel > .message-form {
    --composer-height: 32px;
  }

  .messages-panel > .message-form .input-icon-btn {
    border-width: 2px;
  }
}
