/* ===== ROOT ===== */
#lai-root {
  display: flex;
  flex-direction: column;
  height: 600px;
  border: 1px solid;
  overflow: hidden;
}

/* ===== AGREE ===== */
#lai-agree {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
#lai-agree-inner {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#lai-agree-inner h2 { margin: 0; }
#lai-info-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 480px) { #lai-info-cards { grid-template-columns: 1fr; } }
.lai-info-card {
  border: 1px solid;
  padding: 10px 12px;
  font-size: 0.85em;
}
.lai-info-card-label {
  font-size: 0.75em;
  opacity: 0.55;
  margin-bottom: 4px;
}
.lai-info-card-value {
  font-weight: bold;
  margin-bottom: 2px;
}
.lai-info-card-desc {
  font-size: 0.8em;
  opacity: 0.65;
  line-height: 1.5;
}

#lai-agree-body {
  border: 1px solid;
  padding: 16px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.9em;
  line-height: 1.7;
}
#lai-agree-body h3 { margin: 12px 0 4px; font-size: 0.95em; }
#lai-agree-body h3:first-child { margin-top: 0; }
#lai-agree-body p  { margin: 0 0 8px; }
#lai-agree-body p:last-child { margin-bottom: 0; }

#lai-agree-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9em;
}
#lai-agree-label input { cursor: pointer; }

/* ===== DOWNLOAD ===== */
#lai-download {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#lai-download.active { display: flex; }
#lai-download-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#lai-download-inner h2 { margin: 0; }
#lai-dl-model-sub {
  font-size: 0.8em;
  opacity: 0.6;
  margin-top: -10px;
}
#lai-prog-track {
  height: 3px;
  background: currentColor;
  opacity: 0.15;
  position: relative;
}
#lai-prog-bar {
  position: absolute;
  top: 0; left: 0; height: 100%;
  width: 0%;
  background: currentColor;
  opacity: 1;
  transition: width 0.3s ease;
}
#lai-prog-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8em;
  opacity: 0.6;
}
#lai-dl-log {
  border: 1px solid;
  padding: 10px 12px;
  font-size: 0.8em;
  line-height: 1.8;
  max-height: 160px;
  overflow-y: auto;
  opacity: 0.7;
}
.lai-log-ok  { opacity: 1; font-weight: bold; }
.lai-log-err { opacity: 1; }

/* ===== CHAT SHELL ===== */
#lai-chat {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#lai-chat.active { display: flex; }

/* ===== CHAT HEADER ===== */
#lai-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid;
  flex-shrink: 0;
  min-height: 40px;
}
#lai-header-info {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}
#lai-header-label {
  display: block;
  font-size: 0.8em;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#lai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Think トグル */
#lai-think-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.8em;
  opacity: 0.7;
  white-space: nowrap;
}
#lai-think-label input { cursor: pointer; }

/* ===== MESSAGES ===== */
#lai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

/* ===== MESSAGE BUBBLE ===== */
.lai-msg {
  max-width: 70%;
  padding: 8px 12px;
  font-size: 0.9em;
  line-height: 1.5;
  word-break: break-word;
  border: 1px solid transparent;
}
.lai-msg.me {
  align-self: flex-end;
  background-color: rgba(0, 160, 80, 0.12);
  border-color: rgba(0, 160, 80, 0.3);
}
.lai-msg.ai {
  align-self: flex-start;
  background-color: rgba(0, 100, 200, 0.10);
  border-color: rgba(0, 100, 200, 0.25);
}
.lai-msg .lai-sender {
  font-size: 0.75em;
  opacity: 0.5;
  margin-bottom: 3px;
}
.lai-msg .lai-meta {
  font-size: 0.7em;
  opacity: 0.5;
  margin-top: 4px;
}
.lai-msg.me .lai-meta { text-align: right; }

/* thinking 折りたたみ */
.lai-think-details {
  margin-bottom: 6px;
  font-size: 0.85em;
  opacity: 0.65;
}
.lai-think-details summary {
  cursor: pointer;
  font-size: 0.85em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.lai-think-details summary::-webkit-details-marker { display: none; }
.lai-think-details summary::before {
  content: '▶';
  font-size: 0.7em;
  transition: transform .15s;
  flex-shrink: 0;
}
.lai-think-details[open] summary::before { transform: rotate(90deg); }
.lai-think-body {
  border-left: 2px solid;
  padding: 4px 8px;
  opacity: 0.8;
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.85em;
  line-height: 1.7;
  margin-top: 4px;
}

/* ストリーミングカーソル */
.lai-cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.9em;
  background: currentColor;
  vertical-align: middle;
  margin-left: 1px;
  animation: lai-blink 0.8s step-end infinite;
}
@keyframes lai-blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ===== SYSTEM MSG ===== */
.lai-sys-msg {
  align-self: center;
  font-size: 0.75em;
  opacity: 0.5;
  padding: 2px 10px;
  border: 1px solid;
}

/* ===== TYPING ===== */
#lai-typing {
  padding: 0 12px 2px;
  font-size: 0.75em;
  opacity: 0.5;
  min-height: 18px;
  flex-shrink: 0;
}

/* ===== SYSTEM PROMPT PANEL ===== */
#lai-sysprompt-panel {
  border-bottom: 1px solid;
  flex-shrink: 0;
}
#lai-sysprompt-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
}
#lai-sysprompt-input {
  width: 100%;
  border: 1px solid;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.85em;
  resize: vertical;
  min-height: 64px;
  background: inherit;
  color: inherit;
  box-sizing: border-box;
  line-height: 1.6;
}
#lai-sysprompt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
#lai-sysprompt-hint {
  flex: 1;
  font-size: 0.75em;
  opacity: 0.6;
}

/* ===== INPUT BAR ===== */
#lai-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid;
  flex-shrink: 0;
}
#lai-msg-input {
  flex: 1;
  border: 1px solid;
  padding: 7px 10px;
  font: inherit;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
  background: inherit;
  color: inherit;
  box-sizing: border-box;
}
#lai-send-btn {
  border: 1px solid;
  padding: 6px 14px;
  cursor: pointer;
  font: inherit;
  background: inherit;
  color: inherit;
  flex-shrink: 0;
}
#lai-send-btn:disabled { opacity: 0.3; cursor: default; }

/* ===== COMMON BUTTON ===== */
.lai-btn {
  padding: 6px 12px;
  border: 1px solid;
  cursor: pointer;
  font: inherit;
  background: inherit;
  color: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.lai-btn:disabled { opacity: 0.35; cursor: default; }
