/* Placeholder styling for the first phase: plain blocks and colours, mobile first, no breakage.
   The visual design comes after phase one. */
:root {
  --bg: #14121c;
  --surface: #1f1c2b;
  --surface-2: #2a2639;
  --line: #3a3550;
  --text: #ece8f6;
  --muted: #9d97b3;
  --accent: #f08a4b;
  --accent-text: #1a1206;
  --visitor: #3d5a80;
  --teller: #5b4b8a;
  --danger: #ff8a8a;
  --radius: 16px;
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Noto Sans JP", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}
.fatal {
  padding: 24px 16px;
  color: var(--danger);
}

/* ---- Sign-in ---- */
.login {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0 16px;
}
.login-top {
  display: flex;
  justify-content: flex-end;
  padding: 12px 0;
}
.lang-select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}
.brand {
  font-size: clamp(28px, 9vw, 40px);
  letter-spacing: 0.06em;
  text-align: center;
  margin: 0 0 24px;
  font-weight: 800;
  font-style: italic;
}
.dev-label {
  font-size: 13px;
  color: var(--muted);
}
.dev-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.dev-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 2px solid #4a7bd1;
  background: var(--surface);
}
.hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.login-message {
  margin: 0;
  min-height: 1.4em;
  font-size: 14px;
  color: var(--danger);
}
.provider {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  opacity: 0.6;
}
.provider small {
  color: var(--muted);
  white-space: nowrap;
}
/* Google's dark-theme sign-in button: #131314 fill, #8E918F border, #E3E3E3 text, standard G. */
.google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid #8e918f;
  background: #131314;
  color: #e3e3e3;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.google-signin:disabled {
  opacity: 0.6;
  cursor: progress;
}
.google-logo {
  display: inline-flex;
  width: 20px;
  height: 20px;
}
.google-logo svg {
  width: 100%;
  height: 100%;
}
.about {
  margin: -12px 0 12px;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  color: var(--muted);
}
.legal-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding-top: 24px;
  font-size: 13px;
}
.legal-links a,
.menu-legal a {
  color: var(--muted);
}
.menu-legal .menu-item {
  font-size: 13px;
  text-decoration: none;
}
.safe-area {
  height: calc(56px + var(--safe-bottom));
  flex: none;
}

/* ---- Shared round send button ---- */
.round-send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  display: grid;
  place-items: center;
}
.round-send svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.round-send:disabled {
  opacity: 0.4;
}

/* ---- Chat layout ---- */
.chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}
.topbar {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand-small {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.menu-button {
  position: absolute;
  right: 8px;
  top: 6px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}
.menu {
  position: absolute;
  right: 8px;
  top: 48px;
  z-index: 10;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
}
.menu-label {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--muted);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 8px;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.menu-item:hover,
.menu-item[aria-pressed="true"] {
  background: var(--surface);
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 0;
}
.scroller {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 16px 16px;
}
.history-note {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.date {
  text-align: center;
  margin: 12px 0 4px;
}
.date span {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.reading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---- Message rows ---- */
.row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 6px 0;
  min-width: 0;
}
.row.visitor {
  justify-content: flex-end;
}
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  align-self: flex-start;
}
.teller-avatar {
  background: var(--teller);
}
.visitor-avatar {
  background: var(--visitor);
}
.stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100% - 42px);
}
.visitor .stack {
  align-items: flex-end;
}
.name {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 2px 4px;
}
.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow-wrap: anywhere;
  white-space: normal;
}
.visitor .bubble {
  background: var(--visitor);
  border-top-right-radius: 4px;
}
.teller .bubble {
  border-top-left-radius: 4px;
}
.bubble p {
  margin: 0;
}
.bubble p + p,
.bubble strong + p {
  margin-top: 6px;
}
.bubble .note {
  font-size: 13px;
  color: var(--muted);
}
.bubble strong {
  display: block;
  font-size: 14px;
  color: #f3d58a;
}
.bubble.image {
  padding: 4px;
  width: 100%;
}
.teller .stack:has(.bubble.image) {
  flex: 1;
}
.image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
}
.image-button img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1220 / 660;
  border-radius: 12px;
  background: var(--surface);
}
.position + .position {
  margin-top: 12px;
}
.meta {
  font-size: 11px;
  color: var(--muted);
  margin: 2px 6px 0;
}
.retry {
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}
.typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  color: var(--muted);
}
.dots {
  display: inline-flex;
  gap: 3px;
}
.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.2s infinite both;
}
.dots i:nth-child(2) {
  animation-delay: 0.2s;
}
.dots i:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dots i {
    animation: none;
    opacity: 0.7;
  }
}

/* ---- Footer ---- */
.toast {
  flex: none;
  margin: 0 16px 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #4a2630;
  color: #ffd9d9;
  font-size: 14px;
}
.footer {
  flex: none;
  padding: 8px 16px var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.chip span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.chip svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: var(--muted);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.input {
  flex: 1;
  min-width: 0;
  resize: none;
  /* At most three lines; longer text scrolls inside the box. */
  max-height: calc(3 * 1.45em + 22px);
  min-height: 44px;
  padding: 10px 16px;
  line-height: 1.45;
  border-radius: 22px;
  border: 2px solid var(--accent);
  background: var(--surface);
  overflow-y: auto;
}
.input:disabled {
  opacity: 0.5;
}
.counter {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin: 0 60px 4px 0;
}
.counter.over {
  color: var(--danger);
}
.countdown {
  margin: 4px 0;
  padding: 12px 16px;
  border: 2px solid #8b5a2b;
  border-radius: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  background: rgb(0 0 0 / 0.85);
}
.lightbox[hidden],
.chips[hidden],
.menu[hidden],
.toast[hidden],
.counter[hidden] {
  display: none;
}
.lightbox img {
  max-width: 100%;
  max-height: 80dvh;
  border-radius: 12px;
}
.lightbox-close {
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
