:root {
  --bg: #f2efe9;
  --surface: #ffffff;
  --ink: #14161a;
  --muted: #6c7280;
  --line: #e6e1d8;
  --accent: #0f8a86;
  --accent-soft: #e6f2f1;
  --radius: 22px;
  --shadow: 0 30px 80px -40px rgba(20, 22, 26, .45), 0 2px 6px rgba(20, 22, 26, .04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 12% 0%, #fbf9f5 0%, transparent 55%),
    radial-gradient(100% 80% at 100% 100%, #e4efee 0%, transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.card {
  width: min(460px, 100%);
  height: min(760px, calc(100dvh - 56px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
[hidden] { display: none !important; }

/* ---------- brand mark ---------- */

.mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  letter-spacing: -.02em;
}
.mark--sm { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; font-size: 12.5px; }

/* ---------- screen 1 : gate ---------- */

.screen--gate { padding: 30px 30px 26px; overflow-y: auto; }

.gate__brand { display: flex; align-items: center; gap: 13px; }
.brand__name { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.brand__meta { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.gate__title {
  margin: 30px 0 0;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  font-size: 42px;
  line-height: 1.06;
  letter-spacing: -.025em;
}
.gate__title em { font-style: italic; color: var(--accent); }

.gate__sub {
  margin: 14px 0 26px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 34ch;
}

.field { display: block; margin-bottom: 13px; }
.field span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fbfaf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.field input::placeholder { color: #b3b6bd; }
.field input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.error {
  margin: 0 0 12px;
  font-size: 13px;
  color: #b23b3b;
  background: #fdf0ee;
  border: 1px solid #f4d8d3;
  border-radius: 10px;
  padding: 9px 12px;
}

.btn {
  position: relative;
  width: 100%;
  margin-top: 6px;
  padding: 15px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: 13px;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.22,1,.36,1), background .18s ease, opacity .18s ease;
}
.btn:hover { background: #23262c; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .6; cursor: progress; transform: none; }

.btn__spin {
  display: none;
  width: 15px; height: 15px;
  margin-left: 9px;
  vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-busy .btn__spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.fineprint { margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); text-align: center; }
.fineprint a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ---------- screen 2 : chat ---------- */

.chat__head {
  display: flex; align-items: center; gap: 11px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
}
.chat__id { flex: 1; min-width: 0; }
.chat__title { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.chat__status { margin: 2px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #2fbf71; display: inline-block; }
.chat__cb {
  font: inherit;
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: none; border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, opacity .18s ease, transform .18s cubic-bezier(.22,1,.36,1);
}
.chat__cb:hover:not([disabled]) { background: #d5e9e8; transform: translateY(-1px); }
.chat__cb[disabled] { cursor: default; opacity: .75; }
.chat__cb.is-done { background: #e8f5ec; color: #2c8a52; }

.chat__call {
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  text-decoration: none; padding: 7px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  transition: background .18s ease, border-color .18s ease;
}
.chat__call:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

.chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.msg {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.58;
  border-radius: 17px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: rise .5s cubic-bezier(.22,1,.36,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg--bot { align-self: flex-start; background: #f5f3ef; border-bottom-left-radius: 6px; }
.msg--me  { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg--err { align-self: flex-start; background: #fdf0ee; color: #97372f; border: 1px solid #f4d8d3; }
.msg a { color: inherit; }

.typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #b9bcc2;
  animation: bounce 1.3s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chips {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px 18px 4px;
}
.chips button {
  font: inherit; font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.22,1,.36,1), background .18s ease;
}
.chips button:hover { background: #d5e9e8; transform: translateY(-1px); }
.chips[hidden] { display: none; }

.composer {
  display: flex; gap: 9px;
  padding: 12px 18px 4px;
}
.composer input {
  flex: 1;
  padding: 13px 15px;
  font: inherit; font-size: 15px;
  background: #fbfaf8;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.composer input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer button {
  display: grid; place-items: center;
  width: 46px; height: 46px; flex: 0 0 46px;
  color: #fff; background: var(--ink);
  border: none; border-radius: 50%;
  cursor: pointer;
  transition: background .18s ease, transform .18s cubic-bezier(.22,1,.36,1), opacity .18s ease;
}
.composer button:hover { background: #23262c; transform: translateY(-1px); }
.composer button[disabled] { opacity: .45; cursor: default; transform: none; }

.disclaimer {
  margin: 0;
  padding: 9px 18px 14px;
  font-size: 11px;
  line-height: 1.5;
  color: #9a9ea6;
  text-align: center;
}

/* scrollbars */
.chat__log::-webkit-scrollbar, .screen--gate::-webkit-scrollbar { width: 6px; }
.chat__log::-webkit-scrollbar-thumb, .screen--gate::-webkit-scrollbar-thumb { background: #ddd8ce; border-radius: 3px; }

@media (max-width: 520px) {
  .shell { padding: 0; }
  .card { height: 100dvh; border-radius: 0; border: none; }
  .gate__title { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
