/* Zenko: the shrine fox — night navy, vermilion, white, gold.
   Tenko: the celestial fox — indigo, violet, starlight, gold (html[data-form="tenko"]). */
:root {
  --bg: #0b0f1e;
  --bg-2: #121834;
  --card: #161c36;
  --text: #f3efe6;
  --muted: #a9a6b8;
  --line: #2a3156;
  --gold: #d9b45a;
  --gold-soft: rgba(217, 180, 90, 0.35);
  --accent: #c8263a;        /* vermilion of the torii */
  --accent-text: #ffffff;
  --user: #22294a;
  --glow: rgba(255, 214, 140, 0.45);
  --radius: 16px;
  --dock-h: 148px;
  color-scheme: dark;
}
html[data-form="tenko"] {
  --bg: #090c25;
  --bg-2: #141a45;
  --card: #18205a;
  --line: #34407e;
  --accent: #6a5cd6;        /* celestial violet */
  --user: #1f2766;
  --glow: rgba(190, 200, 255, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background 600ms ease;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: #ff8b8b; min-height: 1.4em; }
.seal {
  display: inline-block; font-size: 0.7em; color: #fff; background: var(--accent);
  border-radius: 4px; padding: 0 0.3em; vertical-align: middle; transition: background 600ms;
}
button {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.6rem 1rem; min-height: 44px; cursor: pointer;
}
button.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
input, select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.65rem 0.8rem; width: 100%; min-height: 44px;
}
label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: end center; padding: 16px; position: relative; overflow: hidden; }
.splash {
  position: absolute; inset: 0; background: url("/img/zenko-splash.jpg") center top / cover no-repeat;
}
.splash::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, var(--bg) 85%); }
.login-card {
  position: relative; width: min(420px, 100%); display: grid; gap: 0.9rem; padding: 1.4rem;
  margin-bottom: max(24px, env(safe-area-inset-bottom)); background: rgba(18, 24, 52, 0.82);
  border: 1px solid var(--gold-soft); border-radius: 20px; backdrop-filter: blur(6px);
}
.brand { margin: 0; font-size: 2rem; color: var(--gold); letter-spacing: 0.04em; }

/* ---------- the assistant ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.hero { position: relative; height: clamp(150px, 28vh, 240px); flex: 0 0 auto; overflow: hidden; }
.banner {
  position: absolute; inset: 0; background-size: cover; background-position: 72% 30%;
  transition: opacity 900ms ease;
}
.zenko-banner { background-image: url("/img/zenko-banner.jpg"); }
.tenko-banner { background-image: url("/img/tenko-banner.jpg"); opacity: 0; }
html[data-form="tenko"] .zenko-banner { opacity: 0; }
html[data-form="tenko"] .tenko-banner { opacity: 1; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg) 100%); }
.hero-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: flex; align-items: center;
  gap: 12px; padding: 0 16px 10px;
}
.avatar {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--gold);
  box-shadow: 0 0 18px var(--glow); object-fit: cover; flex: 0 0 auto; transition: box-shadow 600ms;
}
.who { flex: 1; min-width: 0; }
.name { font-size: 1.35rem; font-weight: 700; color: var(--gold); }
.status { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; background: rgba(11, 15, 30, 0.6); }
.icon-btn svg, .send svg { width: 22px; height: 22px; fill: currentColor; }

.log { flex: 1; overflow-y: auto; padding: 12px 16px calc(var(--dock-h) + 12px); display: flex; flex-direction: column; gap: 10px; }
.empty { margin: auto; text-align: center; max-width: 32ch; }
.msg { max-width: 88%; padding: 0.65rem 0.9rem; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant {
  align-self: flex-start; background: var(--card); border: 1px solid var(--line);
  border-bottom-left-radius: 4px; transition: background 600ms, border-color 600ms;
}
.msg.assistant.tenko { border-color: rgba(160, 170, 255, 0.5); box-shadow: 0 0 14px rgba(140, 150, 255, 0.18); }
.msg .form-tag { display: flex; align-items: center; gap: 0.45rem; font-size: 0.75rem; color: var(--gold); margin-bottom: 0.3rem; }
.msg .form-tag img.mood { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--gold-soft); object-fit: cover; }
.avatar { transition: box-shadow 600ms, opacity 200ms; }
.msg .translation { display: block; margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px dashed var(--line); color: var(--muted); }
.msg.error { align-self: center; background: transparent; color: #ff8b8b; font-size: 0.9rem; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; height: var(--dock-h);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}
.text-row { display: flex; gap: 8px; align-self: end; }
/* Stage A3: attachments waiting to be sent, media in the chat */
.attachments { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 0.25rem 0.6rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); font-size: 0.85rem; }
.chip button { min-height: 28px; padding: 0 0.4rem; border: 0; background: transparent; }
.media { display: grid; gap: 8px; margin-top: 0.5rem; }
.media figure { margin: 0; display: grid; gap: 4px; }
.media img, .media video { max-width: 100%; max-height: 360px; border-radius: 12px; border: 1px solid var(--line); }
.media audio { width: 100%; }
.media .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.media .actions button, .media .actions a { min-height: 34px; padding: 0.2rem 0.7rem; font-size: 0.85rem;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); text-decoration: none; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.4rem; }
.links a { color: var(--gold); font-size: 0.85rem; word-break: break-all; }
.send { width: 48px; padding: 0; display: grid; place-items: center; flex: 0 0 auto; }
.mic {
  position: relative; width: 96px; height: 96px; padding: 0; border-radius: 50%; border: 2px solid var(--gold);
  background: var(--bg-2); overflow: visible; box-shadow: 0 0 22px var(--glow);
}
.mic img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.mic .ring {
  position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--gold-soft);
  transform: scale(calc(1 + var(--level, 0) * 0.35)); transition: transform 80ms linear;
}
body[data-phase="listening"] .mic { border-color: var(--accent); box-shadow: 0 0 28px var(--accent); }
body[data-phase="thinking"] .mic .ring { animation: pulse 1.2s ease-in-out infinite; }
body[data-phase="speaking"] .mic .ring { border-color: var(--gold); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.18); opacity: 0.4; } }

.sheet {
  width: min(480px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--text); padding: 1.2rem; display: none;
}
.sheet[open] { display: grid; gap: 0.9rem; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet h2 { margin: 0; color: var(--gold); }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 5;
  background: rgba(20, 26, 69, 0.92); border: 1px solid rgba(190, 200, 255, 0.5); color: #e9ecff;
  padding: 0.55rem 1rem; border-radius: 999px; box-shadow: 0 0 24px rgba(140, 150, 255, 0.35);
}

@media (min-width: 900px) {
  .app { max-width: 880px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .dock { max-width: 880px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
