/* AFC chat. No outside fonts or files: everything must load in mainland China. */

:root {
  --bg: #ffffff;
  --side: #f6f6f4;
  --line: #e4e3df;
  --ink: #1c1c1a;
  --quiet: #6d6c67;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --mine: #e9f0fb;
  --pick: #e8e7e2;
  --danger: #b3261e;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a;
    --side: #1f1f22;
    --line: #333338;
    --ink: #eeeeea;
    --quiet: #a3a29c;
    --accent: #7fb0ff;
    --accent-ink: #10203a;
    --mine: #24344f;
    --pick: #2c2c31;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.quiet { color: var(--quiet); font-size: 0.875rem; }
.error { color: var(--danger); font-size: 0.875rem; margin: 0; }

button.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 0.6rem 1.1rem; font-weight: 600; min-height: 44px;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.plain { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 1.1rem; min-height: 44px; }
button.link { background: none; border: 0; color: var(--accent); padding: 0.5rem 0.6rem; min-height: 44px; }
button.link.danger { color: var(--danger); }
button.icon { background: none; border: 0; font-size: 1.25rem; width: 44px; height: 44px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: grid; gap: 0.3rem; font-size: 0.875rem; color: var(--quiet); }
input, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem;
  font-size: 1rem; color: var(--ink); width: 100%;
}
textarea { resize: none; }

/* Log in */
.login { min-height: 100%; display: grid; place-items: center; padding: 1.5rem; background: var(--side); }
.card { width: min(22rem, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; display: grid; gap: 0.9rem; }
.card h1 { margin: 0; font-size: 1.35rem; }
.card p { margin: 0; }

/* Layout */
.app { height: 100%; height: 100dvh; display: grid; grid-template-columns: 17rem 1fr; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1rem 0.5rem; min-height: 56px; }
.bot-list { flex: 1; overflow-y: auto; padding: 0.25rem 0.5rem; display: grid; gap: 2px; align-content: start; }
.bot {
  display: grid; grid-template-columns: 2.25rem 1fr; gap: 0.6rem; align-items: center; text-align: left;
  background: none; border: 0; border-radius: 10px; padding: 0.55rem 0.5rem; width: 100%; min-height: 52px;
}
.bot:hover { background: var(--pick); }
.bot[aria-current="true"] { background: var(--pick); }
.bot .face {
  width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.95rem;
}
.bot.made .face { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.bot .words { min-width: 0; display: grid; }
.bot .words strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot .words span { color: var(--quiet); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { color: var(--quiet); font-size: 0.75rem; padding: 0.8rem 0.5rem 0.2rem; }
.new-bot { margin: 0.5rem; background: none; border: 1px dashed var(--line); border-radius: 10px; padding: 0.7rem; min-height: 44px; color: var(--ink); }
.new-bot:hover { background: var(--pick); }
.side-foot { display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 0.5rem 0.5rem 1rem; border-top: 1px solid var(--line); color: var(--quiet); font-size: 0.875rem; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 0.25rem; padding: 0.4rem 0.75rem 0.4rem 1.25rem; border-bottom: 1px solid var(--line); min-height: 56px; }
.top-text { flex: 1; min-width: 0; display: grid; }
.top-text strong, .top-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }
.thread > * { width: min(46rem, 100%); margin-inline: auto; }
.hello { text-align: center; margin-block: auto; display: grid; gap: 0.75rem; justify-items: center; padding: 2rem 0; }
.hello .face { width: 3.5rem; height: 3.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 1.4rem; font-weight: 700; }
.hello h2 { margin: 0; font-size: 1.25rem; }
.hello p { margin: 0; color: var(--quiet); max-width: 28rem; }
.tries { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.try { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.5rem 0.9rem; min-height: 44px; }
.try:hover { background: var(--pick); }

.msg { display: flex; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 100%; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--mine); border-radius: 16px 16px 4px 16px; padding: 0.6rem 0.9rem; max-width: 85%; white-space: pre-wrap; }
.msg.bot .bubble > :first-child { margin-top: 0; }
.msg.bot .bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0.5rem 0; }
.bubble ul, .bubble ol { margin: 0.5rem 0; padding-left: 1.4rem; }
.bubble li { margin: 0.15rem 0; }
.bubble a { color: var(--accent); }
.bubble code { background: var(--side); border-radius: 4px; padding: 0.05rem 0.3rem; font-size: 0.9em; }
.busy { color: var(--quiet); font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; }
.busy::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .busy::before { animation: none; } }
.note { color: var(--danger); font-size: 0.875rem; }

.send { display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.75rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.send textarea { flex: 1; max-height: 9rem; border-radius: 14px; }
.send > * { margin: 0; }
.send { justify-content: center; }
.send textarea { max-width: 40rem; }

/* Make a helper */
.maker { border: 1px solid var(--line); border-radius: 16px; padding: 1.25rem; width: min(26rem, calc(100% - 2rem)); background: var(--bg); color: var(--ink); }
.maker::backdrop { background: rgba(0, 0, 0, 0.4); }
.maker form { display: grid; gap: 0.9rem; }
.maker h2 { margin: 0; font-size: 1.15rem; }
.maker p { margin: 0; }
.row { display: flex; justify-content: flex-end; gap: 0.5rem; }

.only-phone { display: none; }
.shade { display: none; }

/* Phones: the list of helpers slides in from the left */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .only-phone { display: inline-grid; place-items: center; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(19rem, 86vw); z-index: 3; transform: translateX(-100%); transition: transform 0.2s ease; padding-top: env(safe-area-inset-top); }
  .side.open { transform: none; }
  .shade { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 2; }
  .top { padding-left: 0.25rem; padding-top: env(safe-area-inset-top); }
  .thread { padding: 1rem; }
  .send { padding-inline: 0.75rem; }
  @media (prefers-reduced-motion: reduce) { .side { transition: none; } }
}
