:root{
  --bgA:#f2c9d9;
  --bgB:#cbb1ff;
  --panel: rgba(255,255,255,.46);
  --panel-2: rgba(255,255,255,.58);
  --stroke: rgba(255,255,255,.55);
  --text: rgba(20,18,22,.92);
  --muted: rgba(20,18,22,.62);
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  color:var(--text);
  overflow:hidden;
}

.bg{
  position:fixed;
  inset:0;
  background:
    radial-gradient(1200px 800px at 10% 10%, rgba(255,255,255,.35), transparent 50%),
    radial-gradient(1200px 800px at 90% 20%, rgba(255,255,255,.28), transparent 55%),
    linear-gradient(135deg, var(--bgA), var(--bgB));
}
.bg::after{
  content:"";
  position:absolute;
  inset:0;
  background: url('./assets/bg.png') center/cover no-repeat;
  opacity:.28;
  pointer-events:none;
  mix-blend-mode: overlay;
}

.app{
  position:relative;
  height: calc(var(--vh, 1vh) * 100);
  display:flex;
  flex-direction:column;
}

.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 12px 12px;
  background: rgba(255,255,255,.32);
  border-bottom: 1px solid rgba(255,255,255,.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.back{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,255,255,.6);
  color: var(--text);
  text-decoration:none;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 14px;
}

.title{
  flex:1;
  min-width:0;
  text-align:center;
  font-weight: 800;
  letter-spacing: .3px;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right{
  display:flex;
  align-items:center;
  gap:10px;
}

.ghost{
  padding:8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.35);
  border: 1px solid rgba(255,255,255,.55);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.ghost:active{transform: scale(.98)}

.lang{
  display:flex;
  gap:6px;
  padding:6px;
  border-radius: 999px;
  background: rgba(255,255,255,.35);
  border: 1px solid rgba(255,255,255,.55);
}

.lang-btn{
  width:44px;
  height:30px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.65);
  background: rgba(255,255,255,.55);
  color: var(--text);
  font-weight: 800;
}
.lang-btn.active{
  background: rgba(176,149,255,.45);
}

.messages{
  flex:1;
  overflow:auto;
  padding: 16px 14px 18px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.bubble{
  max-width: min(720px, 92%);
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.58);
  background: rgba(255,255,255,.58);
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user{
  align-self:flex-end;
  background: rgba(176,149,255,.35);
}

.bubble.assistant{
  align-self:flex-start;
}

.bubble.system{
  align-self:center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.35);
}

.typing{
  display:inline-flex;
  align-items:center;
  gap:4px;
}
.typing span{
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: rgba(20,18,22,.55);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2){animation-delay:.15s}
.typing span:nth-child(3){animation-delay:.3s}

@keyframes blink{
  0%, 60%, 100%{opacity:.25; transform: translateY(0)}
  30%{opacity:1; transform: translateY(-2px)}
}

.composer{
  display:flex;
  gap: 10px;
  align-items:flex-end;
  padding: 12px 12px calc(16px + var(--safe-b));
  border-top: 1px solid rgba(255,255,255,.45);
  background: rgba(255,255,255,.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

textarea{
  flex:1;
  min-height: 42px;
  max-height: 30vh;
  resize:none;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.6);
  background: rgba(255,255,255,.55);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 16px;
  outline:none;
}

.send{
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.65);
  background: rgba(176,149,255,.55);
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 900;
}

.send:disabled{
  opacity:.5;
}

/* narrow screens */
@media (max-width: 520px){
  .title{font-size:14px}
  .lang-btn{width:40px}
}


@media (max-width:520px){
  .topbar{flex-wrap:wrap}
  .right{margin-left:auto}
  .title{order:3; flex:0 0 100%; text-align:left; padding:6px 2px 0}
}
