:root {
  color-scheme: light;
  --bg: #ededed;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #888888;
  --line: #d9d9d9;
  --green: #07c160;
  --green-deep: #06ae56;
  --bubble-in: #ffffff;
  --bubble-out: #95ec69;
  --bar: #f7f7f7;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

button { cursor: pointer; }

.atmosphere { display: none; }

.panel, .app { position: relative; z-index: 1; }

h1 {
  margin: 0 0 12px;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.lead, .fine {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.fine a { color: #576b95; }

.primary, .ghost {
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
}

.primary {
  background: var(--green);
  color: #fff;
}

.primary:hover { background: var(--green-deep); }

.primary:disabled { opacity: 0.55; cursor: progress; }

.ghost {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
  font-size: 16px;
}

input[type="radio"],
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--green);
  flex: none;
}

textarea { resize: vertical; line-height: 1.5; }

input:focus, textarea:focus, select:focus { border-color: #b2b2b2; }

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

.row { margin-top: 14px; }

.error {
  min-height: 0;
  margin: 8px 0 0;
  color: #fa5151;
  font-size: 13px;
}

.error:empty { display: none; }

.app {
  position: fixed;
  top: var(--app-offset, 0px);
  left: 0;
  right: 0;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: var(--bg);
}

.shell,
.chat {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wx-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  background: #ededed;
}

.wx-bar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.bar-plus {
  border: 0;
  background: transparent;
  color: #111;
  font-size: 30px;
  line-height: 1;
  padding: 0 2px;
}

.wx-list,
.personas {
  flex: 1;
  overflow: auto;
  background: #fff;
}

.list-empty {
  margin: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.conv {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #f2f2f2;
}

.conv-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 8px 12px 16px;
}

.conv-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-body strong {
  font-size: 17px;
  font-weight: 500;
}

.conv-body small {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-clear {
  flex: none;
  border: 0;
  background: transparent;
  color: #576b95;
  padding: 12px 16px;
  font-size: 14px;
}

.tabbar {
  display: flex;
  flex: none;
  background: #f7f7f7;
  border-top: 1px solid #d6d6d6;
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #181818;
  font-size: 10px;
  padding: 6px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tabbar button[aria-selected="true"] { color: var(--green); }

.tabbar svg {
  width: 26px;
  height: 26px;
}

.tabbar svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.me-card {
  margin: 12px 16px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  display: grid;
  gap: 12px;
}

.install-app {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 10px 14px;
}

.start-group { margin: 12px 16px; }

.modes { padding: 0 16px; }

.legend { padding: 8px 16px 0; }

.modes { display: flex; gap: 8px; }

.modes button,
.persona-tools button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
}

.modes button { flex: 1; padding: 8px 12px; }

.modes button[aria-pressed="true"] {
  border-color: var(--green);
  color: var(--green);
  background: #f3fff8;
}

.legend, .personas legend {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.personas {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  align-content: start;
  gap: 0;
}

.persona {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  cursor: pointer;
}

.persona:has(input) { grid-template-columns: 16px 40px minmax(0, 1fr) auto; }

.persona label { margin: 0; color: inherit; cursor: pointer; }

.persona strong { font-weight: 500; }

.persona-tools { display: flex; gap: 4px; }

.persona-tools button {
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.persona small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.persona:has(input:checked) { background: #f7f7f7; }

.chat {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-bar {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
}

.chat-bar > div {
  position: absolute;
  left: 72px;
  right: 72px;
  text-align: center;
  pointer-events: none;
}

.partner {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.chat-bar .fine,
#model-label { display: none; }

.back {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #111;
  padding: 0;
  font-size: 34px;
  line-height: 1;
}

.key-form {
  margin: 12px;
  padding: 16px 16px 8px;
  border-radius: 8px;
  background: #fff;
}

.key-form h2 {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 20px;
}

.key-form .fine { margin: 0 0 12px; }

.who {
  margin: 0 0 4px 2px;
  color: #888;
  font-size: 12px;
  line-height: 1.2;
}

.transcript {
  flex: 1;
  overflow: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}

.msg.user { justify-content: flex-end; }

.msg.follow { margin-top: -8px; }

.msg.follow .avatar { visibility: hidden; }

.msg.follow .who { display: none; }

.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  overflow: hidden;
  padding: 0;
}

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

.avatar-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.avatar-pick {
  width: 72px;
  height: 72px;
  font-size: 28px;
  border: 0;
}

.avatar-actions {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.stack { max-width: min(460px, calc(100% - 52px)); }

.bubble {
  padding: 9px 12px;
  border-radius: 4px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 16px;
}

.msg.assistant .bubble { background: var(--bubble-in); }

.msg.user .bubble { background: var(--bubble-out); }

.shot {
  display: block;
  width: min(220px, 64vw);
  margin-top: 6px;
  border-radius: 4px;
  background: #e5e5e5;
}

.media-status {
  margin: 6px 0 0;
  color: #888;
  font-size: 12px;
}

.msg.pending .text::after {
  content: "▍";
  margin-left: 1px;
  color: #888;
  animation: blink 1s steps(1) infinite;
}

.empty {
  margin: auto;
  max-width: 280px;
  text-align: center;
  color: var(--muted);
}

.empty strong { display: none; }

.empty p { margin: 0; font-size: 14px; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.suggestions button {
  border: 0;
  background: #fff;
  border-radius: 4px;
  padding: 8px 12px;
  color: #576b95;
  font-size: 14px;
}

.composer {
  padding: 8px 10px 10px;
  background: #f7f7f7;
  border-top: 1px solid #d6d6d6;
}

.composer textarea {
  min-height: 40px;
  max-height: 120px;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 16px;
  line-height: 1.4;
}

.composer-bar,
.composer-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.composer-actions { margin-top: 0; gap: 8px; }

.desktop-hint { display: none; }

.composer-actions .primary,
.composer-actions .ghost {
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 4px;
}

.composer-actions .ghost {
  background: transparent;
  border-color: transparent;
  color: #576b95;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

dialog {
  width: min(420px, calc(100% - 32px));
  padding: 20px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

dialog h2 {
  margin: 0 0 16px;
  font-weight: 600;
  font-size: 18px;
}

dialog label { margin-bottom: 12px; }

dialog label input,
dialog label textarea { margin-top: 6px; }

@keyframes blink {
  50% { opacity: 0; }
}

html, body { overflow: hidden; touch-action: manipulation; }

.chat-bar { padding-top: env(safe-area-inset-top); }

.composer { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }

dialog {
  max-height: calc(100dvh - 24px);
  margin: auto;
  overflow: auto;
}
