:root {
  --czx-bg: #eef2f6;
  --czx-paper: #fff;
  --czx-ink: #0b1220;
  --czx-muted: #5c6b80;
  --czx-line: #e3e8ef;
  --czx-blue: #1d4ed8;
  --czx-blue-dark: #1e40af;
  --czx-soft: #eff4ff;
  --czx-green: #15803d;
  --czx-danger: #b91c1c;
  --czx-radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--czx-bg);
  color: var(--czx-ink);
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

button { cursor: pointer; }

a { color: var(--czx-blue); }

:focus-visible {
  outline: 2px solid var(--czx-blue);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.czx-top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 10px 20px;
  background: var(--czx-paper);
  border-bottom: 1px solid var(--czx-line);
}

.czx-top > a:first-child {
  color: var(--czx-ink);
  font-weight: 750;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.czx-top nav {
  display: flex;
  gap: 16px;
  margin-left: auto;
  align-items: center;
}

.czx-top nav a {
  color: var(--czx-muted);
  font-weight: 650;
  text-decoration: none;
}

.czx-wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 40px;
}

.czx-hero { padding: 42px 0 8px; }

.czx-hero h1,
.czx-wrap > h1 {
  margin: 28px 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  letter-spacing: -0.04em;
  line-height: 1.12;
}

.czx-hero h1 { margin-top: 0; }

.czx-hero p,
.czx-wrap > p {
  margin: 0 0 16px;
  color: var(--czx-muted);
  max-width: 40rem;
}

.czx-hero form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  max-width: 560px;
  padding: 12px;
  background: var(--czx-paper);
  border: 1px solid var(--czx-line);
  border-radius: var(--czx-radius);
  box-shadow: 0 10px 30px rgba(11, 18, 32, 0.06);
}

.czx-hero label {
  flex: 1 1 100%;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--czx-muted);
}

.czx-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--czx-paper);
  border: 1px solid var(--czx-line);
  border-radius: 12px;
}

.czx-hero .czx-input { flex: 1 1 200px; width: auto; }

.czx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--czx-blue);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}

.czx-btn:hover { background: var(--czx-blue-dark); }

.czx-btn:disabled { opacity: 0.6; cursor: default; }

.czx-wrap h2 { margin: 28px 0 12px; font-size: 1.2rem; }

.czx-wrap ol { margin: 0; padding-left: 1.2rem; }

.czx-wrap li { margin: 6px 0; }

.czx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.czx-card {
  display: block;
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--czx-paper);
  border: 1px solid var(--czx-line);
  border-radius: var(--czx-radius);
  color: inherit;
  text-decoration: none;
}

.czx-grid .czx-card { margin: 0; height: 100%; }

.czx-card strong,
.czx-card h2 { display: block; margin: 0 0 6px; font-size: 1.05rem; }

.czx-card p { margin: 0 0 8px; color: var(--czx-muted); }

.czx-card [data-room-online] {
  color: var(--czx-green);
  font-size: 0.85rem;
  font-weight: 750;
}

.czx-card [data-room-online]::after {
  content: " online";
  font-weight: 650;
}

.czx-faq h3 { margin: 16px 0 4px; font-size: 1.02rem; }

.czx-faq p { margin: 0; color: var(--czx-muted); }

footer.czx-wrap { padding-top: 8px; padding-bottom: 48px; }

footer.czx-wrap nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 12px;
}

footer.czx-wrap a {
  color: var(--czx-muted);
  font-weight: 650;
  text-decoration: none;
}

.czx-form-error,
.czx-blocked-note {
  color: var(--czx-danger);
  font-size: 0.92rem;
  font-weight: 650;
}

#czatix-app {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--czx-bg);
  color: var(--czx-ink);
}

html.czx-app-on,
html.czx-app-on body {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

html.czx-app-on body {
  display: flex;
  flex-direction: column;
}

html.czx-app-on .czx-app-host {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

html.czx-app-on #czatix-app {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

html.czx-app-on .czx-app-host > h1 {
  margin: 8px 16px 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.czx-app-on #czatix-lead {
  margin: 2px 16px 8px;
  color: var(--czx-muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.czx-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.czx-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--czx-paper);
  border-bottom: 1px solid var(--czx-line);
}

.czx-brand {
  color: var(--czx-ink);
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.czx-bar-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.czx-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.czx-count {
  color: var(--czx-muted);
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}

.czx-navbtn,
.czx-back,
.czx-leave,
.czx-attach {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--czx-line);
  background: var(--czx-paper);
  font-weight: 700;
}

.czx-navbtn { display: none; }

.czx-leave { color: var(--czx-danger); }

.czx-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 240px;
}

.czx-rooms,
.czx-people {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--czx-paper);
}

.czx-rooms { border-right: 1px solid var(--czx-line); }

.czx-people { border-left: 1px solid var(--czx-line); }

.czx-rooms .czx-input {
  width: calc(100% - 24px);
  margin: 12px 12px 8px;
}

.czx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.czx-group {
  padding: 12px 12px 4px;
  color: var(--czx-muted);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.czx-roomlist { flex: 1 1 auto; overflow: auto; padding-bottom: 8px; }

.czx-dms {
  border-top: 1px solid var(--czx-line);
  max-height: 42%;
  overflow: auto;
}

.czx-people-list,
.czx-dm-list { overflow: auto; padding-bottom: 8px; }

.czx-room,
.czx-person,
.czx-dm {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  min-height: 44px;
  margin: 1px 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-size: 16px;
}

.czx-dm {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.czx-room.is-on,
.czx-dm.is-on { background: var(--czx-soft); color: var(--czx-blue-dark); }

.czx-room span,
.czx-person-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.czx-room b {
  margin-left: auto;
  color: var(--czx-green);
  font-size: 0.78rem;
}

.czx-person:not(:disabled):hover,
.czx-dm:hover,
.czx-room:hover { background: var(--czx-soft); }

.czx-person:disabled { cursor: default; color: var(--czx-muted); }

.czx-person::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--czx-green);
}

.czx-you {
  margin-left: auto;
  color: var(--czx-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.czx-dm-name {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-weight: 750;
}

.czx-dm-preview {
  max-width: 100%;
  color: var(--czx-muted);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.czx-muted-row {
  padding: 8px 16px 16px;
  color: var(--czx-muted);
  font-size: 0.92rem;
}

.czx-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.czx-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.czx-msg {
  align-self: flex-start;
  max-width: min(560px, 86%);
  padding: 8px 12px;
  background: var(--czx-paper);
  border: 1px solid var(--czx-line);
  border-radius: var(--czx-radius);
}

.czx-msg.mine {
  align-self: flex-end;
  background: var(--czx-soft);
  border-color: #d7e3ff;
}

.czx-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.czx-nick { font-weight: 750; color: #1e3a8a; }

.czx-meta time {
  margin-left: auto;
  color: var(--czx-muted);
  font-weight: 650;
}

.czx-body {
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.czx-shot {
  display: block;
  max-width: 280px;
  height: auto;
  object-fit: contain;
  margin-top: 6px;
  border-radius: 12px;
  background: #f4f7fb;
}

.czx-admin {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
}

.czx-msg.mine .czx-admin,
.czx-name .czx-admin,
.czx-person .czx-admin,
.czx-dm-name .czx-admin {
  background: #1d4ed8;
  color: #fff;
}

.czx-empty {
  margin: auto;
  max-width: 280px;
  text-align: center;
  color: var(--czx-muted);
}

.czx-compose {
  background: var(--czx-paper);
  border-top: 1px solid var(--czx-line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.czx-err {
  min-height: 0;
  margin: 0 0 6px;
  color: var(--czx-danger);
  font-size: 0.9rem;
  font-weight: 650;
}

.czx-err:empty { display: none; }

.czx-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.czx-compose textarea {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  resize: none;
  border: 1px solid var(--czx-line);
  border-radius: 12px;
  background: var(--czx-paper);
}

.czx-jump {
  position: absolute;
  left: 50%;
  bottom: 78px;
  z-index: 3;
  transform: translateX(-50%);
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--czx-ink);
  color: #fff;
  font-weight: 750;
}

.czx-gate {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(238, 242, 246, 0.94);
}

.czx-gate-card {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--czx-paper);
  border: 1px solid var(--czx-line);
  border-radius: var(--czx-radius);
  box-shadow: 0 10px 30px rgba(11, 18, 32, 0.06);
}

.czx-gate-card h2 { margin: 0 0 12px; font-size: 1.4rem; }

.czx-gate-card .czx-input { margin-bottom: 10px; }

.czx-gate-card .czx-btn { width: 100%; }

.czx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  border: 0;
  padding: 0;
  background: rgba(11, 18, 32, 0.4);
}

.czx-blocked {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.czx-blocked h2 {
  margin: 0;
  color: var(--czx-danger);
  font-size: 1.4rem;
}

@media (max-width: 820px) {
  .czx-navbtn { display: inline-flex; align-items: center; justify-content: center; }

  .czx-body { display: block; }

  .czx-rooms,
  .czx-people {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 40;
    width: min(320px, 88vw);
    overflow: auto;
    transition: transform 0.2s ease;
  }

  .czx-rooms {
    left: 0;
    transform: translateX(-105%);
    border-right: 1px solid var(--czx-line);
  }

  .czx-people {
    right: 0;
    left: auto;
    transform: translateX(105%);
    border-left: 1px solid var(--czx-line);
  }

  .czx-shell.is-rooms .czx-rooms,
  .czx-shell.is-people .czx-people { transform: none; }

  .czx-main { height: 100%; }

  .czx-compose {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
  }

  .czx-log { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  .czx-jump { bottom: calc(88px + env(safe-area-inset-bottom)); }

  .czx-msg { max-width: 88%; }

  .czx-hero { padding-top: 24px; }
}
