/* Abii site: monochrome, Grok-like. Tokens first, then base, shell, pages, chat app, modal. */
:root {
  --bg: #ffffff;
  --surface: #f4f4f5;
  --card: #ffffff;
  --border: #e4e4e7;
  --text: #0a0a0a;
  --muted: #71717a;
  --accent: #0a0a0a; /* accent = text colour: black buttons in light, white in dark */
  --accent-fg: #ffffff;
  --danger: #b42318;
  --blue: #1d74f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --gutter: 16px;
}
@media (max-width: 767px) {
  :root { --bg: #f8f7f5; --surface: #efeeeb; }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #161618;
    --card: #161618;
    --border: #2a2a2d;
    --text: #ededed;
    --muted: #9a9aa0;
    --accent: #ededed;
    --accent-fg: #0a0a0a;
    --danger: #ff8a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
a { color: inherit; }
h1 { font-size: 1.75rem; line-height: 1.3; font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 12px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.icon { flex: none; display: block; }
.note, .muted { color: var(--muted); font-size: 0.9rem; }
.note.small { font-size: 0.8rem; }
.muted-line { color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.center-text { text-align: center; }
.msg { color: var(--muted); font-size: 0.9rem; min-height: 1.4em; margin: 8px 0 0; }

/* ---- inputs and buttons ------------------------------------------------ */
input[type="text"], input[type="email"], input[type="search"] {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
form > * + * { margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font-size: 0.9rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
}
.pill:hover { background: var(--surface); }
.pill.soft { color: var(--muted); }
.pill.sm { padding: 3px 9px; font-size: 0.78rem; gap: 4px; }
.pill.static { color: var(--muted); }
.pill.static:hover { background: transparent; }
.pill.solid, .btn-solid { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pill.solid:hover { background: var(--accent); opacity: 0.88; }
.pill:disabled { opacity: 0.5; }
.btn-solid {
  display: inline-flex; align-items: center; justify-content: center; padding: 12px 20px; border-radius: 999px;
  border: 1px solid var(--accent); font-weight: 600; text-decoration: none;
}
.btn-solid:hover { opacity: 0.88; }
.btn-solid.block { display: flex; width: 100%; }
.roundbtn {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: var(--surface); color: var(--text);
}
.roundbtn.ghost { background: transparent; color: var(--muted); }
.roundbtn.ghost:hover { background: var(--surface); color: var(--text); }
.roundbtn.outline { width: 40px; height: 40px; background: transparent; border-color: var(--border); }
.roundbtn.outline:hover { background: var(--surface); }
.roundbtn.send { background: var(--surface); color: var(--muted); }
.roundbtn.send.ready { background: var(--accent); color: var(--accent-fg); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; padding: 0; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.iconbtn:hover { background: var(--surface); }
.linkbtn, .textlink { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.textlink { color: var(--muted); font-size: 0.9rem; }
.textlink.danger { color: var(--danger); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; }
.check input { margin-top: 4px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.dogmark { display: inline-flex; flex: none; border-radius: 50%; overflow: hidden; vertical-align: middle; }
.dogmark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dogmark.plate { background: #f4f4f5; }
.dogmark.plate img { width: 86%; height: 86%; margin: auto; }
@media (prefers-color-scheme: dark) { .dogmark { background: #f4f4f5; } .dogmark img { width: 86%; height: 86%; margin: auto; } }
.dogface { flex: none; display: block; }
.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; text-decoration: none;
}
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.hide-m { display: inline; }
.only-m { display: none; }
@media (max-width: 767px) {
  .hide-m { display: none; }
  .only-m { display: inline-flex; }
}

/* menu / popover */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 20; bottom: calc(100% + 8px); left: 0; min-width: 220px; padding: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.menu.right { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; }
.menu > button, .menu > a {
  text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text);
  text-decoration: none; font-size: 0.95rem;
}
.menu > button:hover, .menu > a:hover { background: var(--surface); }

/* ---- shell: top bar and footer ---------------------------------------- */
.top { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 var(--gutter); }
.top-l, .top-r { display: flex; align-items: center; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 18px; text-decoration: none; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
footer { padding: 24px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
.foot { margin: 0; color: var(--muted); font-size: 0.75rem; line-height: 1.5; text-align: center; }
.foot a, .foot .linkbtn { color: var(--muted); }

/* ---- plain pages ------------------------------------------------------- */
.col { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.col.center { text-align: center; padding-top: 18vh; }
.label { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.answer { white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.help { color: var(--muted); font-size: 0.9rem; margin-top: 16px; }
.cta { margin-top: 32px; }
.notice { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; }
.auth { width: 100%; max-width: 360px; margin: 0 auto; padding: 12vh var(--gutter) 48px; text-align: center; }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 20px; margin-bottom: 24px; }
.auth h1 { font-size: 1.5rem; }
.auth form { text-align: left; margin-top: 20px; }
.auth input { text-align: left; }
.auth .linkbtn { color: var(--muted); font-size: 0.9rem; display: block; margin: 12px auto 0; }
.sec { margin-top: 36px; }
.sec h2 { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.rowline { display: flex; align-items: center; justify-content: space-between; gap: 12px; word-break: break-all; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.rows a { text-decoration: none; }
.rows a:hover { text-decoration: underline; }
.holdline { display: flex; align-items: center; gap: 8px; }
.danger-zone { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 56px; }
.article { width: 100%; max-width: 680px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.article h2 { font-size: 1.15rem; margin-top: 28px; }
.article ul { padding-left: 1.2rem; }
.banner { color: var(--muted); font-size: 0.85rem; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; text-align: center; }

/* ---- chat app: list + conversation ------------------------------------ */
.split { flex: 1; display: flex; min-height: 0; }
.pane-list, .pane-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view-list .pane-main { display: none; }
.view-conv .pane-list { display: none; }

.listbar { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 var(--gutter); }
.listbar-r { display: flex; gap: 8px; }
.searchbar { padding: 0 var(--gutter) 8px; }
.pinned { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px var(--gutter) 20px; text-decoration: none; }
.pinned-av { position: relative; display: inline-flex; }
.badge {
  position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; background: #ff9500; border: 3px solid var(--bg);
}
.pinned-name { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.convs { list-style: none; margin: 0; padding: 0 8px; }
.crow {
  display: flex; align-items: center; gap: 14px; min-height: 88px; padding: 12px 8px; border-radius: 16px; text-decoration: none;
}
.crow:hover, .crow.active, .pinned.active { background: var(--surface); }
.crow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.crow-top, .crow-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crow-name { font-weight: 600; }
.tagpill { font-size: 0.72rem; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.crow:hover .tagpill, .crow.active .tagpill { background: var(--bg); }
.crow-date { margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.crow-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.92rem; }
.list-foot { margin-top: auto; padding: 24px var(--gutter) calc(16px + env(safe-area-inset-bottom)); }
.emptypane { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

.convhead {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 8px;
  background: var(--bg);
}
.convhead-t { flex: 1; min-width: 0; line-height: 1.25; }
.convhead-name { font-weight: 600; }
.convhead-tag { color: var(--muted); font-size: 0.8rem; }

/* ---- chat -------------------------------------------------------------- */
.chat { flex: 1; display: flex; flex-direction: column; width: 100%; min-height: 0; }
.log { width: 100%; max-width: 720px; margin: 0 auto; padding: 8px var(--gutter) 24px; }
.chat.empty .log { display: none; }
.chat.talking .log { flex: 1; }
.chat.talking .hero, .chat.talking .sugg { display: none; }
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 0 var(--gutter); text-align: center; }
.hero h1 { font-size: 1.6rem; margin: 0; max-width: 20em; }
.dock {
  position: sticky; bottom: 0; z-index: 5; width: 100%; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column;
  padding: 0 12px calc(8px + env(safe-area-inset-bottom)); background: var(--bg);
}
.dock::before {
  content: ""; position: absolute; left: 0; right: 0; top: -28px; height: 28px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
.dock .foot { padding: 10px 4px 0; font-size: 11px; line-height: 1.4; }
.sugg { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.sugg::-webkit-scrollbar { display: none; }
.sugg .pill { flex: none; }
.composer {
  background: var(--card); border: 1px solid var(--border); border-radius: 24px; padding: 12px 12px 10px 16px; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--muted); }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; line-height: 24px; padding: 2px 0; max-height: 216px; overflow-y: auto;
}
.composer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.composer-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.modechip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--surface); font-size: 0.85rem;
}
.modechip button { border: 0; background: transparent; padding: 2px; display: inline-flex; color: var(--muted); border-radius: 50%; }

.msg-user { display: flex; justify-content: flex-end; margin: 18px 0 10px; scroll-margin-bottom: 180px; }
.bubble { max-width: 80%; background: var(--surface); border-radius: 20px; padding: 10px 16px; white-space: pre-wrap; word-break: break-word; }
.msg-abii { margin: 10px 0 22px; scroll-margin-bottom: 180px; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 0.85rem; }
.meta-name { color: var(--muted); }
.dots { display: inline-flex; gap: 5px; padding: 8px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.relay-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; color: var(--muted); font-size: 0.88rem; }
.relay-row .dots { padding: 0; }
.relay { margin: 10px 0; }
button.relay-row.done { width: 100%; margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--muted); font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer; }
button.relay-row.done:hover, button.relay-row.done[aria-expanded="true"] { color: var(--text); }
.relay-chev { margin-left: auto; font-size: 0.7rem; }
.relay-panel { margin-top: 6px; padding: 10px 12px; border-left: 2px solid var(--border); font-size: 0.92rem; }
.relay-go { display: inline-block; margin-top: 8px; color: var(--text); font-size: 0.88rem; }
.errline { color: var(--muted); font-size: 0.9rem; margin: 0; }
.errline .linkbtn { color: var(--text); }
.taskcard { margin-top: 10px; }
.watch-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 0.95rem; }
.links { margin-top: 10px; }
.inline-box { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; max-width: 420px; }
.inline-box .check { margin: 8px 0; }
.inline-box input[type="text"] { padding: 8px 12px; font-size: 0.9rem; }

.talk { margin-top: 4px; }
.talk-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.talk-row > .dogmark, .talk-row > .dogface { margin-top: 2px; }
.talk-main { min-width: 0; }
.talk-name { color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
.talk-text { word-break: break-word; line-height: 1.6; white-space: pre-wrap; }
.talk-row.typing { color: var(--muted); align-items: center; }

/* ---- waitlist modal ---------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-box {
  position: relative; width: 100%; max-width: 420px; max-height: 92dvh; overflow-y: auto; padding: 24px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .modal-box { background: var(--surface); } }
.modal-box h2 { font-size: 1.15rem; margin: 0 40px 16px 0; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal-ok { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0; text-align: center; }
.wishes { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.wishes legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 8px; }
.wishes .pills { margin: 0; }
.wishes input[type="text"] { margin-top: 10px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span {
  display: inline-block; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); font-size: 0.88rem; cursor: pointer;
}
.toggle input:checked + span { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.toggle input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---- add-dog row, sheet, toast ---------------------------------------- */
.addwrap { padding: 0 8px; }
.addrow { width: 100%; border: 0; background: transparent; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.addrow:hover { background: var(--surface); }
.addav {
  flex: none; width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); color: var(--muted);
}
.pill.danger { color: var(--danger); border-color: var(--danger); }
.pill-plus {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin: 0 -4px 0 2px; padding: 0;
  border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-fg);
}
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet-box {
  position: relative; width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--bg); color: var(--text);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .sheet-box { background: var(--surface); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 4px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheetrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.sheetrow-t { flex: 1; min-width: 0; }
.sheetrow-t .tagpill { margin-left: 8px; }
.sheetrow-intro { color: var(--muted); font-size: 0.85rem; line-height: 1.4; margin-top: 2px; }
.sheet-wait { display: block; width: 100%; border: 0; border-top: 1px solid var(--border); background: transparent; text-align: left; padding: 16px 0 8px; color: var(--muted); }
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: 0.9rem; box-shadow: var(--shadow);
}
@media (min-width: 768px) {
  .sheet { align-items: center; padding: 16px; }
  .sheet-box { max-width: 460px; border-radius: 20px; padding: 16px 24px 20px; border: 1px solid var(--border); }
}

/* ---- desktop ----------------------------------------------------------- */
@media (min-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .chat.empty { justify-content: center; }
  .chat.empty .hero { flex: none; padding-bottom: 24px; }
  .chat.empty .dock { position: static; }
  .chat.empty .dock::before { display: none; }
  .chat.empty .sugg { order: 2; flex-wrap: wrap; justify-content: center; overflow: visible; padding: 16px 0 0; }
  .chat.empty .dock .foot { order: 3; margin-top: 8px; }
  .composer { padding: 14px 14px 12px 20px; }
  .chat.empty .composer { margin-top: 0; }
}
@media (min-width: 900px) {
  body.app { height: var(--app-h, 100dvh); overflow: hidden; }
  .pane-list { flex: none; width: 360px; overflow-y: auto; border-right: 1px solid var(--border); }
  .pane-main { overflow-y: auto; }
  .view-list .pane-main, .view-conv .pane-list { display: flex; }
  .view-conv .list-foot { display: none; }
  .back { display: none; }
  .convhead { padding-left: 20px; }
  .chat.empty { min-height: calc(100% - 60px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .dots i { opacity: 0.6; }
}
