.anna-chat {
  width:min(100%,760px); margin:24px auto; border:1px solid #e5e5e5; border-radius:18px;
  overflow:hidden; background:#fff; box-shadow:0 10px 30px rgba(0,0,0,.06);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,sans-serif;
}
.anna-chat__header { display:flex; align-items:center; gap:12px; padding:16px 18px; border-bottom:1px solid #eee; background:#fafafa; }
.anna-chat__avatar { width:42px; height:42px; border-radius:50%; display:grid; place-items:center; font-weight:700; background:#222; color:#fff; flex:0 0 auto; }
.anna-chat__title { font-weight:700; font-size:17px; }
.anna-chat__subtitle { font-size:12px; color:#666; margin-top:2px; }
.anna-chat__messages { height:min(62vh,560px); min-height:380px; overflow-y:auto; padding:18px; background:#f7f7f8; }
.anna-chat__message { display:flex; margin:0 0 14px; }
.anna-chat__message--user { justify-content:flex-end; }
.anna-chat__message--assistant { justify-content:flex-start; }
.anna-chat__bubble { max-width:82%; padding:11px 14px; border-radius:16px; line-height:1.7; font-size:15px; word-break:break-word; overflow:hidden; }
.anna-chat__message--assistant .anna-chat__bubble { background:#fff; border:1px solid #e5e5e5; border-bottom-left-radius:6px; }
.anna-chat__message--user .anna-chat__bubble { background:#222; color:#fff; border-bottom-right-radius:6px; }
.anna-chat__bubble-image { display:block; width:min(320px,100%); max-height:320px; object-fit:contain; border-radius:10px; margin:0 0 9px; background:#fff; }
.anna-chat__bubble-text { min-width:0; }
.anna-chat__status { min-height:24px; padding:4px 18px 0; font-size:12px; color:#777; }
.anna-chat__form { display:block; padding:8px 14px 14px; background:#fff; }
.anna-chat__composer { display:flex; gap:10px; align-items:stretch; }
.anna-chat__input { flex:1; resize:none; min-height:48px; max-height:150px; border:1px solid #d6d6d6; border-radius:14px; padding:11px 13px; font:inherit; line-height:1.5; outline:none; min-width:0; }
.anna-chat__input:focus { border-color:#888; box-shadow:0 0 0 2px rgba(0,0,0,.05); }
.anna-chat__attach { width:48px; min-width:48px; border:1px solid #d6d6d6; border-radius:14px; display:grid; place-items:center; background:#fff; color:#222; font-size:26px; line-height:1; font-weight:400; cursor:pointer; user-select:none; }
.anna-chat__attach:hover { background:#f5f5f5; }
.anna-chat__attach:has(input:disabled) { opacity:.45; cursor:wait; }
.anna-chat__send { align-self:stretch; min-width:74px; border:0; border-radius:14px; background:#222; color:#fff; font-weight:700; cursor:pointer; }
.anna-chat__send:disabled { opacity:.45; cursor:wait; }
.anna-chat__image-preview { display:flex; align-items:center; gap:12px; padding:10px; margin:0 0 9px; border:1px solid #e1e1e1; border-radius:12px; background:#fafafa; }
.anna-chat__image-preview[hidden] { display:none; }
.anna-chat__image-preview img { width:76px; height:76px; object-fit:cover; border-radius:10px; background:#fff; border:1px solid #eee; }
.anna-chat__image-meta { display:flex; flex:1; min-width:0; align-items:center; justify-content:space-between; gap:10px; font-size:12px; color:#666; }
.anna-chat__image-meta span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.anna-chat__image-remove { border:0; background:transparent; color:#555; text-decoration:underline; cursor:pointer; white-space:nowrap; padding:5px; }
.anna-chat__image-remove:disabled { opacity:.45; cursor:wait; }
.anna-chat__image-hint { padding:7px 4px 0; color:#888; font-size:11px; }
.anna-chat__note { padding:0 16px 14px; text-align:center; color:#888; font-size:11px; line-height:1.6; }
@media (max-width:600px) {
  .anna-chat { margin:12px 0; border-radius:14px; }
  .anna-chat__messages { min-height:55vh; height:55vh; padding:14px 10px; }
  .anna-chat__bubble { max-width:88%; font-size:14px; }
  .anna-chat__form { padding:8px 10px 10px; }
  .anna-chat__composer { gap:7px; }
  .anna-chat__attach { width:44px; min-width:44px; border-radius:12px; }
  .anna-chat__send { min-width:62px; border-radius:12px; }
  .anna-chat__image-preview img { width:64px; height:64px; }
  .anna-chat__image-meta { align-items:flex-start; flex-direction:column; gap:2px; }
}
.anna-chat .screen-reader-text {
  position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important;
  overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important;
}
.anna-chat__generate { display:block; margin-top:12px; border:1px solid #d8d8d8; border-radius:999px; padding:9px 14px; background:#fff; color:#222; font:inherit; font-size:13px; font-weight:700; cursor:pointer; }
.anna-chat__generate:hover { background:#f3f3f3; }
.anna-chat__generate:disabled { opacity:.55; cursor:wait; }
.anna-chat__message--user .anna-chat__generate { color:#222; }


/* Long-term memory */
.anna-chat__memory-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.anna-chat__memory-tools button {
  border: 1px solid #d7d7d7;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}
.anna-chat__memory-tools button:hover {
  background: #f3f3f3;
}
.anna-chat__memory-tools button:disabled {
  opacity: .5;
  cursor: wait;
}


/* =========================================================
   Front-end account / login (Ver.0.7.0)
========================================================= */

.anna-chat__account-summary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px 12px;
  font-size: 11px;
  color: #777;
}

.anna-chat__account-summary button,
.anna-chat__account-close {
  border: 1px solid #d8d8d8;
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 11px;
}

.anna-chat__account-panel {
  padding: 12px 16px 18px;
}

.anna-chat__account-panel[hidden] {
  display: none !important;
}

.anna-chat__account-card {
  max-width: 430px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid #e3e3e3;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,.05);
}

.anna-chat__account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.anna-chat__account-tabs button {
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #f6f6f6;
  padding: 9px 8px;
  cursor: pointer;
  font-weight: 700;
}

.anna-chat__account-tabs button.is-active {
  background: #222;
  color: #fff;
  border-color: #222;
}

.anna-chat__account-form[hidden] {
  display: none !important;
}

.anna-chat__account-title {
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 800;
}

.anna-chat__account-form label {
  display: block;
  margin: 0 0 11px;
  color: #444;
  font-size: 12px;
  font-weight: 700;
}

.anna-chat__account-form input {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1px solid #d7d7d7;
  border-radius: 10px;
  background: #fff;
  color: #222;
  font-size: 16px;
  box-sizing: border-box;
}

.anna-chat__account-primary {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: #222;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.anna-chat__account-primary:disabled {
  opacity: .55;
  cursor: wait;
}

.anna-chat__account-help {
  margin: 10px 0 0;
  color: #888;
  font-size: 11px;
  line-height: 1.7;
}

.anna-chat__account-status {
  min-height: 1.5em;
  margin: 10px 0 2px;
  color: #555;
  font-size: 12px;
  text-align: center;
}

.anna-chat__account-close {
  display: block;
  margin: 8px auto 0;
}

@media (max-width: 600px) {
  .anna-chat__account-panel {
    padding-left: 10px;
    padding-right: 10px;
  }
  .anna-chat__account-card {
    padding: 15px;
  }
}


/* Image generation daily quota (Ver.0.7.1) */
.anna-chat__generation-control {
  margin-top: 10px;
}
.anna-chat__generation-count {
  margin: 0 0 6px;
  color: #777;
  font-size: 11px;
  font-weight: 700;
}
.anna-chat__generation-limit {
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid #eadfbd;
  border-radius: 10px;
  background: #fffaf0;
  color: #6f5b25;
  font-size: 12px;
  line-height: 1.65;
}


/* Generated image download button (Ver.0.7.2) */
.anna-chat__generated-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.anna-chat__generated-image-wrap .anna-chat__bubble-image {
  display: block;
}
.anna-chat__image-download {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 50%;
  background: rgba(20,20,20,.72);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,.22);
  z-index: 2;
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.anna-chat__image-download:hover {
  background: rgba(20,20,20,.9);
  transform: translateY(-1px);
}
.anna-chat__image-download:disabled {
  opacity: .55;
  cursor: wait;
  transform: none;
}
@media (max-width: 600px) {
  .anna-chat__image-download {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}


/* =========================================================
   My Chat (Ver.0.8.0)
========================================================= */
.anna-mychat { max-width: 900px; margin: 20px auto; }
.anna-mychat__head { display:flex; justify-content:space-between; gap:18px; align-items:flex-start; margin-bottom:18px; }
.anna-mychat__head h2 { margin:0 0 6px; }
.anna-mychat__head p { margin:0; color:#777; }
.anna-mychat__new,.anna-mychat__save,.anna-mychat__open { border:0; border-radius:10px; padding:10px 14px; background:#222; color:#fff; font-weight:700; cursor:pointer; text-decoration:none; display:inline-block; }
.anna-mychat__list { display:grid; gap:12px; }
.anna-mychat__card { display:flex; justify-content:space-between; gap:16px; padding:16px; border:1px solid #e3e3e3; border-radius:14px; background:#fff; }
.anna-mychat__card h3 { margin:0 0 6px; font-size:18px; }
.anna-mychat__card p { margin:0 0 8px; color:#666; }
.anna-mychat__character { font-size:12px; color:#888; }
.anna-mychat__card-actions { display:flex; gap:7px; align-items:center; flex-wrap:wrap; }
.anna-mychat__card-actions button { border:1px solid #ddd; background:#fff; border-radius:9px; padding:8px 10px; cursor:pointer; }
.anna-mychat__empty { padding:28px; text-align:center; border:1px dashed #ccc; border-radius:14px; color:#777; }
.anna-mychat__editor { margin-top:20px; padding:18px; border:1px solid #ddd; border-radius:14px; background:#fafafa; }
.anna-mychat__editor[hidden] { display:none!important; }
.anna-mychat__editor h3 { margin-top:0; }
.anna-mychat__editor label { display:block; margin-bottom:13px; font-size:13px; font-weight:700; }
.anna-mychat__editor input,.anna-mychat__editor textarea { width:100%; box-sizing:border-box; margin-top:5px; border:1px solid #d5d5d5; border-radius:9px; padding:10px 11px; background:#fff; font-size:15px; }
.anna-mychat__template-row { margin:-4px 0 13px; }
.anna-mychat__template-row button,.anna-mychat__editor-actions button:not(.anna-mychat__save) { border:1px solid #ddd; background:#fff; border-radius:9px; padding:8px 11px; cursor:pointer; }
.anna-mychat__editor-actions { display:flex; gap:8px; }
.anna-mychat__room-head { max-width:900px; margin:12px auto; display:flex; gap:12px; align-items:center; flex-wrap:wrap; font-size:13px; }
.anna-mychat__room-head a { text-decoration:none; }
.anna-mychat__room-head span { color:#777; }
@media(max-width:600px){
  .anna-mychat__head,.anna-mychat__card { flex-direction:column; }
  .anna-mychat__new { width:100%; text-align:center; }
}


/* =========================================================
   Multi character rooms (Ver.0.9.0)
========================================================= */
.anna-mychat__characters {
  margin: 15px 0;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
}
.anna-mychat__characters-head {
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  margin-bottom:10px;
}
.anna-mychat__characters-head span {
  color:#777;
  font-size:12px;
}
.anna-mychat__character-card {
  padding:14px;
  margin-bottom:12px;
  border:1px solid #e0e0e0;
  border-radius:12px;
  background:#fafafa;
}
.anna-mychat__character-card-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
}
.anna-mychat__remove-character,
.anna-mychat__character-template,
.anna-mychat__add-character {
  border:1px solid #ddd;
  background:#fff;
  border-radius:9px;
  padding:7px 10px;
  cursor:pointer;
}
.anna-mychat__remove-character {
  font-size:11px;
}
.anna-mychat__add-character {
  width:100%;
  font-weight:700;
}
.anna-mychat__add-character:disabled {
  opacity:.45;
  cursor:not-allowed;
}
.anna-chat__message--character .anna-chat__bubble {
  position:relative;
}
.anna-chat__speaker {
  margin-bottom:6px;
  font-size:11px;
  font-weight:800;
  letter-spacing:.06em;
  color:#555;
}
.anna-chat__message--character:nth-child(even) .anna-chat__bubble {
  border-left:3px solid #555;
}


/* Ver.0.9.1: clearer multi-character speaker labels */
.anna-chat__speaker {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f1f1;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.anna-chat__log-tools{margin:8px 0 10px}.anna-chat__log-tools button{border:1px solid #d8d8d8;background:#fff;border-radius:9px;padding:7px 11px;font-size:12px;font-weight:700;cursor:pointer}.anna-chat__log-tools button:hover{background:#f7f7f7}

.anna-mychat__user-profile{margin:15px 0;padding:14px;border:1px solid #ddd;border-radius:12px;background:#fff}


/* =========================================================
   Public user chats (Ver.0.9.15)
========================================================= */
.anna-mychat__visibility{
  margin:16px 0;
  padding:14px;
  border:1px solid #ddd;
  border-radius:12px;
}
.anna-mychat__visibility legend{font-weight:700;padding:0 6px}
.anna-mychat__visibility label{display:block;margin:8px 0}
.anna-mychat__visibility p{margin:8px 0 0;font-size:.9em;color:#777}
.anna-mychat__publish-meta{margin-top:8px;font-size:.9em;color:#666}

.anna-public-chats{max-width:980px;margin:0 auto}
.anna-public-chats__head{margin-bottom:22px}
.anna-public-chats__head h2{margin-bottom:8px}
.anna-public-chats__head p{margin:0;color:#666}
.anna-public-chats__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.anna-public-chat-card{
  border:1px solid #ddd;
  border-radius:14px;
  background:#fff;
  padding:18px;
  box-shadow:0 2px 8px rgba(0,0,0,.04);
}
.anna-public-chat-card h3{margin:0 0 8px;font-size:1.12em}
.anna-public-chat-card__purpose{margin:0 0 14px;line-height:1.65;color:#555}
.anna-public-chat-card__meta{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;font-size:.92em;margin-bottom:14px}
.anna-public-chat-card__like{
  appearance:none;border:0;background:transparent;padding:0;cursor:pointer;font:inherit;color:#666
}
.anna-public-chat-card__like.is-liked{color:#d6336c;font-weight:700}
.anna-public-chat-card__start{
  display:inline-block;text-decoration:none;font-weight:700;padding:9px 12px;border:1px solid #222;border-radius:9px;color:#222;background:#fff
}
.anna-public-chat-card__start:hover{background:#222;color:#fff}
.anna-public-chats__empty{padding:24px;border:1px dashed #ccc;border-radius:12px;text-align:center;color:#777}
.anna-public-chats__login-note{margin-top:14px;color:#777;font-size:.9em}

@media (max-width:720px){
  .anna-public-chats__grid{grid-template-columns:1fr}
  .anna-public-chat-card{padding:15px}
}

.anna-public-room__participant{margin:14px 0 16px;padding:14px;border:1px solid #ddd;border-radius:12px;background:#fff}
.anna-public-room__participant label span{display:block;margin-bottom:7px;font-weight:700}
.anna-public-room__participant input{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid #ccc;border-radius:9px;font:inherit}
.anna-public-room__participant p{margin:8px 0 0;color:#777;font-size:.88em;line-height:1.55}


/* Ver.0.9.20: 会話続行の区切り・自動開始設定 */
.anna-chat__continue-separator{display:flex;align-items:center;justify-content:center;gap:10px;margin:12px 0 16px;color:#8a8a8a;font-size:12px;font-weight:700;letter-spacing:.03em;text-align:center}
.anna-chat__continue-separator::before,.anna-chat__continue-separator::after{content:"";height:1px;background:#d9d9d9;flex:1;max-width:150px}
.anna-mychat__auto-start{display:flex!important;align-items:flex-start;gap:8px;margin-top:8px}
.anna-mychat__auto-start input{width:auto!important;margin-top:3px}
.anna-mychat__auto-start small{display:block;color:#777;font-weight:400;margin-left:4px}
.anna-chat__log-tools{display:flex;flex-wrap:wrap;gap:7px}


/* Ver.0.9.21: 長いチャット説明を折りたたむ */
.anna-purpose-collapsible {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.anna-purpose-collapsible.is-collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}
.anna-purpose-toggle {
  margin: 6px 0 12px;
  padding: 6px 10px;
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.anna-purpose-toggle:hover {
  background: #f5f5f5;
}

/* Ver.0.9.28: fixed-chat AI provider selector */
.anna-chat__header-main{flex:1;min-width:0}
.anna-chat__provider-current{margin-left:auto;display:flex;align-items:center;gap:7px;flex-wrap:wrap;justify-content:flex-end;font-size:12px}
.anna-chat__provider-caption{color:#777}
.anna-chat__provider-current strong{font-size:13px}
.anna-chat__provider-current button,.anna-chat__provider-cancel{border:1px solid #d4d4d4;background:#fff;border-radius:999px;padding:5px 10px;cursor:pointer}
.anna-chat__provider-picker[hidden]{display:none!important}
.anna-chat__provider-picker{position:absolute;inset:0;z-index:30;background:rgba(0,0,0,.38);display:flex;align-items:center;justify-content:center;padding:18px;border-radius:inherit}
.anna-chat{position:relative}
.anna-chat__provider-picker-card{width:min(92%,460px);background:#fff;border-radius:16px;padding:20px;box-shadow:0 18px 50px rgba(0,0,0,.25)}
.anna-chat__provider-picker-title{font-size:18px;font-weight:700;margin-bottom:5px}
.anna-chat__provider-picker-note{font-size:12px;color:#666;margin-bottom:14px}
.anna-chat__provider-options{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-bottom:13px}
.anna-chat__provider-options button{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:12px;border:1px solid #ddd;border-radius:12px;background:#fff;cursor:pointer;text-align:left}
.anna-chat__provider-options button:hover,.anna-chat__provider-options button.is-current{border-color:#222;background:#f5f5f5}
.anna-chat__provider-options button b{font-size:14px}
.anna-chat__provider-options button span{font-size:11px;color:#777}
.anna-chat__provider-cancel{display:block;margin-left:auto}
.anna-chat__provider-separator{margin:10px 0;text-align:center;color:#777;font-size:11px;letter-spacing:.02em}
@media(max-width:560px){.anna-chat__provider-current{width:100%;justify-content:flex-start;margin:7px 0 0 0}.anna-chat__provider-options{grid-template-columns:1fr}}


/* Ver.0.9.29: mobile layout fix for fixed-chat provider selector */
.anna-chat__provider-picker-card{box-sizing:border-box;max-width:100%;}
@media(max-width:560px){
  .anna-chat__header{flex-wrap:wrap;align-items:center;}
  .anna-chat__header-main{flex:1 1 calc(100% - 54px);min-width:0;}
  .anna-chat__title,.anna-chat__subtitle{word-break:normal;overflow-wrap:anywhere;}
  .anna-chat__provider-current{
    flex:0 0 100%;
    width:auto;
    margin:4px 0 0 0;
    padding-left:54px;
    box-sizing:border-box;
    justify-content:flex-start;
  }
  .anna-chat__provider-picker{padding:12px;align-items:center;}
  .anna-chat__provider-picker-card{
    width:100%;
    max-width:460px;
    padding:16px;
    max-height:calc(100% - 24px);
    overflow-y:auto;
  }
  .anna-chat__provider-picker-title{font-size:17px;line-height:1.45;word-break:keep-all;overflow-wrap:anywhere;}
  .anna-chat__provider-picker-note{line-height:1.6;}
  .anna-chat__provider-options{grid-template-columns:1fr;}
}
/* v0.9.30: 担当AI切替を入力欄直下へ */
.anna-chat__provider-current--composer{margin-top:8px;display:flex;align-items:center;gap:7px;flex-wrap:wrap;font-size:13px}
.anna-chat__provider-current--composer button{padding:4px 10px;border-radius:999px}
.anna-chat__provider-image-note{color:#777;font-size:12px;margin-left:auto}
@media(max-width:600px){.anna-chat__provider-current--composer{padding:0 2px}.anna-chat__provider-image-note{width:100%;margin-left:0}}

/* v0.9.42: non-dialogue provider failure notice (not stored in transcript). */
.anna-chat__provider-warning{margin:8px 14px;padding:8px 10px;border:1px solid #ddd;border-radius:8px;font-size:12px;line-height:1.5;color:#666;background:#fafafa}


/* v0.9.44: built-in Stage template picker. */
.anna-mychat__template-bar{display:flex;flex-wrap:wrap;align-items:end;gap:8px;margin:12px 0 16px;padding:12px;border:1px solid #e2e2e2;border-radius:10px;background:#fafafa}
.anna-mychat__template-bar label{display:flex;flex-direction:column;gap:4px;font-size:12px;font-weight:700}
.anna-mychat__template-bar select{min-width:220px}
.anna-mychat__template-bar small{flex-basis:100%;color:#777;line-height:1.5}

/* v1.0: registration bot honeypot. */
.anna-chat__hp{position:absolute!important;left:-10000px!important;width:1px!important;height:1px!important;overflow:hidden!important}
