:root{
  --bg:#0b0f14;
  --panel:#11161d;
  --panel2:#0f141b;
  --line:#243041;
  --text:#e8edf3;
  --muted:#9ba8b7;
  --accent:#4f8cff;
  --accent-soft:rgba(79,140,255,.14);
  --good:#34d399;
  --shadow:0 18px 50px rgba(0,0,0,.35);
  --radius:22px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:var(--bg);
  color:var(--text);
}

.shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:20px;
}

.app{
  width:min(1400px,100%);
  display:grid;
  gap:18px;
  perspective:1200px;
}

.main{
  position:relative;
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)), var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  min-height:calc(100vh - 40px);
  overflow:hidden;
  transition:transform .25s ease;
}

.main::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at top, rgba(79,140,255,.08), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,.02), transparent);
  pointer-events:none;
}

.inner{
  position:relative;
  z-index:1;
  padding:22px;
  display:grid;
  gap:16px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.logo{
  width:42px;
  height:42px;
  border-radius:14px;
  background:#17202b;
  color:var(--text);
  display:grid;
  place-items:center;
  font-weight:800;
  border:1px solid var(--line);
}

h1{
  margin:0;
  font-size:1.08rem;
  letter-spacing:.2px;
}

.sub{
  margin:2px 0 0;
  color:var(--muted);
  font-size:.92rem;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.pill{
  border:1px solid var(--line);
  background:#141a22;
  border-radius:999px;
  padding:9px 13px;
  color:var(--muted);
  font-size:.88rem;
}

.grid{display:grid;gap:14px}

.field{
  border:1px solid var(--line);
  background:var(--panel2);
  border-radius:20px;
  padding:14px;
}

label{
  display:block;
  font-size:.8rem;
  color:var(--muted);
  margin-bottom:8px;
  letter-spacing:.3px;
  text-transform:uppercase;
}

input, select, textarea, button{
  font:inherit;
}

input, select, textarea{
  width:100%;
  border:none;
  outline:none;
  color:var(--text);
  background:#0f141b;
  border:1px solid #2a3646;
  border-radius:14px;
  padding:13px 14px;
  transition:.2s ease;
}

input::placeholder,
textarea::placeholder{
  color:#7e8b98;
  opacity:1;
}

textarea{
  min-height:132px;
  resize:vertical;
  line-height:1.5;
}

input:focus, select:focus, textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-soft);
}

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

.compact-actions{
  gap:8px;
}

.btn{
  border:none;
  border-radius:999px;
  padding:10px 14px;
  color:#fff;
  background:var(--accent);
  font-weight:700;
  cursor:pointer;
  transition:transform .18s ease, filter .18s ease, box-shadow .18s ease;
  letter-spacing:.1px;
}

.btn:hover{
  transform:translateY(-1px);
  filter:brightness(1.05);
}

.btn.secondary{
  color:var(--text);
  background:#18212c;
  border:1px solid #2a3646;
}

.btn.good{
  background:#1f6feb;
}

.mini-btn{
  padding:8px 12px;
  font-size:.84rem;
  border-radius:999px;
}

.translateWrap{
  display:flex;
  justify-content:center;
}

.translateBtn{
  width:auto;
  min-width:170px;
  padding:12px 22px;
  font-size:.95rem;
  border-radius:999px;
  box-shadow:0 10px 24px rgba(31,111,235,.16);
}

.output-actions{
  justify-content:flex-start;
}

.cameraBox{
  display:none;
  margin-top:12px;
  gap:12px;
}
.cameraBox.open{display:grid}
.cameraWrap{display:grid;gap:10px}

video, canvas{
  width:100%;
  border-radius:16px;
  border:1px solid var(--line);
  background:#02050a;
}

.result{
  min-height:100px;
  white-space:pre-wrap;
  line-height:1.5;
}

.rowInfo{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-top:8px;
  flex-wrap:wrap;
}

.tiny{
  font-size:.84rem;
  color:var(--muted);
}

.langHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:8px;
}

.selectWrap{
  position:relative;
}

.selectWrap select{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
  padding-right:42px;
  cursor:pointer;
  color:var(--text);
  background:#0f141b;
}

.selectWrap select option{
  background:#0f141b;
  color:#e8edf3;
}

.selectArrow{
  position:absolute;
  right:16px;
  top:50%;
  transform:translateY(-50%);
  pointer-events:none;
  color:var(--muted);
  font-size:1rem;
}

.historyList{
  display:grid;
  gap:10px;
  margin-top:12px;
  max-height:260px;
  overflow:auto;
}

.historyItem{
  padding:12px;
  border:1px solid var(--line);
  border-radius:16px;
  background:#0f141b;
  display:grid;
  gap:6px;
}

.historyMeta{
  font-size:.78rem;
  color:var(--muted);
}

.historyText{
  font-size:.93rem;
  line-height:1.45;
}

.chat-fab{
  position:fixed;
  right:20px;
  bottom:20px;
  width:58px;
  height:58px;
  border:none;
  border-radius:50%;
  background:var(--accent);
  color:#fff;
  font-size:1.2rem;
  font-weight:800;
  box-shadow:var(--shadow);
  cursor:pointer;
  z-index:1000;
}

.chat-dialog{
  width:min(420px, calc(100vw - 24px));
  border:none;
  padding:0;
  border-radius:22px;
  background:#10161d;
  color:var(--text);
  box-shadow:var(--shadow);
  border:1px solid var(--line);
}

.chat-dialog::backdrop{
  background:rgba(0,0,0,.5);
}

.chat-dialog-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:18px 18px 12px;
  border-bottom:1px solid var(--line);
}

.chat-dialog-head h2{
  margin:0;
  font-size:1.05rem;
}

.chat-dialog-head p{
  margin:4px 0 0;
  color:var(--muted);
  font-size:.88rem;
}

.chat-close{
  border:none;
  background:#18212c;
  color:var(--text);
  width:38px;
  height:38px;
  border-radius:12px;
  cursor:pointer;
  border:1px solid #2a3646;
}

.popup-log{
  max-height:320px;
  overflow:auto;
  padding:14px 18px;
}

.popup-input{
  padding:14px 18px 18px;
}

.msg{
  max-width:92%;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  line-height:1.45;
}

.msg.user{
  margin-left:auto;
  background:rgba(79,140,255,.12);
}

.msg.bot{
  background:#151c24;
}

.chatInput{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
}

.status{
  font-size:.88rem;
  color:var(--good);
  min-height:1.2em;
}

@media (max-width:640px){
  .inner{padding:16px}
  .topbar{flex-direction:column;align-items:flex-start}
  .chatInput{grid-template-columns:1fr}
  .btn,.pill,input,select,textarea{border-radius:13px}
  .chat-dialog{width:calc(100vw - 20px)}
}