:root {
  color-scheme: light;
  --bg: #f1f4f8;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --material: rgba(255, 255, 255, 0.92);
  --material-soft: rgba(246, 249, 252, 0.9);
  --surface-soft: #f6f8fb;
  --surface-card: #edf2f7;
  --surface-strong: #dfe7f1;
  --surface-dark: #1b2430;
  --surface-dark-elevated: #283443;
  --surface-dark-soft: #223040;
  --line: #e4ebf3;
  --line-strong: #cfd9e6;
  --text: #171b22;
  --body: #343a45;
  --muted: #7a828e;
  --muted-soft: #a9b1bc;
  --accent: #315fa8;
  --accent-dark: #244b88;
  --accent-soft: rgba(49, 95, 168, 0.12);
  --accent-faint: rgba(49, 95, 168, 0.07);
  --accent-gold: #c8ab63;
  --accent-gold-dark: #af934f;
  --danger: #c64545;
  --success: #5db872;
  --bubble-owner: #315fa8;
  --bubble-visitor: #c8ab63;
  --code: #1b2430;
  --on-primary: #ffffff;
  --on-dark: #f5f5f1;
  --on-dark-soft: #aeb3b4;
  --soft-dark: rgba(47, 70, 97, 0.16);
  --soft-dark-subtle: rgba(47, 70, 97, 0.10);
  --soft-light: rgba(255, 255, 255, 0.95);
  --shadow-soft: 0 18px 42px rgba(47, 70, 97, 0.13);
  --shadow-subtle: 0 10px 24px rgba(47, 70, 97, 0.10);
  --shadow-inset: inset 0 1px 3px rgba(47, 70, 97, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9);
  --blur: blur(16px) saturate(1.04);
  --font-display: "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Heiti SC", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Heiti SC", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

body.app-fixed-mode,
body.chat-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  height: 100%;
}

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

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-primary);
  cursor: pointer;
  min-height: 40px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  box-shadow: 0 10px 22px rgba(49, 95, 168, 0.20);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, color 160ms ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 8px 18px rgba(49, 95, 168, 0.22);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 4px 10px rgba(49, 95, 168, 0.18);
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(47, 70, 97, 0.08);
}

button.secondary:hover {
  background: var(--panel-strong);
  border-color: var(--line-strong);
}

button.secondary.active {
  border-color: rgba(49, 95, 168, 0.35);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

button.danger {
  background: var(--danger);
  box-shadow: 0 10px 22px rgba(198, 69, 69, 0.18);
}

button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
  color: var(--text);
  padding: 10px 14px;
  box-shadow: inset 0 1px 2px rgba(47, 70, 97, 0.06), 0 8px 18px rgba(47, 70, 97, 0.06);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-strong);
  box-shadow: inset 0 1px 2px rgba(47, 70, 97, 0.06), 0 0 0 3px rgba(49, 95, 168, 0.16);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

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

.page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.chat-page {
  width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--material);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 12px 30px rgba(47, 70, 97, 0.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-leading {
  display: flex;
  align-items: center;
  min-width: 0;
}

.chat-topbar {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(0, 2.2fr) minmax(72px, 1fr);
}

.chat-topbar .topbar-leading {
  justify-self: start;
}

.chat-topbar .topbar-actions {
  justify-self: end;
  flex-wrap: nowrap;
  min-width: 0;
}

.chat-topbar .brand {
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.chat-topbar .brand > strong,
.chat-topbar .brand > .brand-subtitle {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: grid;
  gap: 1px;
}

.brand strong {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: 0;
}

.brand-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-count-toggle {
  display: inline;
  flex: 0 0 auto;
  min-width: 0;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  color: inherit;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  vertical-align: baseline;
  margin-left: 0;
  box-shadow: none !important;
  transform: none;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.member-count-toggle:hover,
.member-count-toggle:focus,
.member-count-toggle:focus-visible {
  outline: 0;
  background: transparent !important;
  color: var(--accent-dark);
  text-decoration: none;
  opacity: 0.78;
  box-shadow: none !important;
}

.member-count-toggle:active {
  transform: none;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: 0;
}

.chat-topbar .brand strong {
  position: relative;
  max-width: calc(100% - 54px);
  overflow: visible;
  font-size: 26px;
  line-height: 1.08;
}

.chat-topbar .brand-title-text {
  display: block;
  max-width: 100%;
}

.chat-topbar .member-count-toggle {
  position: absolute;
  left: 100%;
  top: 50%;
  margin-left: 8px;
  transform: translateY(-50%);
}

.chat-topbar .member-count-toggle:active {
  transform: translateY(-50%);
}

.chat-topbar .brand > .brand-subtitle {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}

.home {
  width: min(760px, calc(100vw - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 18px;
}

.dashboard {
  width: min(1080px, calc(100vw - 32px));
}

.dashboard-page {
  width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dashboard-page .topbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
}

.dashboard-page .brand {
  grid-column: 2;
  min-width: 0;
  justify-items: center;
  text-align: center;
}

.dashboard-page .brand strong {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.08;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-page .topbar-actions {
  grid-column: 3;
  justify-self: end;
  margin-left: 0;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.24fr) minmax(300px, 0.98fr);
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  align-items: stretch;
  gap: 18px;
  width: min(1360px, calc(100vw - 32px));
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 28px 0;
  overflow: hidden;
}

.usage-panel {
  grid-column: 1;
  grid-row: 1;
}

.dashboard-history-panel {
  grid-column: 3;
  grid-row: 1;
}

.create-room-panel {
  grid-column: 2;
  grid-row: 1;
}

.dashboard-shell > .panel {
  height: 100%;
  min-height: 0;
}

.dashboard-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(20, 20, 19, 0.34);
}

.dashboard-menu-backdrop[hidden],
.dashboard-menu-drawer[hidden] {
  display: none;
}

.dashboard-menu-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(520px, calc(100vw - 24px));
  height: 100vh;
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: -16px 0 42px rgba(20, 20, 19, 0.14);
}

.dashboard-menu-drawer {
  grid-template-rows: auto auto;
  inset: 76px 24px auto auto;
  width: min(360px, calc(100vw - 24px));
  height: auto;
  max-height: min(42vh, 320px);
  overflow: hidden;
  border: 1px solid rgba(250, 249, 245, 0.08);
  border-radius: 22px;
  background: var(--surface-dark);
  color: var(--on-dark);
  border-left-color: rgba(250, 249, 245, 0.08);
}

.dashboard-menu-drawer .history-drawer-header {
  border-bottom-color: rgba(250, 249, 245, 0.08);
  background: var(--surface-dark-elevated);
}

.dashboard-menu-drawer .history-drawer-header strong {
  color: var(--on-dark);
}

.dashboard-menu-drawer .history-drawer-header button.secondary,
.dashboard-menu-drawer button.secondary {
  border-color: rgba(250, 249, 245, 0.12);
  background: var(--surface-dark-elevated);
  color: var(--on-dark);
}

.dashboard-menu-drawer .history-drawer-header button.secondary:hover,
.dashboard-menu-drawer button.secondary:hover {
  background: var(--surface-dark-soft);
  border-color: rgba(250, 249, 245, 0.20);
}

.dashboard-menu-actions {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
}

.dashboard-menu-action {
  justify-content: center;
  min-height: 48px;
  width: 100%;
}

.dashboard-menu-actions .status {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.dashboard-menu-actions .status.error {
  color: #ffb7b7;
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--material);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.history-drawer-header strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.12;
}

.dashboard-menu-toggle,
.mobile-menu-toggle {
  position: relative;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
}

.dashboard-menu-toggle {
  display: inline-flex;
}

.dashboard-menu-toggle::before,
.dashboard-menu-toggle::after,
.mobile-menu-toggle::before,
.mobile-menu-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.dashboard-menu-toggle::before,
.mobile-menu-toggle::before {
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.dashboard-menu-toggle::after,
.mobile-menu-toggle::after {
  display: none;
}

.panel {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-soft);
  align-self: start;
}

.dashboard-shell > .panel {
  align-self: stretch;
}

.usage-panel,
.create-room-panel,
.dashboard-history-panel {
  display: grid;
  align-content: start;
}

.usage-panel {
  gap: 18px;
}

.create-room-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.create-room-panel p {
  max-width: 56ch;
}

.create-room-panel p,
.create-room-panel label,
.dashboard-room-form input,
.dashboard-room-form textarea,
.dashboard-history-heading .status,
.dashboard-history-list .status {
  font-size: 13px;
  line-height: 1.38;
}

.dashboard-history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-history-heading h2 {
  margin-bottom: 0;
}

.dashboard-history-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.dashboard-history-panel {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.dashboard-history-panel .dashboard-history-list {
  gap: 10px;
}

.dashboard-history-list .room-card {
  grid-template-columns: minmax(0, 1fr) 132px;
  align-items: start;
}

.dashboard-history-list .room-card-main strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.24;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-history-list .room-card-main .status {
  overflow-wrap: anywhere;
}

.dashboard-history-list .room-card-actions {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 8px;
}

.dashboard-history-list .room-card-actions button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.dashboard-history-inline {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcfe;
  box-shadow: inset 0 1px 2px rgba(47, 70, 97, 0.05);
}

.dashboard-room-form {
  align-content: stretch;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.dashboard-room-form textarea {
  min-height: 44px;
  height: 44px;
  resize: none;
}

.dashboard-form-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.dashboard-page-footer {
  border-top: 1px solid var(--line);
  background: var(--material);
  box-shadow: 0 -12px 30px rgba(47, 70, 97, 0.08);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 12px 24px max(12px, env(safe-area-inset-bottom));
}

.dashboard-page-footer-inner {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.24fr) minmax(300px, 0.98fr);
  gap: 18px;
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
}

.dashboard-page-footer .dashboard-form-footer {
  grid-column: 2 / 4;
}

.invite-ttl-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 54px;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfcfe;
  box-shadow: inset 0 1px 2px rgba(47, 70, 97, 0.06), 0 8px 18px rgba(47, 70, 97, 0.06);
}

.invite-ttl-field span {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
}

.invite-ttl-field input {
  grid-column: 1;
  grid-row: 1;
  width: 42px;
  min-height: 24px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  appearance: textfield;
  -moz-appearance: textfield;
}

.invite-ttl-field input:focus {
  background: transparent;
  box-shadow: none;
}

.invite-ttl-field input::-webkit-outer-spin-button,
.invite-ttl-field input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.dashboard-form-footer button[type="submit"] {
  min-height: 54px;
  width: 132px;
  align-self: stretch;
  justify-self: end;
  padding: 0 14px;
  white-space: nowrap;
}

.usage-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2px 12px;
}

.usage-heading h2 {
  margin-bottom: 0;
}

.usage-heading > strong {
  grid-row: span 2;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 400;
  line-height: 0.9;
}

.usage-heading > span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.panel h1,
.panel h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.panel p {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.usage-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-card);
}

.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.usage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.usage-grid > div {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 72px;
  overflow: hidden;
  padding: 15px 14px 13px;
  border: 1px solid #d8e4f1;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.36)),
    linear-gradient(180deg, #fbfdff 0%, #eef4fb 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(47, 70, 97, 0.04),
    0 10px 22px rgba(47, 70, 97, 0.12);
}

.usage-grid > div::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: rgba(49, 95, 168, 0.28);
}

.usage-grid > div:nth-child(2)::before {
  background: rgba(93, 184, 114, 0.34);
}

.usage-grid > div:nth-child(3)::before {
  background: rgba(200, 171, 99, 0.42);
}

.usage-grid span,
.usage-grid small {
  color: #6f7b8b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.15;
}

.usage-grid strong {
  color: var(--text);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.usage-grid small {
  display: block;
}

.usage-note {
  margin-top: auto;
  padding-top: 4px;
  font-size: 13px;
}

.usage-sync-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.usage-sync-row button {
  flex: 0 0 auto;
}

.usage-sync-row .error {
  color: var(--danger);
}

.room-history {
  display: grid;
  gap: 12px;
}

.room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-subtle);
}

.room-card-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.room-card-actions {
  display: flex;
  align-items: start;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.room-preview {
  overflow-wrap: anywhere;
  border-radius: 10px;
  background: var(--code);
  color: var(--on-dark-soft);
  font-size: 14px;
  line-height: 1.43;
  padding: 10px 12px;
}

.chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

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

.timeline {
  --chat-edge: clamp(18px, 3vw, 46px);
  --avatar-size: 36px;
  --bubble-gap: 12px;
  overflow-y: auto;
  min-height: 0;
  padding: 22px var(--chat-edge);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.message-row {
  display: flex;
  align-items: center;
  gap: var(--bubble-gap);
  width: 100%;
}

.message-row.owner {
  align-self: stretch;
  flex-direction: row-reverse;
}

.message-stack {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: min(72%, calc(100% - var(--avatar-size) - var(--bubble-gap)));
}

.message-row.owner .message-stack {
  justify-items: end;
}

.message-avatar {
  display: grid;
  flex: 0 0 var(--avatar-size);
  width: var(--avatar-size);
  height: var(--avatar-size);
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: var(--shadow-subtle);
}

.message-name {
  display: none;
}

.time-notice {
  align-self: center;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1;
  padding: 2px 0;
}

.message {
  position: relative;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px 15px 15px 5px;
  box-shadow: 0 10px 22px rgba(47, 70, 97, 0.10);
  padding: 11px 13px;
  background: var(--bubble-visitor);
  color: var(--on-primary);
}

.message.owner {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 15px 15px 5px 15px;
  background: var(--bubble-owner);
  color: var(--on-primary);
  box-shadow: 0 10px 22px rgba(49, 95, 168, 0.18);
}

.message::before {
  content: "";
  position: absolute;
  left: -5px;
  bottom: 11px;
  display: block;
  width: 10px;
  height: 10px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: inherit;
  transform: rotate(45deg);
}

.message.owner::before {
  right: -5px;
  left: auto;
  border: 0;
}

.source {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

.attachment-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: min(260px, 64vw);
  color: inherit;
  text-decoration: none;
}

.attachment-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 28px;
  border: 2px solid currentColor;
  border-radius: 5px;
  opacity: 0.9;
}

.attachment-icon::before {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 0 5px 0 4px;
  background: rgba(255, 255, 255, 0.18);
}

.attachment-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.attachment-copy strong,
.attachment-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-copy strong {
  font-size: 14px;
  font-weight: 600;
}

.attachment-copy small {
  font-size: 11px;
  opacity: 0.78;
}

.composer {
  position: relative;
  z-index: 4;
  border-top: 1px solid var(--line);
  background: var(--material);
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 -12px 30px rgba(47, 70, 97, 0.08);
  transform: translateY(calc(-1 * var(--keyboard-offset, 0px)));
  transition: transform 120ms ease;
}

.composer > .status:empty {
  display: none;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.composer textarea {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  max-height: 96px;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 22px;
  resize: none;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(47, 70, 97, 0.08);
  letter-spacing: 0;
}

.file-upload-toggle {
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  padding: 0;
  color: var(--muted);
  font-size: 0;
  line-height: 1;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(47, 70, 97, 0.08);
}

.file-input {
  display: none;
}

.file-upload-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer button[type="submit"] {
  flex: 0 0 64px;
  width: 64px;
  min-width: 0;
  min-height: 40px;
  border-radius: 999px;
  padding: 0 14px;
}

.composer-settings-toggle {
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  place-items: center;
  position: relative;
  min-width: 40px;
  width: 40px;
  min-height: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  font-size: 0;
  line-height: 0;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(47, 70, 97, 0.08);
  color: var(--accent-dark);
}

.composer-settings-toggle::before,
.composer-settings-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.composer-settings-toggle::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.composer-settings-toggle.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.quick-settings {
  display: grid;
  gap: 8px;
  width: 100%;
}

.quick-settings[hidden],
.quick-choice-panel[hidden] {
  display: none;
}

.quick-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-action-button,
.choice-button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  border-radius: 8px;
  box-shadow: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

.quick-action-button:hover,
.choice-button:hover,
.choice-button.active {
  border-color: rgba(204, 120, 92, 0.42);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.quick-choice-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 12px;
  box-shadow: var(--shadow-subtle);
}

.quick-choice-panel strong {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.tone-choice-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.side {
  border-left: 1px solid rgba(250, 249, 245, 0.08);
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}

.side strong,
.members-drawer strong {
  color: var(--on-dark);
  font-weight: 500;
}

.side .status,
.members-drawer .status {
  color: var(--on-dark-soft);
}

.side button.secondary,
.members-drawer button.secondary {
  border-color: rgba(250, 249, 245, 0.12);
  background: var(--surface-dark-elevated);
  color: var(--on-dark);
}

.side button.secondary:hover,
.members-drawer button.secondary:hover {
  background: var(--surface-dark-soft);
  border-color: rgba(250, 249, 245, 0.20);
}

.mobile-menu-toggle {
  display: none;
  position: relative;
  width: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
}

.mobile-menu-toggle::before,
.mobile-menu-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.mobile-menu-toggle::before {
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.mobile-menu-toggle::after {
  display: none;
}

.mobile-member-toggle {
  display: none;
}

.side-drawer-header {
  display: none;
}

.visitor-chat-page .chat-shell {
  grid-template-columns: 1fr;
  position: relative;
}

.visitor-chat-page .mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0;
}

.visitor-chat-page .mobile-member-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
}

.visitor-chat-page .side,
.visitor-chat-page .members-drawer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  max-height: min(78dvh, 640px);
  border-top: 1px solid rgba(250, 249, 245, 0.08);
  border-left: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface-dark);
  box-shadow: 0 -1px 0 rgba(250, 249, 245, 0.08);
  transform: translateY(105%);
  transition: transform 180ms ease;
  padding: 0 16px 16px;
}

.side-open .visitor-chat-page .chat-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(20, 20, 19, 0.34);
}

.members-open .visitor-chat-page .chat-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(20, 20, 19, 0.34);
}

.side-open .visitor-chat-page .side {
  transform: translateY(0);
}

.members-open .visitor-chat-page .members-drawer {
  transform: translateY(0);
}

.visitor-chat-page .side-drawer-header {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 2;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 58px;
  margin: 0 -16px 12px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(250, 249, 245, 0.08);
  border-radius: 16px 16px 0 0;
  background: var(--surface-dark-elevated);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.visitor-chat-page .side-drawer-header strong {
  font-size: 18px;
}

.visitor-chat-page .side-close-button {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-dark-soft);
  color: var(--on-dark);
}

.visitor-chat-page .side-close-button::before,
.visitor-chat-page .side-close-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.visitor-chat-page .side-close-button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.visitor-chat-page .side-close-button:hover {
  background: var(--surface-dark-elevated);
}

.visitor-chat-page .side-section {
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.side-action-grid {
  grid-template-columns: 1fr 1fr;
}

.members-drawer {
  display: none;
  align-content: start;
  gap: 10px;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  max-height: min(78dvh, 640px);
  border-top: 1px solid rgba(250, 249, 245, 0.08);
  border-left: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface-dark);
  color: var(--on-dark);
  box-shadow: 0 -1px 0 rgba(250, 249, 245, 0.08);
  padding: 0 16px 16px;
  overflow-y: auto;
  min-height: 0;
}

.members-open .members-drawer {
  display: grid;
}

.side-section {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(250, 249, 245, 0.10);
}

.share-panel {
  display: none;
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px;
  border: 1px solid rgba(250, 249, 245, 0.10);
  border-radius: 12px;
  background: var(--surface-dark-elevated);
  box-shadow: none;
}

.member-card.has-action {
  grid-template-columns: 40px minmax(0, 1fr) auto;
}

.member-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.22);
}

.member-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--on-dark);
  font-weight: 600;
}

.member-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.member-copy span,
.member-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-copy small {
  color: var(--on-dark-soft);
  font-size: 12px;
}

.member-kick-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.side-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.share-box {
  display: grid;
  gap: 10px;
}

.share-url {
  overflow-wrap: anywhere;
  background: var(--surface-dark-elevated);
  color: var(--on-dark-soft);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
}

.backup-share {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid rgba(250, 249, 245, 0.10);
}

.share-url.copy-selected {
  outline: 3px solid rgba(204, 120, 92, 0.22);
  background: var(--accent-soft);
}

.network-links {
  display: grid;
  gap: 8px;
}

.provider-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.provider-badge {
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.25;
  padding: 7px 8px;
}

.provider-badge.ready {
  background: rgba(93, 184, 114, 0.14);
  color: #b9e7c4;
}

.provider-badge.missing {
  background: rgba(250, 249, 245, 0.08);
  color: var(--on-dark-soft);
}

.auto-route {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.side .auto-route {
  color: var(--on-dark-soft);
}

.qr {
  width: 220px;
  max-width: 100%;
  border: 1px solid rgba(250, 249, 245, 0.10);
  border-radius: 12px;
  box-shadow: none;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
}

.system-notice {
  align-self: center;
  max-width: min(620px, 100%);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.notice-name {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  box-shadow: none;
  text-shadow: none;
  transform: none;
  appearance: none;
}

.notice-name:hover,
.notice-name:focus-visible,
.notice-name:active {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  box-shadow: none;
  transform: none;
}

.owner-login-page {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  grid-template-rows: 1fr;
  overflow: hidden;
  background:
    radial-gradient(circle at 35% 18%, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0) 33%),
    radial-gradient(circle at 72% 80%, rgba(177, 191, 210, 0.34), rgba(177, 191, 210, 0) 38%),
    linear-gradient(145deg, #f3f7fb 0%, #dfe7f0 52%, #eef3f8 100%);
}

.owner-login-page::before,
.owner-login-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  pointer-events: none;
}

.owner-login-page::before {
  width: 360px;
  height: 360px;
  left: max(-110px, calc(50% - 520px));
  top: max(-90px, 5vh);
  background: rgba(255, 255, 255, 0.46);
  filter: blur(32px);
}

.owner-login-page::after {
  width: 420px;
  height: 420px;
  right: max(-150px, calc(50% - 560px));
  bottom: -160px;
  background: rgba(102, 122, 149, 0.18);
  filter: blur(38px);
}

.owner-login-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(22px, 6vw, 48px);
}

.owner-login-card {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(420px, 100%);
  min-height: min(540px, calc(100svh - 44px));
  padding: 74px clamp(26px, 6vw, 44px) 42px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 44px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88) 0%, rgba(232, 239, 247, 0.92) 48%, rgba(216, 226, 238, 0.88) 100%),
    #e7eef6;
  box-shadow:
    30px 36px 62px rgba(77, 95, 118, 0.27),
    -20px -22px 44px rgba(255, 255, 255, 0.96),
    inset 2px 2px 3px rgba(255, 255, 255, 0.92),
    inset -5px -6px 12px rgba(121, 141, 166, 0.13);
}

.owner-login-card::before {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border-radius: 34px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 44%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.72),
    inset -1px -1px 0 rgba(103, 121, 145, 0.06);
}

.owner-login-card::after {
  content: "";
  position: absolute;
  left: 52px;
  right: 52px;
  bottom: -18px;
  z-index: -1;
  height: 28px;
  border-radius: 999px;
  background: rgba(72, 88, 109, 0.18);
  filter: blur(16px);
  pointer-events: none;
}

.owner-login-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  margin-bottom: 28px;
  border: 9px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 24%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 33%),
    linear-gradient(145deg, #24334a 0%, #080c14 62%, #020408 100%);
  color: #f7fbff;
  box-shadow:
    13px 18px 28px rgba(72, 88, 109, 0.26),
    -9px -10px 18px rgba(255, 255, 255, 0.94),
    inset 3px 3px 8px rgba(255, 255, 255, 0.08),
    inset -7px -8px 16px rgba(0, 0, 0, 0.42);
}

.owner-login-mark::after {
  content: "";
  position: absolute;
  inset: 8px 10px auto;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.owner-login-mark span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  color: #ffffff;
  font-family: "PingFang SC", "Microsoft YaHei", "Heiti SC", var(--font-display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 8px rgba(49, 95, 168, 0.45),
    0 -1px 0 rgba(255, 255, 255, 0.18);
  transform: translate(2px, -1px);
}

.owner-login-copy {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 58px;
  text-align: center;
}

.owner-login-copy h1 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(34px, 8vw, 42px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
}

.owner-login-copy p {
  max-width: 18em;
  margin: 0;
  color: #6f7c8d;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.08em;
}

.owner-login-form {
  display: grid;
  width: 100%;
  gap: 22px;
}

.owner-login-field {
  position: relative;
  display: block;
  color: var(--muted);
}

.owner-login-label {
  position: absolute;
  left: 58px;
  top: 50%;
  z-index: 1;
  color: #8993a1;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  transform: translateY(-50%);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.owner-login-field:focus-within .owner-login-label,
.owner-login-field:has(input:not(:placeholder-shown)) .owner-login-label {
  opacity: 0;
  transform: translateY(-50%) translateX(8px);
}

.owner-login-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #1d2530;
  transform: translateY(-50%);
  pointer-events: none;
}

.owner-login-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.owner-login-field input {
  min-height: 64px;
  padding: 0 22px 0 58px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(222, 230, 240, 0.96), rgba(247, 250, 253, 0.86)),
    #e8eef6;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  box-shadow:
    inset 9px 9px 16px rgba(94, 111, 134, 0.20),
    inset -10px -10px 18px rgba(255, 255, 255, 0.98),
    0 1px 0 rgba(255, 255, 255, 0.92),
    0 9px 18px rgba(104, 121, 143, 0.08);
}

.owner-login-field input:focus {
  background:
    linear-gradient(145deg, rgba(232, 239, 247, 0.98), rgba(255, 255, 255, 0.9)),
    #f1f6fb;
  box-shadow:
    inset 7px 7px 13px rgba(94, 111, 134, 0.16),
    inset -9px -9px 17px rgba(255, 255, 255, 0.98),
    0 0 0 4px rgba(49, 95, 168, 0.12),
    0 9px 18px rgba(104, 121, 143, 0.08);
}

.owner-login-form button[type="submit"] {
  position: relative;
  overflow: hidden;
  min-height: 64px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 44%),
    linear-gradient(145deg, #447fd0 0%, #315fa8 50%, #214985 100%);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  box-shadow:
    14px 17px 28px rgba(34, 76, 142, 0.36),
    -8px -8px 16px rgba(255, 255, 255, 0.78),
    inset 1px 1px 0 rgba(255, 255, 255, 0.46),
    inset -2px -6px 12px rgba(20, 54, 106, 0.30);
}

.owner-login-form button[type="submit"]::before {
  content: "";
  position: absolute;
  inset: 6px 18px auto;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
  opacity: 0.82;
  pointer-events: none;
}

.owner-login-form button[type="submit"]::after {
  content: "";
  position: absolute;
  inset: auto 18px 7px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 28, 63, 0), rgba(8, 28, 63, 0.18));
  pointer-events: none;
}

.owner-login-form button[type="submit"]:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 42%),
    linear-gradient(145deg, #407bd0 0%, #2e5da4 48%, #204a89 100%);
  box-shadow:
    10px 14px 24px rgba(34, 76, 142, 0.36),
    -6px -6px 13px rgba(255, 255, 255, 0.74),
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    inset 0 -4px 10px rgba(20, 54, 106, 0.28);
}

.owner-login-form button[type="submit"]:active {
  box-shadow:
    5px 7px 14px rgba(34, 76, 142, 0.25),
    -4px -4px 10px rgba(255, 255, 255, 0.68),
    inset 0 3px 8px rgba(20, 54, 106, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.owner-login-form button[type="submit"]:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.owner-login-form .status {
  min-height: 22px;
  margin-top: -6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 520px) {
  .owner-login-shell {
    padding: 18px;
  }

  .owner-login-card {
    min-height: min(520px, calc(100svh - 36px));
    padding: 56px 26px 34px;
    border-radius: 36px;
  }

  .owner-login-mark {
    width: 78px;
    height: 78px;
    margin-bottom: 24px;
    border-width: 8px;
  }

  .owner-login-mark span {
    font-size: 31px;
  }

  .owner-login-copy {
    margin-bottom: 42px;
  }

  .owner-login-copy p {
    font-size: 12px;
    letter-spacing: 0.05em;
  }

  .owner-login-field input,
  .owner-login-form button[type="submit"] {
    min-height: 58px;
  }
}

.join-box {
  width: min(460px, calc(100vw - 32px));
  margin: 42px auto;
}

.join-login-page .owner-login-card {
  min-height: min(560px, calc(100svh - 44px));
}

.join-login-card .owner-login-copy {
  margin-bottom: 42px;
}

.join-login-form {
  gap: 18px;
}

.join-select-field .owner-login-label {
  display: none;
}

.join-select-field:focus-within .owner-login-label {
  display: none;
}

.join-select-field select {
  min-height: 64px;
  padding: 0 48px 0 58px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(222, 230, 240, 0.96), rgba(247, 250, 253, 0.86)),
    #e8eef6;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  box-shadow:
    inset 9px 9px 16px rgba(94, 111, 134, 0.20),
    inset -10px -10px 18px rgba(255, 255, 255, 0.98),
    0 1px 0 rgba(255, 255, 255, 0.92),
    0 9px 18px rgba(104, 121, 143, 0.08);
}

@media (max-width: 860px) {
  .home {
    grid-template-columns: 1fr;
  }

  .dashboard-page {
    height: 100svh;
    max-height: 100svh;
  }

  .chat-page {
    height: 100dvh;
  }

  .chat-shell {
    grid-template-columns: 1fr;
    position: relative;
  }

  .dashboard-page .topbar {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    min-height: 64px;
    padding: 8px 16px;
  }

  .dashboard-page .brand strong {
    font-size: 29px;
    font-weight: 700;
    line-height: 1.08;
  }

  .dashboard-page .topbar-actions {
    grid-column: 3;
    justify-self: end;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .dashboard-page .topbar-actions button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .dashboard-page .topbar-actions .dashboard-menu-toggle {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 0;
  }

  .dashboard-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 104px minmax(0, 1fr) clamp(204px, 27svh, 224px);
    align-content: stretch;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 8px 12px 8px;
    overflow: hidden;
  }

  .dashboard-shell > .panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 9px 14px;
    border-radius: 14px;
  }

  .usage-panel,
  .create-room-panel,
  .dashboard-history-panel {
    grid-column: 1;
  }

  .usage-panel {
    grid-row: 1;
  }

  .dashboard-history-panel {
    grid-row: 2;
  }

  .create-room-panel {
    grid-row: 3;
  }

  .usage-panel {
    grid-template-columns: minmax(96px, 0.72fr) minmax(0, 1.28fr);
    grid-template-rows: 8px minmax(0, 1fr);
    align-items: center;
    gap: 6px 10px;
  }

  .dashboard-page .panel h1,
  .dashboard-page .panel h2 {
    margin-bottom: 0;
    font-size: 20px;
    line-height: 1.12;
    font-weight: 600;
    letter-spacing: 0;
  }

  .usage-heading {
    grid-column: 1;
    grid-row: 1 / 3;
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    align-items: start;
    gap: 2px;
  }

  .usage-heading h2 {
    font-size: 20px;
  }

  .usage-heading > strong {
    grid-row: auto;
    font-size: clamp(30px, 9vw, 38px);
  }

  .usage-heading > span {
    align-self: start;
    font-size: 12px;
  }

  .usage-bar {
    grid-column: 2;
    grid-row: 1;
    height: 7px;
  }

  .usage-grid {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .usage-grid > div {
    min-height: 56px;
    gap: 5px;
    padding: 10px 9px 8px;
    border-radius: 10px;
  }

  .usage-grid span,
  .usage-grid small {
    font-size: 9px;
  }

  .usage-grid strong {
    font-size: clamp(13px, 3.5vw, 16px);
    line-height: 1.1;
  }

  .usage-note {
    display: none;
  }

  .usage-sync-row {
    display: none;
  }

  .create-room-panel {
    grid-template-rows: auto auto auto;
    align-content: center;
    gap: 5px;
    padding: 14px;
  }

  .create-room-panel p {
    margin: 0;
    font-size: 12px;
    line-height: 1.2;
  }

  .dashboard-room-form {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 5px;
    height: auto;
  }

  .dashboard-history-panel .dashboard-history-list {
    padding-bottom: 16px;
  }

  .dashboard-room-form > label {
    gap: 4px;
    font-size: 12px;
  }

  .dashboard-room-form > label:nth-of-type(1),
  .dashboard-room-form > label:nth-of-type(2) {
    grid-column: 1 / -1;
  }

  .dashboard-room-form > label:nth-of-type(1) {
    grid-row: 1;
  }

  .dashboard-room-form > label:nth-of-type(2) {
    grid-row: 2;
  }

  .dashboard-form-footer {
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 8px;
    min-height: 44px;
  }

  .dashboard-page-footer {
    min-height: 64px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  .dashboard-page-footer-inner {
    display: block;
    width: 100%;
  }

  .dashboard-room-form input,
  .dashboard-room-form textarea {
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
  }

  .invite-ttl-field {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 44px;
    padding: 5px 12px;
    border-radius: 14px;
  }

  .invite-ttl-field span {
    font-size: 10px;
    line-height: 1.15;
  }

  .invite-ttl-field input {
    min-height: 20px;
    width: 34px;
    padding: 0;
    font-size: 15px;
  }

  .dashboard-form-footer button[type="submit"] {
    width: 96px;
    min-height: 44px;
    padding: 0 8px;
    font-size: 12px;
  }

  .dashboard-room-form textarea {
    height: 34px;
    min-height: 34px;
    resize: none;
  }

  .dashboard-menu-drawer {
    inset: auto 0 0;
    width: 100%;
    height: auto;
    max-height: min(34dvh, 280px);
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 16px 16px 0 0;
  }

  .dashboard-history-heading .status {
    font-size: 11px;
  }

  .dashboard-history-list {
    gap: 6px;
  }

  .dashboard-history-list .room-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
    border-radius: 10px;
  }

  .dashboard-history-list .room-card-main {
    gap: 1px;
  }

  .dashboard-history-list .room-card-main strong {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-history-list .room-card-main .status {
    font-size: 10px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-history-list .room-preview {
    display: none;
  }

  .dashboard-history-list .room-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 4px;
  }

  .dashboard-history-list .room-card-actions button {
    min-height: 26px;
    padding: 0 7px;
    font-size: 10px;
  }

  .dashboard-menu-drawer {
    border-top-color: rgba(250, 249, 245, 0.08);
  }

  .topbar {
    align-items: center;
    gap: 8px;
    min-height: 64px;
    padding: 8px 16px;
  }

  .brand {
    min-width: 0;
  }

  .brand strong {
    font-size: 24px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-subtitle {
    max-width: 58vw;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .chat-topbar {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .chat-topbar .topbar-actions {
    margin-left: 0;
  }

  .chat-topbar .brand {
    max-width: 100%;
  }

  .chat-topbar .brand strong {
    font-size: 25px;
    line-height: 1.08;
  }

  .chat-topbar .brand > .brand-subtitle {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.2;
  }

  .chat-page .home-button {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .mobile-member-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
  }

  .timeline {
    --chat-edge: clamp(12px, 3.2vw, 20px);
    --avatar-size: 36px;
    --bubble-gap: clamp(8px, 2vw, 12px);
    gap: 12px;
    padding: 14px var(--chat-edge);
    background: var(--bg);
  }

  .message-row {
    width: 100%;
    gap: var(--bubble-gap);
  }

  .message-row.owner {
    align-self: stretch;
  }

  .message-stack {
    max-width: min(82%, calc(100% - var(--avatar-size) - var(--bubble-gap)));
  }

  .message-avatar {
    flex: 0 0 var(--avatar-size);
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    background: var(--panel-strong);
    box-shadow: none;
  }

  .message-name {
    display: none;
  }

  .time-notice {
    background: transparent;
    color: var(--muted-soft);
    padding: 2px 0;
  }

  .message {
    position: relative;
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 15px 15px 15px 5px;
    box-shadow: 0 10px 22px rgba(47, 70, 97, 0.10);
    padding: 11px 13px;
    background: var(--bubble-visitor);
    color: var(--on-primary);
  }

  .message.owner {
    border-color: transparent;
    border-radius: 15px 15px 5px 15px;
    background: var(--bubble-owner);
    color: var(--on-primary);
    box-shadow: 0 10px 22px rgba(49, 95, 168, 0.18);
  }

  .message::before {
    content: "";
    position: absolute;
    left: -5px;
    bottom: 11px;
    display: block;
    width: 10px;
    height: 10px;
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: inherit;
    transform: rotate(45deg);
  }

  .message.owner::before {
    right: -5px;
    left: auto;
    border: 0;
  }

  .source {
    font-size: 16px;
    line-height: 1.55;
  }

  .system-notice {
    max-width: 94%;
    border-radius: 0;
    padding: 2px 8px;
  }

  .composer {
    gap: 8px;
    min-height: 64px;
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  }

  .composer-row {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .composer textarea {
    order: 1;
    height: 44px;
    min-height: 44px;
    max-height: 96px;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 22px;
    resize: none;
  }

  .composer-settings-toggle {
    order: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    place-items: center;
    position: relative;
    min-width: 40px;
    width: 40px;
    min-height: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    color: var(--accent-dark);
    font-size: 0;
    line-height: 0;
  }

  .composer-settings-toggle::before,
  .composer-settings-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform: translate(-50%, -50%);
  }

  .composer-settings-toggle::after {
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .composer-settings-toggle.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
  }

  .file-upload-toggle {
    order: 2;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
  }

  .composer button[type="submit"] {
    display: none;
  }

  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .side {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    max-height: min(78dvh, 640px);
    border-top: 1px solid rgba(250, 249, 245, 0.08);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    background: var(--surface-dark);
    color: var(--on-dark);
    box-shadow: 0 -1px 0 rgba(250, 249, 245, 0.08);
    transform: translateY(105%);
    transition: transform 180ms ease;
    padding: 0 16px 16px;
  }

  .side-open .chat-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(20, 20, 19, 0.34);
  }

  .members-open .chat-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(20, 20, 19, 0.34);
  }

  .side-open .side {
    transform: translateY(0);
  }

  .side-drawer-header {
    display: grid;
  }

  .side-drawer-header {
    position: sticky;
    top: 0;
    z-index: 2;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 58px;
    margin: 0 -16px 12px;
    padding: 12px 16px 10px;
    border-bottom: 1px solid rgba(250, 249, 245, 0.08);
    border-radius: 16px 16px 0 0;
    background: var(--surface-dark-elevated);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
  }

  .side-drawer-header strong {
    font-size: 18px;
  }

  .side-close-button {
    position: relative;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface-dark-soft);
    color: var(--on-dark);
  }

  .side-close-button::before,
  .side-close-button::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 17px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .side-close-button::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .side-close-button:hover {
    background: var(--surface-dark-elevated);
  }

  .side-section {
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .share-panel {
    display: grid;
  }

  .qr {
    width: 160px;
    justify-self: center;
  }

  .room-card {
    grid-template-columns: 1fr;
  }

  .room-card-actions {
    justify-content: stretch;
  }

  .room-card-actions button {
    flex: 1 1 140px;
  }
}

@media (max-width: 430px) {
  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tone-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
