*{box-sizing:border-box}
:root{
  --ink:#17324a;
  --muted:#6b8aa3;
  --line:#cfe4f4;
  --blue:#2d83ba;
  --blue-deep:#1b5f8f;
  --blue-soft:#eaf6ff;
  --blue-bg:#f5fbff;
  --white:#fff;
  --danger:#b83232;
  --danger-bg:#fff1f1;
}
body{
  margin:0;
  min-height:100vh;
  background:linear-gradient(180deg,var(--blue-bg),#eef8ff 48%,#f8fcff);
  color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Sans","Yu Gothic",sans-serif;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.app{
  width:min(860px,100%);
  display:grid;
  gap:18px;
}
.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}
.brand{display:grid;gap:4px}
h1{
  font-size:24px;
  line-height:1.15;
  margin:0;
  letter-spacing:0;
}
.sub{
  color:var(--muted);
  font-size:13px;
}
.badge{
  border:1px solid var(--line);
  background:rgba(255,255,255,.72);
  color:var(--blue-deep);
  border-radius:999px;
  padding:7px 12px;
  font-size:12px;
  white-space:nowrap;
}
.panel{
  background:rgba(255,255,255,.86);
  border:1px solid var(--line);
  border-radius:8px;
  box-shadow:0 12px 36px rgba(27,95,143,.12);
  overflow:hidden;
}
.conversation{
  border-bottom:1px solid var(--line);
  min-height:360px;
  max-height:58vh;
  overflow:auto;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.empty{
  border:1px dashed var(--line);
  background:var(--blue-soft);
  color:var(--muted);
  border-radius:8px;
  padding:18px;
  line-height:1.7;
  font-size:14px;
}
.msg{
  display:grid;
  gap:6px;
  max-width:86%;
}
.msg.user{align-self:flex-end}
.msg.assistant{align-self:flex-start}
.role{
  color:var(--muted);
  font-size:11px;
  padding:0 4px;
}
.bubble{
  border:1px solid var(--line);
  border-radius:8px;
  padding:12px 14px;
  white-space:pre-wrap;
  line-height:1.9;
  font-size:13px;
}
.assistant .bubble{font-size:12.8px}
.message-photo{
  width:160px;
  max-width:100%;
  aspect-ratio:4/3;
  object-fit:cover;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
}
.user .bubble{
  background:var(--blue);
  color:#fff;
  border-color:var(--blue);
}
.assistant .bubble{background:#fff}
.composer{
  border-top:1px solid var(--line);
  background:#fff;
  padding:14px;
  display:grid;
  gap:10px;
}
textarea{
  width:100%;
  min-height:96px;
  resize:vertical;
  border:1px solid var(--line);
  border-radius:8px;
  padding:12px;
  font:inherit;
  line-height:1.6;
  color:var(--ink);
  outline:none;
  background:#fbfdff;
}
textarea:focus{
  border-color:#7abce4;
  background:#fff;
  box-shadow:0 0 0 3px rgba(91,164,207,.18);
}
.photo-tools{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
#photoInput{
  position:absolute;
  inline-size:1px;
  block-size:1px;
  opacity:0;
  pointer-events:none;
}
.photo-button,
.text-button{
  border-radius:8px;
  border:1px solid var(--line);
  background:var(--blue-soft);
  color:var(--blue-deep);
  cursor:pointer;
  font-weight:700;
  font-size:13px;
}
.photo-button{
  display:inline-flex;
  align-items:center;
  min-height:40px;
  padding:9px 12px;
}
.photo-button:hover,
.text-button:hover{
  background:#dff1ff;
}
.photo-preview{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.photo-preview[hidden]{display:none}
.photo-preview img{
  width:54px;
  height:54px;
  object-fit:cover;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
}
.photo-meta{
  display:grid;
  gap:5px;
  min-width:0;
}
#photoName{
  color:var(--muted);
  font-size:12px;
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.text-button{
  min-width:0;
  width:max-content;
  padding:6px 10px;
}
.actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.actions > div{
  flex:1;
  min-width:0;
}
.tool-row{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:8px;
}
.answer-tools{
  background:#fff;
  padding:14px;
  display:grid;
  gap:10px;
}
.hint{
  color:var(--muted);
  font-size:12px;
}
button{
  border:0;
  border-radius:8px;
  background:var(--blue);
  color:#fff;
  padding:11px 18px;
  font-weight:700;
  font-size:14px;
  cursor:pointer;
  min-width:108px;
}
#sendButton{
  flex:0 0 auto;
  width:auto;
}
button:hover{background:var(--blue-deep)}
button:disabled{
  cursor:not-allowed;
  opacity:.64;
}
.tool-button{
  min-width:0;
  background:var(--blue-soft);
  border:1px solid var(--line);
  color:var(--blue-deep);
  padding:10px 8px;
}
.tool-button:hover{background:#dff1ff}
.tool-button.reset{
  background:#fff;
  color:var(--muted);
  justify-self:stretch;
}
.tool-button.reset:hover{
  border-color:#9fc9e3;
  color:var(--blue-deep);
}
.status{
  min-height:22px;
  color:var(--muted);
  font-size:13px;
}
.error{
  display:none;
  border:1px solid #f2b6b6;
  background:var(--danger-bg);
  color:var(--danger);
  border-radius:8px;
  padding:10px 12px;
  font-size:13px;
  line-height:1.6;
}
.error.visible{display:block}
.profile-panel summary{padding:16px;cursor:pointer;font-weight:700}
.profile-panel summary span{font-size:12px;color:var(--muted);font-weight:400;margin-left:8px;overflow-wrap:anywhere}
.profile-content{padding:0 16px 12px}
.profile-content .hint{line-height:1.8}
.profile-controls{display:flex;gap:10px;align-items:center;flex-wrap:wrap;font-size:13px;margin:14px 0}
.profile-content fieldset{border:0;padding:0;min-width:0}
.profile-content legend{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
.profile-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.profile-grid label{display:grid;gap:6px;font-size:13px;min-width:0}
.profile-wide{grid-column:1 / -1}
.profile-content input,.profile-content select{min-width:0;max-width:100%;border:1px solid var(--line);border-radius:8px;padding:10px;background:#fff;color:var(--ink);font:inherit}
.profile-content input:focus,.profile-content select:focus{outline:2px solid #7abce4;outline-offset:1px}
.profile-content textarea{min-height:70px;font-size:14px}
.profile-buttons{display:flex;gap:8px;flex-wrap:wrap}
.profile-buttons button{font-size:13px}
.profile-content .status{margin-bottom:0;overflow-wrap:anywhere}
@media (max-width:640px){
  .profile-grid{grid-template-columns:1fr}
  body{
    padding:14px;
    align-items:stretch;
  }
  .header{
    align-items:flex-start;
    flex-direction:column;
  }
  .badge{white-space:normal}
  .msg{max-width:100%}
  .conversation{
    min-height:360px;
    max-height:none;
    padding:14px;
  }
  .bubble{
    font-size:12.8px;
    line-height:1.95;
  }
  .assistant .bubble{font-size:12.6px}
  .actions{
    align-items:center;
    flex-direction:row;
  }
  .photo-tools{
    align-items:flex-start;
    flex-direction:column;
  }
  #photoName{
    max-width:calc(100vw - 118px);
  }
  .tool-row{
    grid-template-columns:1fr;
  }
  button{width:100%}
  .text-button{width:max-content}
  #sendButton{
    width:auto;
    align-self:center;
  }
}
