/* Glyphm - minimal, Grok-inspired, with light and dark themes */

/* ---------------------------------------------------------------- themes */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #161618;
  --panel-2: #1d1d20;
  --border: #2a2a2e;
  --focus: #4a4a52;
  --text: #ececee;
  --muted: #8d8d95;
  --green: #5bd48a;
  --red: #ff6b6b;
  --overlay: rgba(0, 0, 0, .6);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f5f5f6;
  --panel-2: #ebebed;
  --border: #dcdce0;
  --focus: #b4b4bc;
  --text: #111113;
  --muted: #6b6b73;
  --green: #1c9b52;
  --red: #d63636;
  --overlay: rgba(0, 0, 0, .35);
}

:root {
  --rail: 64px;
  --radius: 26px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ left rail */
.rail {
  position: relative;
  z-index: 30;
  width: var(--rail);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

.spacer { flex: 1; }

.logo-mark,
.logo-glyph {
  background-color: var(--text);
  -webkit-mask: url("/static/logo.png") center / contain no-repeat;
  mask: url("/static/logo.png") center / contain no-repeat;
}

.logo-mark { width: 34px; height: 34px; }

/* the big logo next to the name on the home screen (sized in em so it follows the text) */
.logo-glyph { display: inline-block; width: .8em; height: .8em; margin-right: .22em; vertical-align: -0.05em; }

.rail-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rail-btn:hover { background: var(--panel-2); color: var(--text); }

/* show the sun while dark (click = go light) and the moon while light */
[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun { display: none; }

/* account button: person icon when signed out, first letter when signed in */
.account .initial { display: none; }
.account.signed-in { background: var(--panel-2); color: var(--text); border-radius: 50%; }
.account.signed-in .icon-person { display: none; }
.account.signed-in .initial { display: block; font-size: 16px; font-weight: 600; }

/* ----------------------------------------------------------- main column */
.main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
}

/* before the first question: everything centred like Grok's home screen */
body:not(.has-chat) .main { justify-content: center; }
body:not(.has-chat) .chat { display: none; }

body.has-chat .hero,
body.has-chat .chips { display: none; }

.hero { text-align: center; margin-bottom: 28px; }

.wordmark {
  margin: 0;
  font-size: clamp(48px, 9vw, 84px);
  font-weight: 600;
  letter-spacing: -0.04em;
}

.tagline { margin: 8px 0 0; color: var(--muted); font-size: 17px; }

/* ------------------------------------------------------------------ chat */
.chat {
  flex: 1;
  width: 100%;
  max-width: 760px;
  overflow-y: auto;
  padding: 32px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  padding: 11px 18px;
  border-radius: 20px;
  background: var(--panel-2);
  font-size: 17px;
  overflow-wrap: anywhere;
}

.msg-bot { align-self: stretch; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.step { display: flex; gap: 14px; align-items: baseline; font-size: 17px; line-height: 1.5; }

.step-num {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transform: translateY(-1px);
}

.step-text { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.note { margin-top: 6px; color: var(--muted); font-size: 14px; }

.answer {
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  font-size: 19px;
  font-weight: 600;
}
.answer small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }

.badge { margin-top: 12px; color: var(--green); font-size: 13px; }
.badge.warn { color: var(--muted); }

.error { color: var(--red); }

/* little "thinking" dots */
.dots { display: inline-flex; gap: 5px; padding: 8px 0; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* -------------------------------------------------------------- input bar */
.dock {
  width: 100%;
  max-width: 760px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
body.has-chat .dock { padding-top: 6px; background: linear-gradient(to top, var(--bg) 80%, transparent); }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--focus); }

.composer textarea {
  flex: 1;
  min-height: 28px;
  max-height: 140px;
  padding: 6px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea { margin-left: 4px; }
.icon-btn[hidden] + input + textarea { margin-left: 14px; }       /* no camera button -> a bit more room */

.send {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.send:hover:not(:disabled) { transform: scale(1.06); }
.send:disabled { opacity: .25; cursor: default; }

.chips { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.chip {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.chip:hover { background: var(--panel-2); }

.fine { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------- account menu */
.popover {
  position: fixed;
  z-index: 40;
  left: calc(var(--rail) + 8px);
  bottom: 16px;
  width: 240px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.pop-label { color: var(--muted); font-size: 12px; }
.pop-email { margin: 2px 0 12px; font-size: 15px; overflow-wrap: anywhere; }
.pop-btn {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.pop-btn:hover { background: var(--panel-2); }

/* -------------------------------------------------------- history panel */
.history {
  position: fixed;
  z-index: 20;
  top: 0;
  bottom: 0;
  left: var(--rail);
  width: 300px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform .2s ease, visibility .2s;
}
.history.open { transform: none; visibility: visible; }

.history-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 12px; }
.history-head h2 { margin: 0; font-size: 16px; }

.link-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.link-btn:hover { color: var(--text); }

.history-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }

.hist-item {
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.hist-item:hover { background: var(--panel-2); }
.hist-empty { margin: 8px 6px; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* --------------------------------------------------- sign in / sign up */
.auth {
  width: min(400px, 92vw);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
}
.auth::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }

.auth-box { position: relative; padding: 28px 26px 26px; }
.auth-close {
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer;
}
.auth-close:hover { background: var(--panel-2); color: var(--text); }

.auth-title { margin: 0 0 6px; font-size: 22px; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 12px; background: var(--panel-2); }
.tab {
  flex: 1; padding: 9px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--bg); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.field input:focus { outline: 0; border-color: var(--focus); }

.auth-hint { margin: -4px 0 10px; color: var(--muted); font-size: 13px; }
.auth-error { min-height: 1.3em; margin: 0 0 10px; color: var(--red); font-size: 14px; }

.primary {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------- email code step */
.code-input { text-align: center; font-family: ui-monospace, Consolas, monospace; font-size: 30px; letter-spacing: .4em; padding-left: calc(14px + .4em); }
.verify-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.link-btn:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 640px) {
  body { flex-direction: column; }

  /* the rail turns into a top bar */
  .rail {
    width: 100%;
    height: 56px;
    flex-direction: row;
    gap: 8px;
    padding: 0 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main { height: auto; min-height: 0; flex: 1; padding: 0 14px; }

  .history { left: 0; top: 56px; width: min(320px, 86vw); }
  .popover { left: auto; right: 12px; top: 64px; bottom: auto; }
}

/* ------------------------------------------------------------ photo upload */
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .5; cursor: wait; }

.photo-note { margin: 0 0 10px; padding: 0 6px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.photo-note.error { color: var(--red); }

.msg-caption { margin-top: 3px; color: var(--muted); font-size: 12px; }