/* AiQON Medical welfare/static/styles.css */
:root {
  --bg: #f2f6f9;
  --card: #fff;
  --accent: #2a5f8f;
  --accent-soft: #e8f0f8;
  --care: #3d7a5c;
  --care-soft: #e8f4ed;
  --text: #1a2330;
  --muted: #5c6b7a;
  --border: #d5dee6;
  --content-max: 1680px;
  --side-pad: clamp(1rem, 2.5vw, 2.5rem);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
header {
  background: linear-gradient(135deg, #2a5f8f 0%, #3d7a5c 100%);
  color: #fff;
  padding: 1.25rem var(--side-pad);
}
.header-inner,
main {
  width: min(98vw, var(--content-max));
  margin-left: auto;
  margin-right: auto;
}
header h1 { margin: 0; font-size: 1.35rem; font-weight: 650; }
header p { margin: 0.35rem 0 0; opacity: 0.92; font-size: 0.9rem; }
.badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
}
main { padding: 1.25rem var(--side-pad) 2rem; }
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.sidebar .card { position: sticky; top: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 24px rgba(15, 40, 55, 0.06);
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
textarea, button {
  width: 100%;
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
}
textarea {
  min-height: 260px;
  padding: 0.75rem 0.9rem;
  resize: vertical;
  line-height: 1.6;
}
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (min-width: 1400px) {
  .layout {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 1.5rem;
  }
  textarea { min-height: 300px; }
  .out { min-height: 320px; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar .card { position: static; }
}
button {
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}
button.secondary {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  margin-top: 0.35rem;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
.input-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.input-actions button { margin-top: 0; }
.input-actions #send { flex: 1; }
.input-actions #voiceInputBtn,
.input-actions #fileUploadBtn {
  width: auto;
  min-width: 5.5rem;
  flex: 0 0 auto;
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--border);
  font-weight: 600;
}
.input-actions #voiceInputBtn.recording {
  background: #c62828;
  color: #fff;
  border-color: #c62828;
  animation: voice-pulse 1.2s ease-in-out infinite;
}
.input-actions #voiceInputBtn:disabled,
.input-actions #fileUploadBtn:disabled {
  opacity: 0.45;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, 0); }
}
.voice-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  min-height: 1.2em;
}
.voice-status.active { color: #c62828; font-weight: 600; }
.voice-status.ok { color: #3d7a5c; font-weight: 600; }
.voice-status.err { color: #b00020; }
.warn {
  background: var(--accent-soft);
  border: 1px solid #b8d4ea;
  color: #1a3d5c;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}
.out {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.98rem;
  line-height: 1.65;
  min-height: 240px;
  max-height: none;
}
.card.reply-card {
  min-height: 280px;
  position: relative;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.card.reply-card.is-loading {
  border-color: #b8d4ea;
  box-shadow: 0 8px 28px rgba(42, 95, 143, 0.12);
}
.reply-body {
  position: relative;
  min-height: 240px;
}
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 240px;
  padding: 2rem 1rem;
  text-align: center;
}
.ai-loading[hidden] { display: none !important; }
.ai-loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid #e8f0f8;
  border-top-color: var(--accent);
  border-right-color: var(--care);
  animation: ai-spin 0.9s linear infinite;
}
.ai-loading-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--accent);
  animation: ai-text-pulse 1.6s ease-in-out infinite;
}
.ai-loading-dots {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
}
.ai-loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--care));
  animation: ai-dot-bounce 1.2s ease-in-out infinite;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
.ai-loading-bar {
  width: min(280px, 80%);
  height: 6px;
  border-radius: 999px;
  background: #e8f0f8;
  overflow: hidden;
  position: relative;
}
.ai-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--care), transparent);
  animation: ai-bar-slide 1.4s ease-in-out infinite;
}
.out.is-hidden { display: none; }
.input-actions #send.is-loading {
  background: linear-gradient(135deg, #2a5f8f, #3d7a5c, #2a5f8f);
  background-size: 200% 200%;
  animation: send-gradient 1.8s ease infinite;
  cursor: wait;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
@keyframes ai-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-7px); opacity: 1; }
}
@keyframes ai-bar-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@keyframes send-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-loading-spinner,
  .ai-loading-text,
  .ai-loading-dots span,
  .ai-loading-bar::after,
  .input-actions #send.is-loading {
    animation: none;
  }
}
.meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
.reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}
.reply-header strong { font-size: 0.98rem; }
.reply-download-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.reply-download-actions button {
  width: auto;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.reply-download-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.err { color: #b00020; font-size: 0.9rem; margin-top: 0.5rem; }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.45rem; }
.task-list { display: grid; gap: 0.45rem; }
.task-row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}
.task-row .task-btn { flex: 1; min-width: 0; }
.task-app-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 0 0.5rem;
  min-width: 2.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #b8c9dc;
  background: #f7fafc;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.task-app-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.task-app-link[hidden] { display: none !important; }
.agent-section-card {
  margin-bottom: 1rem;
}
.agent-section-card label {
  font-weight: 650;
  color: #6b4c9a;
}
.task-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 500;
  margin-top: 0;
}
.task-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.task-btn.care.active {
  background: var(--care);
  border-color: var(--care);
}
.selected-task {
  margin-top: 0.55rem;
  font-size: 0.84rem;
  color: var(--muted);
}
.task-main-title {
  margin: 0 0 0.4rem;
  font-size: 1.02rem;
  font-weight: 650;
}
.task-main-desc {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.domain-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-bottom: 0.35rem;
  background: var(--care-soft);
  color: var(--care);
}
.domain-tag.welfare {
  background: var(--accent-soft);
  color: var(--accent);
}
.domain-tag.concern {
  background: #f5ebe8;
  color: #8b4a3a;
}
.task-btn.concern.active {
  background: #8b4a3a;
  border-color: #8b4a3a;
}
.task-btn.agent {
  border-color: #6b4c9a;
  background: linear-gradient(135deg, #f8f4ff 0%, #ede8f8 100%);
  font-weight: 650;
}
.task-btn.agent.active {
  background: linear-gradient(135deg, #6b4c9a 0%, #4a3580 100%);
  border-color: #6b4c9a;
  color: #fff;
}
.agent-card {
  background: linear-gradient(135deg, #f8f4ff 0%, #f0f4f8 100%);
  border: 1px solid #d8cce8;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.agent-card[hidden] { display: none; }
.agent-title {
  font-size: 0.82rem;
  font-weight: 650;
  color: #6b4c9a;
  margin: 0 0 0.55rem;
}
.agent-step {
  font-size: 0.84rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
}
.agent-step strong { color: #6b4c9a; }
.agent-step.err { border-color: #e8b4b4; background: #fff8f8; }
.emotion-card {
  background: linear-gradient(135deg, #faf6f2 0%, #f0f4f8 100%);
  border: 1px solid #e0d5cc;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.emotion-card[hidden] { display: none; }
.emotion-title {
  font-size: 0.82rem;
  font-weight: 650;
  color: #6b5348;
  margin: 0 0 0.5rem;
}
.emotion-primary {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  margin: 0 0 0.35rem;
}
.emotion-bar-wrap {
  height: 8px;
  background: #e8e4e0;
  border-radius: 4px;
  overflow: hidden;
  margin: 0.4rem 0 0.55rem;
}
.emotion-bar {
  height: 100%;
  background: linear-gradient(90deg, #2a5f8f, #3d7a5c);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.emotion-summary {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0 0 0.45rem;
  line-height: 1.5;
}
.emotion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.75rem;
}
.emotion-tag {
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
}
.emotion-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.65rem;
  cursor: pointer;
}
.emotion-toggle input { width: auto; margin: 0; cursor: pointer; }
#clearStatus {
  color: #2a5f8f;
  font-weight: 600;
  margin-top: 0.5rem;
}
#clearStatus.ok { color: #3d7a5c; }
#clearStatus.err { color: #b00020; }
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
}
.settings-modal[hidden] { display: none !important; }
.settings-dialog {
  width: min(100%, 28rem);
  max-height: min(90vh, 40rem);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}
.settings-dialog h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
}
.settings-dialog label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}
.settings-dialog select {
  width: 100%;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
  background: #fff;
  color: var(--text);
}
.settings-dialog input[type="text"] {
  width: 100%;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
.settings-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.settings-section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--text);
}
.settings-section .hint {
  margin-top: 0;
  margin-bottom: 0.65rem;
}
.settings-dialog .emotion-toggle {
  margin-top: 0;
  margin-bottom: 0.85rem;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.settings-actions button {
  width: auto;
  margin-top: 0;
  padding: 0.55rem 0.9rem;
}
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-overlay[hidden] { display: none !important; }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: min(100%, 24rem);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}
.login-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}
.login-card p.sub {
  margin: 0 0 1.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}
.login-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.login-card input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
.login-card button {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}