/* Kizuki — AI Practice Coach (portfolio demo)
   Palette: warm paper + clay accent + deep pine secondary.
   Type: Fraunces (display) / Inter (UI) / Noto Sans JP (Japanese). */

:root {
  --bg: #faf5ee;
  --surface: #fffdf9;
  --surface-2: #f3ebdf;
  --ink: #2d261d;
  --ink-soft: #6f6354;
  --line: #e5d9c8;
  --accent: #bc5a3c;        /* clay */
  --accent-soft: #f4ded4;
  --accent-ink: #8c3c24;
  --pine: #33635a;          /* deep pine green */
  --pine-soft: #dfeae6;
  --user-bubble: #33635a;
  --user-ink: #f2f7f5;
  --shadow: 0 1px 2px rgba(60, 45, 25, .06), 0 6px 24px -8px rgba(60, 45, 25, .12);
  --radius: 16px;
  --font-display: "Fraunces", "Noto Serif JP", serif;
  --font-body: "Inter", "Noto Sans JP", -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201c17;
    --surface: #2a251e;
    --surface-2: #332d25;
    --ink: #ece4d8;
    --ink-soft: #a99c8a;
    --line: #423a2f;
    --accent: #d97a58;
    --accent-soft: #45301f;
    --accent-ink: #eda586;
    --pine: #7fb3a6;
    --pine-soft: #263832;
    --user-bubble: #35544d;
    --user-ink: #e4efeb;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px -8px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 500px at 50% -200px, var(--accent-soft), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:lang(ja) { line-break: strict; }

.app {
  max-width: 680px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: .01em;
}
.brand-tag {
  font-size: .72rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.lang-toggle {
  font: 500 .82rem/1 var(--font-body);
  color: var(--pine);
  background: var(--pine-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.lang-toggle:hover { border-color: var(--pine); }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- task card ---------- */

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
  position: sticky;
  top: 10px;
  z-index: 5;
}

.task-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.task-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.task-progress { font-size: .78rem; color: var(--ink-soft); white-space: nowrap; }

.task-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  line-height: 1.3;
  margin-bottom: 6px;
}

.task-why { font-size: .88rem; color: var(--ink-soft); }

.task-dots { display: flex; gap: 6px; margin-top: 12px; }
.task-dots span {
  width: 22px; height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background .3s;
}
.task-dots span.done { background: var(--pine); border-color: var(--pine); }
.task-dots span.current { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- chat ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 2px 18px;
}

.msg { display: flex; gap: 10px; max-width: 88%; }

.msg.coach { align-self: flex-start; }
.msg.user  { align-self: flex-end; }

.avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 999px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: .8rem;
  font-weight: 600;
  margin-top: 2px;
}

.bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: .95rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.msg.coach .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
  box-shadow: var(--shadow);
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--user-ink);
  border-top-right-radius: 6px;
}

.msg { animation: rise .35s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* typing indicator */
.typing .bubble { display: flex; gap: 5px; align-items: center; padding: 15px 16px; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--ink-soft);
  animation: blink 1.2s infinite both;
}
.typing .dot:nth-child(2) { animation-delay: .18s; }
.typing .dot:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }

/* wrap-up card at end of cycle */
.wrapup {
  align-self: center;
  text-align: center;
  background: var(--pine-soft);
  border: 1px solid var(--pine);
  border-radius: var(--radius);
  padding: 16px 22px;
  max-width: 88%;
  animation: rise .35s ease both;
}
.wrapup strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--pine);
  margin-bottom: 4px;
}
.wrapup p { font-size: .88rem; color: var(--ink-soft); }

/* ---------- composer ---------- */

.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 8px 0 14px;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 10px; }

.chip {
  font: 400 .8rem/1.3 var(--font-body);
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip.next {
  color: var(--pine);
  background: var(--pine-soft);
  border-color: var(--pine);
  font-weight: 500;
}

.composer {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--accent); }

.composer input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--ink);
  font: 400 1rem var(--font-body); /* 16px min -- iOS Safari auto-zooms on focus below this */
  outline: none;
}
.composer input::placeholder { color: var(--ink-soft); opacity: .8; }

.send-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .12s, opacity .15s;
}
.send-btn:hover { transform: scale(1.06); }
.send-btn:disabled { opacity: .45; cursor: default; transform: none; }
.send-btn svg { width: 17px; height: 17px; }

.demo-note {
  text-align: center;
  font-size: .68rem;
  color: var(--ink-soft);
  opacity: .75;
  padding-top: 10px;
}

/* ---------- access gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -200px, var(--accent-soft), transparent 70%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 28px 30px;
}

.gate-mark { width: 44px; height: 44px; margin-bottom: 12px; }

.gate-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.2;
}

.gate-sub {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 4px 0 14px;
}

.gate-body {
  font-size: .88rem;
  color: var(--ink-soft);
  margin-bottom: 18px;
}

.gate-form {
  display: flex;
  gap: 8px;
}

.gate-form input {
  flex: 1;
  min-width: 0;
  font: 400 1rem var(--font-body); /* 16px min -- iOS Safari auto-zooms on focus below this */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  outline: none;
}
.gate-form input:focus { border-color: var(--accent); }
.gate-form input::placeholder { color: var(--ink-soft); opacity: .8; }

.gate-form button {
  font: 500 .88rem/1 var(--font-body);
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s;
}
.gate-form button:hover { transform: scale(1.04); }

.gate-error {
  font-size: .8rem;
  color: var(--accent-ink);
  margin-top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .msg, .wrapup { animation: none; }
  .typing .dot { animation-duration: 2s; }
  .send-btn { transition: none; }
}

@media (max-width: 600px) {
  .app { padding: 0 12px; }
  .topbar { padding: 12px 2px 10px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 1.08rem; }
  .brand-tag { font-size: .64rem; }
  .lang-toggle { padding: 6px 11px; font-size: .76rem; }
  .icon-btn { width: 30px; height: 30px; }

  /* Free up vertical space on small screens: let the task card scroll
     away with the chat instead of permanently pinning above it. */
  .task-card { position: static; padding: 14px 16px 12px; }
  .task-title { font-size: 1.1rem; margin-bottom: 4px; }
  .task-why { font-size: .82rem; }
  .task-dots { margin-top: 8px; }

  .chat { padding: 14px 2px 12px; gap: 10px; }
  .msg { max-width: 94%; gap: 8px; }
  .avatar { width: 26px; height: 26px; }
  .bubble { padding: 10px 13px; font-size: .92rem; }

  .chips { gap: 6px; padding-bottom: 8px; }
  .chip { padding: 6px 11px; font-size: .74rem; }

  .composer-wrap { padding: 6px 0 10px; }
  .composer { padding: 5px 5px 5px 15px; }
  .send-btn { width: 36px; height: 36px; }
  .demo-note { font-size: .62rem; padding-top: 6px; }

  .gate-card { padding: 26px 20px 22px; }
}
