:root {
  --bg: #eef3ec;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --line: #dfe7de;
  --text: #172319;
  --muted: #69756b;
  --green: #07c160;
  --green-dark: #05a551;
  --green-soft: #e8f8ef;
  --danger: #d64545;
  --shadow: 0 18px 50px rgba(17, 41, 26, 0.12);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(7, 193, 96, 0.12), transparent 45%),
    radial-gradient(circle at 92% 20%, rgba(255, 191, 71, 0.12), transparent 42%),
    linear-gradient(180deg, #f4f8f2 0%, #e9f0e7 100%);
}

body[data-lang="tote"] {
  font-family: "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", sans-serif;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(8px);
}

.bg-shape-a {
  width: 320px;
  height: 320px;
  background: rgba(7, 193, 96, 0.14);
  top: -50px;
  left: -90px;
}

.bg-shape-b {
  width: 260px;
  height: 260px;
  background: rgba(255, 189, 74, 0.14);
  right: -60px;
  bottom: 12%;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.side-panel {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--green), #15d368);
  box-shadow: 0 10px 18px rgba(7, 193, 96, 0.22);
}

.brand-title {
  margin: 0;
  font-size: 1.1rem;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

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

.side-tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.side-tab.is-active {
  border-color: rgba(7, 193, 96, 0.3);
  background: var(--green-soft);
  color: var(--green-dark);
}

.panel-section {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.field-label {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #d4dfd1;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.input:focus,
.message-input:focus {
  outline: 2px solid rgba(7, 193, 96, 0.2);
  border-color: rgba(7, 193, 96, 0.35);
}

.profile-mini {
  min-height: 72px;
}

.profile-mini .mini-name {
  font-weight: 700;
  margin: 0;
}

.profile-mini .mini-sub {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 0.88rem;
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.muted-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.content-panel {
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.view-stack {
  height: 100%;
}

.view {
  display: none;
  height: 100%;
}

.view.is-active {
  display: block;
}

.chat-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 40px);
}

.rooms-panel {
  border-right: 1px solid var(--line);
  background: rgba(248, 251, 247, 0.85);
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: 16px 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.status-pill {
  font-size: 0.76rem;
  border-radius: 999px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.status-pill.is-online {
  color: var(--green-dark);
  border-color: rgba(7, 193, 96, 0.25);
  background: var(--green-soft);
}

.rooms-list {
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.room-item {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  padding: 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.room-item:hover {
  transform: translateY(-1px);
  border-color: rgba(7, 193, 96, 0.2);
  box-shadow: 0 6px 16px rgba(17, 41, 26, 0.06);
}

.room-item.is-active {
  border-color: rgba(7, 193, 96, 0.28);
  background: linear-gradient(180deg, #ffffff 0%, #effcf5 100%);
}

.room-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.room-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.room-chip {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  color: #1f5d35;
  background: rgba(7, 193, 96, 0.12);
  white-space: nowrap;
}

.room-desc {
  margin: 7px 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.room-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #506050;
  font-size: 0.78rem;
}

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

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.chat-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.chat-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.messages {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.65)),
    radial-gradient(circle at 10% 0%, rgba(7, 193, 96, 0.06), transparent 40%);
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.msg {
  display: grid;
  gap: 4px;
  max-width: min(78%, 560px);
}

.msg.is-self {
  align-self: flex-end;
}

.msg.is-other {
  align-self: flex-start;
}

.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.msg.is-self .msg-head {
  justify-content: flex-end;
}

.msg-bubble {
  border-radius: 16px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 6px 14px rgba(17, 41, 26, 0.04);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.is-self .msg-bubble {
  background: linear-gradient(180deg, #dff8e7 0%, #cff4dc 100%);
  border-color: rgba(7, 193, 96, 0.12);
}

.msg-image {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.msg-audio {
  width: min(100%, 320px);
}

.tag-filtered {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  color: #7b5a00;
  background: rgba(255, 205, 72, 0.2);
}

.chat-controls {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ghost-btn,
.primary-btn,
.send-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 12px;
}

.ghost-btn {
  padding: 8px 12px;
  color: #26543a;
  background: rgba(7, 193, 96, 0.1);
}

.ghost-btn.is-recording {
  color: #fff;
  background: var(--danger);
}

.record-state {
  font-size: 0.82rem;
  color: var(--muted);
}

.message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.message-input {
  resize: vertical;
  min-height: 52px;
  max-height: 140px;
  border-radius: 14px;
  border: 1px solid #d4dfd1;
  padding: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.send-btn {
  align-self: end;
  height: 52px;
  padding: 0 16px;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, var(--green), #16ce68);
  box-shadow: 0 10px 18px rgba(7, 193, 96, 0.2);
}

.primary-btn {
  width: 100%;
  padding: 12px 14px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--green), #16ce68);
  box-shadow: 0 10px 18px rgba(7, 193, 96, 0.18);
}

.profile-card {
  max-width: 720px;
  margin: 22px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.profile-card h2 {
  margin: 0 0 6px;
}

.profile-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.saved-state {
  margin-top: 10px;
  color: var(--green-dark);
  min-height: 20px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(24px);
  background: rgba(24, 30, 26, 0.95);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: min(92vw, 520px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .rooms-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;
  }

  .messages {
    min-height: 34vh;
  }

  .side-panel {
    order: 2;
  }

  .content-panel {
    order: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
