:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #7c7f85;
  --line: #e8e9ec;
  --soft: #f6f7f8;
  --red: #e8464b;
  --red-dark: #d6363c;
  --green: #22a06b;
  --blue: #536f9f;
  --shadow: 0 18px 55px rgba(29, 35, 48, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "PingFang SC", "Microsoft YaHei", monospace;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { cursor: pointer; }

.page-header {
  width: min(760px, 100%);
  height: 82px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 22px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #1f2328;
  font: 42px/1 -apple-system, BlinkMacSystemFont, sans-serif;
  text-decoration: none;
}

.settings-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.settings-button span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #676b72;
}

main {
  width: min(650px, 100%);
  margin: 0 auto;
  padding: 42px 26px max(54px, env(safe-area-inset-bottom));
}

.identity {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 26px;
  align-items: center;
  margin-bottom: 36px;
}

.bot-mark {
  width: 82px;
  height: 82px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding-top: 25px;
  border-radius: 10px;
  background: var(--red);
  box-shadow: 0 14px 30px rgba(232, 70, 75, 0.2);
}

.bot-mark i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.identity p:last-child {
  margin: 0;
  color: #555960;
  font-size: 14px;
  line-height: 1.7;
}

.connection-card,
.composer-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.connection-card {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 14px 18px;
  background: var(--soft);
}

.status-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-copy > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.status-copy strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #b2b5ba;
  box-shadow: 0 0 0 5px rgba(178, 181, 186, 0.14);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(34, 160, 107, 0.13);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(232, 70, 75, 0.12);
}

.text-button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

.composer-card,
.history-card { padding: 22px; }

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title.compact {
  align-items: center;
  margin-bottom: 12px;
}

.section-title span,
.dialog-head span {
  color: var(--muted);
  font-size: 11px;
}

.section-title h2,
.dialog-head h2 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.private-label {
  padding: 6px 8px;
  border-radius: 5px;
  background: #edf8f3;
  color: var(--green) !important;
  white-space: nowrap;
}

.message-field {
  position: relative;
  display: block;
}

textarea {
  width: 100%;
  min-height: 166px;
  resize: vertical;
  padding: 16px 16px 34px;
  border: 1px solid #dfe1e5;
  border-radius: 9px;
  outline: 0;
  background: #fbfbfc;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus,
input:focus {
  border-color: rgba(232, 70, 75, 0.65);
  box-shadow: 0 0 0 3px rgba(232, 70, 75, 0.09);
}

textarea::placeholder { color: #a5a8ad; }

.message-field > small {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: #a0a3a8;
  font-size: 10px;
}

.quick-messages {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0 18px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.quick-messages::-webkit-scrollbar { display: none; }

.quick-messages button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #64686f;
  font-size: 11px;
}

.send-button,
.save-button {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  transition: background 160ms ease, transform 160ms ease;
}

.send-button:hover,
.save-button:hover { background: var(--red-dark); }
.send-button:active { transform: translateY(1px); }
.send-button:disabled { cursor: wait; opacity: 0.62; }

.form-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.history-card { margin-top: 14px; }
.history-card ol { margin: 0; padding: 0; list-style: none; }

.history-card li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.history-card li p {
  overflow: hidden;
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card li time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.install-card {
  margin-top: 14px;
  border-bottom: 1px solid var(--line);
}

.install-card summary {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  color: #373a40;
  font-size: 14px;
  font-weight: 700;
}

.install-card summary::-webkit-details-marker { display: none; }

.install-card summary span { display: grid; gap: 5px; }
.install-card summary small { color: var(--muted); font-size: 10px; font-weight: 400; }
.install-card summary i { font-size: 20px; font-style: normal; font-weight: 400; transition: transform 180ms ease; }
.install-card[open] summary i { transform: rotate(45deg); }

.install-body {
  padding: 0 0 22px;
  color: #6f7278;
  font-size: 12px;
  line-height: 1.65;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.command-row code {
  overflow-x: auto;
  padding: 12px;
  border-radius: 7px;
  background: #f2f3f5;
  color: #30343a;
  white-space: nowrap;
}

.command-row button {
  border: 0;
  border-radius: 7px;
  background: #eef1f6;
  color: var(--blue);
  font-weight: 700;
}

.muted { margin: 10px 0 0; color: var(--muted); }
.footer-note { margin: 80px 0 0; color: #8b8e93; font-size: 12px; }

dialog {
  width: min(440px, calc(100% - 30px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(27, 31, 39, 0.25);
  backdrop-filter: blur(3px);
}

dialog form { padding: 22px; }

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: #61656b;
  font-size: 24px;
  line-height: 1;
}

dialog label {
  display: grid;
  gap: 7px;
  margin-bottom: 17px;
}

dialog label > span { font-size: 12px; font-weight: 700; }

dialog input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #dfe1e5;
  border-radius: 7px;
  outline: 0;
  font-size: 12px;
}

dialog label small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.save-button { justify-content: center; }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 7px;
  background: #25282d;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .page-header { height: 68px; padding-inline: 12px; }
  main { padding: 48px 18px 44px; }
  .identity { grid-template-columns: 76px 1fr; gap: 18px; margin-bottom: 30px; }
  .bot-mark { width: 76px; height: 76px; }
  .composer-card, .history-card { padding: 18px; }
}

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