:root {
  --bg: #f7f7f7;
  --fg: #0d0d0d;
  --muted: #9b9b9b;
  --peek: #c4c4c4;
  --user-bubble: #eaf1ff;
  --user-text: #2f6bed;
  --blue: #2f6bed;
  --composer-bg: #ffffff;
  --composer-shadow: 0 2px 10px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.05);
  --circle-border: #e6e6e6;
  --err-fg: #b42318; --err-bg: rgba(240,68,56,.06); --err-border: rgba(240,68,56,.3);
}
[data-theme="dark"] {
  --bg: #212121; --fg: #ececec; --muted: #9a9a9a; --peek: #474747;
  --user-bubble: #2f3b57; --user-text: #cfe0ff; --blue: #2f6bed;
  --composer-bg: #2f2f2f; --composer-shadow: 0 0 0 1px rgba(255,255,255,.08); --circle-border: #4a4a4a;
  --err-fg: #ff8a80; --err-bg: rgba(240,68,56,.1); --err-border: rgba(240,68,56,.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--fg);
  /* chatgpt.com mobile loads no webfont, so this is San Francisco on iPhone. */
  font-family: -apple-system, "SF Pro Text", "SF Pro", BlinkMacSystemFont, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px; line-height: 1.5;
  display: flex; flex-direction: column; height: 100dvh; -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }

/* Top bar */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top));
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar .menu-circle { justify-self: start; }
.topbar .title { justify-self: center; }
.topbar .login-pill { justify-self: end; }
.menu-circle {
  width: 44px; height: 44px; border-radius: 50%; background: var(--composer-bg);
  border: 1px solid var(--circle-border); color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.title { font-size: 20px; font-weight: 700; }
.conversation .title { visibility: hidden; }
.login-pill {
  background: #000; color: #fff; border: none; font-size: 17px; font-weight: 600;
  padding: 11px 22px; border-radius: 999px;
}
[data-theme="dark"] .login-pill { background: #fff; color: #000; }

/* Covert readout: faint, small, only while peeking */
.peek {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 2px);
  font-size: 12px; font-weight: 500; color: var(--peek); letter-spacing: .5px;
  pointer-events: none; opacity: 0; transition: opacity .12s;
  font-variant-numeric: tabular-nums;
}
.peek.on { opacity: 1; }

/* Thread */
.thread { flex: 1; overflow-y: auto; padding: 4px 18px 16px; -webkit-overflow-scrolling: touch; }
.thread-inner { max-width: 760px; margin: 0 auto; }
.empty-state { display: flex; flex-direction: column; align-items: center; padding-top: 26vh; gap: 26px; }
.greeting { font-size: 28px; font-weight: 600; margin: 0; text-align: center; }

/* Invisible keypad (homepage only) */
.pad {
  position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 4;
  background: transparent; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.conversation .pad, .pad.off { display: none; }
.empty-state, .greeting, .chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.msg { margin: 18px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-text);
  border-radius: 22px; padding: 11px 17px; max-width: 85%; font-size: 18px;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant .bubble { font-size: 18px; line-height: 1.7; word-wrap: break-word; }
.msg.assistant h3 { font-size: 21px; font-weight: 700; margin: 22px 0 10px; }
.msg.assistant p { margin: 0 0 14px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant strong { font-weight: 700; }
.msg.assistant ol, .msg.assistant ul { margin: 0 0 14px; padding-left: 1.625em; }
.msg.assistant li { margin: .3em 0; padding-left: .375em; }
.msg.assistant code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; }

/* Waiting dot before the first token */
.thinking::before {
  content: ""; display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  background: var(--fg); vertical-align: middle; animation: pulse 1.25s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .85; } 50% { transform: scale(1); opacity: 1; } }

.err {
  font-size: 15px; line-height: 1.45; color: var(--err-fg); background: var(--err-bg);
  border: 1px solid var(--err-border); border-radius: 12px; padding: 10px 14px;
}

/* Suggestion chip (empty only) */
.suggest { display: flex; justify-content: center; }
.chip {
  background: var(--composer-bg); border: 1px solid var(--circle-border);
  border-radius: 999px; padding: 10px 18px; font-size: 16px; color: var(--fg);
}

/* Scroll-to-bottom pill */
.to-bottom {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 6;
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--composer-bg); color: var(--fg); border: 1px solid var(--circle-border);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

/* Composer */
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.composer-inner {
  display: flex; align-items: flex-end; gap: 6px; max-width: 760px; margin: 0 auto;
  background: var(--composer-bg); box-shadow: var(--composer-shadow);
  border-radius: 28px; padding: 7px 8px 7px 10px;
}
.icon-btn {
  background: none; border: none; color: var(--fg); padding: 0;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
#input {
  flex: 1; border: none; outline: none; resize: none; background: transparent; color: var(--fg);
  font: inherit; font-size: 17px; line-height: 1.4; padding: 9px 2px; max-height: 160px; overflow-y: auto; min-width: 0;
  scrollbar-width: none;
}
#input::placeholder { color: var(--muted); }
#input::-webkit-scrollbar { display: none; }
.circle-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--blue); color: #fff;
  border: none; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
[hidden] { display: none !important; }
