:root{font-family:system-ui,-apple-system,"Noto Sans KR",sans-serif;background:#f2f4f8;color:#172033}*{box-sizing:border-box}body{margin:0}button,input,textarea,select{font:inherit}button{border:0;border-radius:12px;padding:12px 16px;background:#172033;color:#fff;cursor:pointer}input,textarea,select{width:100%;padding:12px;border:1px solid #ccd2dc;border-radius:12px;background:#fff}.login{max-width:430px;margin:10vh auto;background:#fff;padding:28px;border-radius:24px;box-shadow:0 12px 40px #0002}.login form,.card,#userForm{display:grid;gap:12px}.error{color:#b42318}header{height:66px;padding:0 16px;background:#172033;color:#fff;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:10}header small{display:block;color:#cbd5e1}#aiState{font-size:12px;margin-right:8px}.minor{background:transparent;border:1px solid #ffffff55;padding:8px}.panel{display:none;min-height:calc(100vh - 132px);padding:14px}.panel.active{display:block}.messages{max-width:880px;margin:auto;padding-bottom:165px}.bubble{max-width:88%;padding:12px 14px;border-radius:18px;margin:10px 0;white-space:pre-wrap;line-height:1.55}.bubble.user{margin-left:auto;background:#172033;color:#fff}.bubble.assistant{background:#fff}.composer{position:fixed;left:0;right:0;bottom:66px;background:#f2f4f8ee;padding:10px;border-top:1px solid #ddd;z-index:5}.composer textarea,.composer .row{max-width:880px;margin:auto}.row{display:flex;gap:8px;align-items:center;margin-top:7px!important}.row select{width:120px}.row label{flex:1;font-size:13px}label input{width:auto}.card{max-width:760px;margin:auto;background:#fff;padding:20px;border-radius:22px}.record{background:#b42318}pre{white-space:pre-wrap;background:#f8fafc;padding:12px;border-radius:12px;min-height:50px}#imagePreview{max-width:100%;max-height:380px;object-fit:contain}.item{border-bottom:1px solid #e4e7ec;padding:13px 0}nav{position:fixed;left:0;right:0;bottom:0;min-height:66px;display:flex;background:#fff;border-top:1px solid #ddd;z-index:20}nav button{flex:1;background:#fff;color:#667085;border-radius:0;padding:6px;display:grid;place-items:center;font-size:20px}nav button span{font-size:11px}nav button.active{color:#172033;font-weight:700}@media(min-width:900px){nav{top:66px;right:auto;width:220px;height:calc(100vh - 66px);display:block}nav button{width:100%;display:flex;gap:12px;padding:18px}.panel{margin-left:220px}.composer{left:220px}}

.calendar-chip{
  display:inline-block;
  margin:4px 6px 8px 0;
  padding:6px 10px;
  border:1px solid rgba(127,127,127,.35);
  border-radius:999px;
  font-size:.85rem;
}

.calendar-picker{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:8px 0 14px;
}
.calendar-choice{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid rgba(127,127,127,.28);
  border-radius:10px;
}
.calendar-choice input{
  width:auto;
  margin:0;
}

.chat-toolbar{display:flex;gap:10px;flex-wrap:wrap;padding:10px 12px;background:#f5f7fb;border-radius:12px;margin-bottom:8px}.chat-toolbar label{display:flex;align-items:center;gap:6px}.voice-status{min-height:1.4em;font-size:.9rem;opacity:.85;margin:6px 0}.hint{font-size:.9rem;opacity:.75}.card hr{margin:22px 0;border:0;border-top:1px solid #dfe3ea}

/* R4: 자료 입력 영역을 명확하게 분리 */
.upload-box{margin:14px 0;padding:16px;border:1px solid rgba(127,127,127,.28);border-radius:14px;background:rgba(127,127,127,.06)}
.upload-box h3{margin-top:0}
.direct-text-box textarea{width:100%;min-height:220px;box-sizing:border-box;resize:vertical}
.direct-text-box input[type=text]{width:100%;box-sizing:border-box;margin-bottom:10px}
@media(max-width:640px){.upload-box{padding:12px}.direct-text-box textarea{min-height:260px}}


/* R5: 가족채팅 - 모바일 우선 2-pane UI */
.family-chat-shell{max-width:1100px;margin:auto;background:#fff;border-radius:20px;overflow:hidden;min-height:calc(100vh - 170px);display:grid;grid-template-columns:290px 1fr;border:1px solid #e4e7ec}
.family-chat-sidebar{border-right:1px solid #e4e7ec;background:#f8fafc;overflow:auto}
.family-chat-side-head,.family-chat-head{min-height:54px;padding:10px 12px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #e4e7ec}
.family-chat-side-head .minor{color:#172033;border-color:#ccd2dc;padding:6px 10px}
.family-chat-label{font-size:12px;font-weight:700;color:#667085;padding:12px 12px 6px}
.family-user,.family-room{width:100%;background:transparent;color:#172033;border-radius:0;text-align:left;padding:11px 12px;border-bottom:1px solid #eef0f4}
.family-user:hover,.family-room:hover,.family-room.active{background:#e9eef7}
.family-room{display:flex;align-items:center;justify-content:space-between;gap:8px}
.family-room span{display:grid;min-width:0}.family-room small{font-size:11px;color:#667085;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:205px}.family-room b{min-width:22px;height:22px;border-radius:999px;background:#b42318;color:#fff;display:grid;place-items:center;font-size:11px}
.family-chat-main{min-width:0;display:grid;grid-template-rows:auto 1fr auto;height:calc(100vh - 170px)}
.family-chat-head span{font-size:11px;color:#667085}
.family-chat-messages{padding:14px;overflow-y:auto;background:#f2f4f8}
.family-msg{max-width:78%;margin:9px 0;display:grid;gap:3px}.family-msg>div{padding:10px 13px;border-radius:16px;white-space:pre-wrap;overflow-wrap:anywhere}.family-msg strong{font-size:12px}.family-msg small{font-size:10px;color:#667085}.family-msg.other>div{background:#fff}.family-msg.mine{margin-left:auto;justify-items:end}.family-msg.mine>div{background:#172033;color:#fff}
.family-chat-composer{display:flex;gap:8px;padding:10px;background:#fff;border-top:1px solid #e4e7ec}.family-chat-composer textarea{resize:none;min-height:48px}.family-chat-composer button{width:76px;flex:none}
@media(max-width:760px){.family-chat-shell{display:block;min-height:calc(100vh - 150px);border-radius:14px}.family-chat-sidebar{border-right:0;border-bottom:1px solid #e4e7ec;max-height:230px}.family-chat-main{height:calc(100vh - 380px);min-height:390px}.family-chat-side-head{position:sticky;top:0;background:#f8fafc;z-index:2}.family-msg{max-width:88%}nav button{font-size:18px;padding:5px 2px}nav button span{font-size:10px}}

/* R6: 가족채팅 Web Push / 안읽음 알림 */
.family-chat-notify{padding:9px 12px;border-bottom:1px solid #e4e7ec;display:flex;align-items:center;gap:9px;background:#fff}.family-chat-notify button{white-space:nowrap;padding:7px 10px}.family-chat-notify small{font-size:11px;color:#667085;line-height:1.35}.family-chat-notify small.ok{color:#067647}.family-chat-notify small.warn{color:#b54708}.family-chat-nav{position:relative}.nav-badge{position:absolute;top:2px;right:3px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:#d92d20;color:#fff;font-size:10px;line-height:18px;text-align:center;box-shadow:0 0 0 2px #fff}.nav-badge[hidden]{display:none!important}

/* R6.3: 저장 텍스트 직접 수정 */
.text-edit-box{border:2px solid rgba(23,32,51,.25);background:#fff;margin-top:18px}
.text-edit-box textarea{min-height:280px;resize:vertical}
.minor.dark{color:#172033;border-color:#ccd2dc;background:transparent}
@media(max-width:640px){.text-edit-box textarea{min-height:340px}}


/* R6.4: GUI 사용설명 / 음성 안내 */
.help-card{max-width:1050px}
.help-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:14px}
.help-head h2{margin:0 0 6px}.help-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.help-start,.help-note{padding:14px 16px;border-radius:14px;background:#f8fafc;border:1px solid #e4e7ec;margin:12px 0 16px}
.help-start h3{margin-top:0}.help-start ol{margin:8px 0 0;padding-left:22px;line-height:1.65}
.help-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.help-item{border:1px solid #e4e7ec;border-radius:16px;padding:15px;background:#fff;box-shadow:0 2px 8px #1018280a}
.help-item h3{margin:0 0 6px}.help-item p{margin:0 0 8px;color:#475467}.help-item ul{padding-left:20px;margin:8px 0 14px;line-height:1.6}.help-item button{width:auto}
.help-note p{margin-bottom:0;line-height:1.6}
@media(max-width:760px){.help-head{display:block}.help-actions{justify-content:flex-start;margin-top:10px}.help-grid{grid-template-columns:1fr}.help-actions button{flex:1;min-width:130px}nav{overflow-x:auto}nav button{min-width:54px}}

/* R6.11: 로컬 사진 기억 / 대화 내 원본 카드 */
#imagePreview{display:block;max-width:min(100%,420px);max-height:420px;object-fit:contain;margin:10px 0;border-radius:14px;border:1px solid #e4e7ec;background:#f8fafc}
#imagePreview[hidden]{display:none}
.upload-state{margin:10px 0;padding:10px 12px;border-radius:12px;background:#f8fafc;line-height:1.55;font-size:13px}
.chat-image-card{max-width:78%;margin:8px 0 14px 0;padding:10px 12px;border:1px solid #d0d5dd;border-radius:14px;background:#fff;display:grid;gap:8px}
.chat-image-card strong{font-size:14px}.chat-image-card p{margin:0;color:#475467;font-size:12px}
.chat-memory-image{display:block;width:min(100%,320px);max-height:320px;object-fit:contain;border-radius:10px;border:1px solid #e4e7ec;cursor:pointer;background:#f8fafc}
@media(max-width:640px){.chat-image-card{max-width:92%}.chat-memory-image{width:100%;max-height:300px}}

/* R6.12: 사진 로컬 저장 / AI 분석 동작 분리 */
.photo-source-buttons,.photo-action-buttons{display:flex;gap:8px;flex-wrap:wrap}
.photo-source-buttons button,.photo-action-buttons button{flex:1;min-width:180px}
.photo-action-buttons #imageSaveOnlyBtn{font-weight:700}
@media(max-width:640px){.photo-source-buttons button,.photo-action-buttons button{min-width:100%;width:100%}}


/* R6.14: 관리 > 환경설정 센터 */
.settings-shell{max-width:900px;margin:auto;display:grid;gap:16px}
.settings-card{max-width:none}
.settings-group{padding:16px 0;border-top:1px solid #e4e7ec}
.settings-group h3{margin:0 0 10px}
.setting-row,.setting-select{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px;border:1px solid #e4e7ec;border-radius:14px;background:#f8fafc;margin:8px 0}
.setting-row span,.setting-select span{display:grid;gap:4px}
.setting-row small,.setting-select small{color:#667085;line-height:1.45}
.setting-row input[type=checkbox]{width:22px;height:22px;flex:none}
.setting-select select{width:min(280px,45%);flex:none}
.settings-action-row{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.settings-action-row small{color:#667085}
#settingsCalendarPicker{display:grid;gap:8px;margin:10px 0}
.calendar-current>strong{display:block;margin-bottom:8px}
@media(max-width:640px){
  .setting-row,.setting-select{align-items:flex-start}
  .setting-select{display:grid}
  .setting-select select{width:100%}
  .settings-action-row button{width:100%}
}


/* ==========================================================================
   R6.15 - Family Calendar Agenda UI
   ========================================================================== */
.calendar-card{
  max-width:900px;
  margin:auto;
}
.calendar-toolbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:8px;
}
.calendar-toolbar h2{
  margin:0 0 6px;
}
.calendar-status{
  margin:0;
  color:#475467;
  font-size:.94rem;
}
.calendar-actions{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.calendar-actions button{
  width:auto;
  min-height:38px;
  padding:8px 12px;
}
.calendar-auth-hint:empty{
  display:none;
}
.calendar-source-details{
  margin:10px 0 18px;
  border:1px solid #e7eaf0;
  border-radius:12px;
  background:#f8fafc;
  padding:0 12px;
}
.calendar-source-details summary{
  cursor:pointer;
  list-style:none;
  padding:11px 0;
  color:#667085;
  font-size:.9rem;
  font-weight:700;
}
.calendar-source-details summary::-webkit-details-marker{
  display:none;
}
.calendar-source-details summary::after{
  content:"▾";
  float:right;
  color:#98a2b3;
}
.calendar-source-details[open] summary::after{
  content:"▴";
}
.calendar-source-grid{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  padding:0 0 10px;
}
.calendar-source-chip{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  background:#fff;
  border:1px solid #e4e7ec;
  color:#475467;
  padding:5px 9px;
  font-size:.82rem;
}
.calendar-agenda{
  display:grid;
  gap:20px;
}
.agenda-day{
  display:grid;
  grid-template-columns:110px 1fr;
  gap:18px;
}
.agenda-date{
  font-weight:800;
  color:#344054;
  padding-top:11px;
  line-height:1.35;
}
.agenda-events{
  border-left:2px solid #e4e7ec;
  display:grid;
}
.agenda-event{
  display:grid;
  grid-template-columns:72px minmax(0,1fr);
  gap:12px;
  padding:11px 0 11px 18px;
  position:relative;
}
.agenda-event::before{
  content:"";
  position:absolute;
  width:9px;
  height:9px;
  border-radius:50%;
  background:#667085;
  left:-5.5px;
  top:17px;
  box-shadow:0 0 0 3px #fff;
}
.agenda-event+.agenda-event{
  border-top:1px solid #f0f2f5;
}
.agenda-time{
  font-size:.86rem;
  font-weight:800;
  color:#667085;
  white-space:nowrap;
}
.agenda-title{
  font-size:1rem;
  font-weight:800;
  color:#101828;
  line-height:1.4;
}
.agenda-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  margin-top:5px;
}
.agenda-location{
  font-size:.86rem;
  color:#475467;
  line-height:1.4;
}
.agenda-source{
  font-size:.76rem;
  border-radius:999px;
  background:#f2f4f7;
  color:#667085;
  padding:3px 7px;
}
.calendar-empty{
  padding:28px 14px;
  text-align:center;
  color:#667085;
  background:#f8fafc;
  border-radius:14px;
}

/* ==========================================================================
   R6.15 - Family Chat Push Always-On
   ========================================================================== */
.always-on-setting{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:12px;
  border:1px solid #e4e7ec;
  border-radius:14px;
  background:#f8fafc;
}
.always-on-setting>div{
  display:grid;
  gap:4px;
}
.always-on-setting small{
  color:#667085;
  line-height:1.45;
}
.always-on-badge{
  flex:none;
  font-size:.76rem;
  font-weight:800;
  padding:5px 8px;
  border-radius:999px;
  background:#ecfdf3;
  color:#027a48;
  border:1px solid #abefc6;
}
.setting-status{
  font-size:.84rem;
  color:#667085;
  margin-top:3px;
}
.setting-status.ok{
  color:#027a48;
}
.setting-status.warn{
  color:#b54708;
}

@media(max-width:700px){
  .calendar-toolbar{
    display:grid;
  }
  .calendar-actions{
    justify-content:flex-start;
  }
  .agenda-day{
    grid-template-columns:1fr;
    gap:6px;
  }
  .agenda-date{
    padding-top:0;
    font-size:.95rem;
  }
  .agenda-events{
    margin-left:4px;
  }
  .agenda-event{
    grid-template-columns:58px minmax(0,1fr);
    padding-left:16px;
  }
}

/* R6.16 family chat plus */
.family-chat-main{grid-template-rows:auto 1fr auto auto}.family-msg{position:relative}.family-msg .family-bubble{padding:10px 13px;border-radius:16px;white-space:normal;overflow-wrap:anywhere;min-width:80px}.family-msg.other .family-bubble{background:#fff}.family-msg.mine .family-bubble{background:#172033;color:#fff}.family-message-text{white-space:pre-wrap}.family-msg-footer{display:flex;align-items:center;gap:6px;min-height:24px}.family-msg.mine .family-msg-footer{justify-content:flex-end}.family-msg-actions{display:flex;gap:2px;opacity:.3}.family-msg:hover .family-msg-actions,.family-msg:focus-within .family-msg-actions{opacity:1}.family-msg-actions button{width:auto;min-width:28px;min-height:26px;padding:2px 5px;border-radius:8px;border:0;background:transparent;color:#667085;font-size:14px}.family-reply-quote{width:100%;display:grid;gap:2px;text-align:left;border:0;border-left:3px solid #98a2b3;border-radius:6px;padding:6px 8px;margin:0 0 7px;background:rgba(152,162,179,.14);color:inherit}.family-reply-quote strong,.family-reply-quote span{font-size:11px}.family-reply-quote span{opacity:.78;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.family-reactions{display:flex;gap:4px;flex-wrap:wrap;margin-top:2px}.family-msg.mine .family-reactions{justify-content:flex-end}.family-reaction{width:auto;padding:3px 7px;border-radius:999px;border:1px solid #d0d5dd;background:#fff;color:#344054;font-size:12px}.family-reaction.mine{border-color:#84adff;background:#eff4ff}.family-attachments{display:grid;gap:7px;margin-top:7px}.family-image-attachment{display:block;width:min(280px,70vw);padding:0;overflow:hidden;border:0;border-radius:12px;background:#e4e7ec;color:#475467}.family-image-attachment img{display:block;width:100%;max-height:320px;object-fit:cover}.family-image-placeholder{min-height:110px;display:grid;place-items:center;padding:12px}.family-file-attachment{width:min(320px,72vw);display:flex;align-items:center;gap:9px;padding:9px 10px;text-align:left;border:1px solid rgba(152,162,179,.3);border-radius:12px;background:rgba(255,255,255,.12);color:inherit}.family-file-attachment>span:last-child{min-width:0;display:grid}.family-file-attachment strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.family-file-attachment small{opacity:.7;font-size:10px}.family-file-icon{font-size:22px}.family-reply-preview{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;border-top:1px solid #e4e7ec;background:#f8fafc}.family-reply-preview>div{min-width:0;display:grid;gap:2px}.family-reply-preview strong{font-size:11px;color:#475467}.family-reply-preview span{font-size:12px;color:#667085;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.icon-button{width:30px!important;height:30px;min-height:30px;padding:0!important;border-radius:999px;background:transparent!important;color:#667085!important;border:0!important}.family-pending-files{display:flex;gap:6px;overflow-x:auto;padding:7px 10px;border-top:1px solid #eef0f4;background:#fff}.pending-file{display:flex;align-items:center;gap:5px;flex:none;max-width:220px;padding:5px 7px;border-radius:9px;background:#f2f4f7;color:#475467;font-size:11px}.pending-file span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pending-file button{width:auto;min-height:20px;padding:0 3px;color:#667085;background:transparent;border:0}.family-chat-composer{align-items:flex-end}.family-chat-composer .family-attach-btn{width:42px;min-width:42px;height:42px;min-height:42px;padding:0;border-radius:50%;background:#f2f4f7;color:#344054;font-size:25px}.family-chat-composer .family-send-btn{width:66px;min-width:66px}.family-msg-highlight .family-bubble{outline:3px solid rgba(53,105,255,.22)}@media(max-width:760px){.family-msg-actions{opacity:.72}.family-msg-actions button{min-width:26px;font-size:13px}.family-chat-composer{gap:6px}.family-chat-composer textarea{min-height:42px}}


/* ==========================================================================
   R6.16c - Family Chat composer visibility/layout fix
   ========================================================================== */

/* author CSS의 display:flex가 HTML hidden 속성을 덮어쓰는 문제를 차단합니다. */
.family-reply-preview[hidden],
.family-pending-files[hidden],
#familyChatFile[hidden]{
  display:none!important;
}

/* + 버튼 / 입력창 / 전송 버튼이 한 줄에 안정적으로 배치되도록 합니다. */
.family-chat-composer{
  display:flex;
  align-items:flex-end;
  gap:7px;
  width:100%;
  box-sizing:border-box;
}

.family-chat-composer textarea{
  flex:1 1 auto;
  width:auto;
  min-width:0;
  min-height:42px;
  max-height:120px;
  box-sizing:border-box;
  resize:none;
}

.family-chat-composer .family-attach-btn{
  flex:0 0 42px;
}

.family-chat-composer .family-send-btn{
  flex:0 0 64px;
  width:64px;
}

/* hidden이 아닐 때만 실제로 표시합니다. */
.family-reply-preview:not([hidden]){
  display:flex;
}

.family-pending-files:not([hidden]){
  display:flex;
}

@media(max-width:760px){
  .family-chat-main{
    min-width:0;
  }

  .family-chat-composer{
    position:sticky;
    bottom:0;
    z-index:5;
    padding:8px;
  }

  .family-chat-composer textarea{
    min-height:42px;
    font-size:16px;
  }

  .family-chat-composer .family-send-btn{
    flex-basis:58px;
    width:58px;
    padding-left:7px;
    padding-right:7px;
  }
}

/* R6.17 OpenAI Usage Meter */
.usage-card-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.usage-card-head h2{margin-bottom:4px}.usage-card-head button{width:auto;flex:none}
.usage-money-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:16px 0 12px}.usage-metric{padding:15px;border:1px solid #e4e7ec;border-radius:14px;background:#f8fafc;display:grid;gap:5px}.usage-metric small,.usage-token-grid small{color:#667085}.usage-metric strong{font-size:1.55rem;color:#101828}.usage-balance{background:#f0fdf4;border-color:#bbf7d0}.usage-balance strong{color:#027a48}
.usage-token-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:8px 0 12px}.usage-token-grid>div{padding:10px 12px;border-radius:11px;background:#f2f4f7;display:grid;gap:3px}.usage-token-grid strong{font-size:1rem}
.usage-budget-admin{margin-top:14px;padding-top:14px;border-top:1px solid #e4e7ec}.usage-budget-admin label{display:flex;align-items:center;justify-content:space-between;gap:14px}.usage-budget-admin label>span{display:grid;gap:3px}.usage-budget-admin small{color:#667085}.usage-budget-input{display:flex;align-items:center;gap:6px}.usage-budget-input input{width:120px}.usage-budget-input button{width:auto}.usage-disclaimer{font-size:.78rem;color:#667085;line-height:1.5;margin:12px 0 0}
@media(max-width:640px){.usage-money-grid{grid-template-columns:1fr}.usage-token-grid{grid-template-columns:repeat(3,1fr)}.usage-budget-admin label{display:grid}.usage-budget-input input{flex:1;width:auto}}


/* R6.18 - OpenAI actual usage status */
.usage-warning{
  margin:10px 0;
  padding:10px 12px;
  border-radius:12px;
  background:#fff7ed;
  border:1px solid #fed7aa;
  color:#9a3412;
  font-size:.88rem;
  line-height:1.5;
}


/* ==========================================================================
   R6.19 - OpenAI official Usage/Costs API
   ========================================================================== */
.usage-sync-status{
  margin:10px 0 14px;
  padding:9px 11px;
  border-radius:10px;
  background:#f2f4f7;
  color:#475467;
  font-size:.88rem;
  font-weight:700;
}
.usage-sync-status.connected{
  background:#ecfdf3;
  color:#027a48;
}
.usage-sync-status.syncing{
  background:#eff8ff;
  color:#175cd3;
}
.usage-sync-status.error{
  background:#fef3f2;
  color:#b42318;
}
.usage-period-title{
  margin:16px 0 7px;
  font-weight:800;
  color:#344054;
}
.usage-period-title small{
  margin-left:5px;
  font-weight:500;
  color:#98a2b3;
}
.usage-admin-help{
  margin-top:12px;
  padding:12px;
  border:1px solid #fdb022;
  border-radius:12px;
  background:#fffaeb;
  color:#7a2e0e;
}
.usage-admin-help p{
  margin:5px 0 0;
  line-height:1.55;
}
.usage-admin-help code{
  overflow-wrap:anywhere;
}


/* ==========================================================================
   R6.20 - Family account delete / re-register
   ========================================================================== */

.account-card-head,
.account-list-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.account-create-box{
  margin-top:14px;
  padding:14px;
  border:1px solid #eaecf0;
  border-radius:14px;
  background:#f9fafb;
}

.account-create-box h3,
.account-list-head h3{
  margin:0 0 10px;
}

.account-create-form{
  display:grid;
  grid-template-columns:1fr 1fr 1.2fr auto;
  gap:8px;
}

.account-count{
  color:#667085;
  font-size:.9rem;
  font-weight:700;
}

.family-account-list{
  display:grid;
  gap:8px;
  margin-top:8px;
}

.family-account-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:11px 12px;
  border:1px solid #eaecf0;
  border-radius:13px;
  background:#fff;
}

.family-account-main{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.family-account-avatar{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  flex:0 0 38px;
  border-radius:50%;
  background:#f2f4f7;
  font-size:19px;
}

.family-account-text{
  display:grid;
  gap:2px;
  min-width:0;
}

.family-account-text strong{
  color:#101828;
}

.family-account-text span,
.family-account-text small{
  color:#667085;
  font-size:.82rem;
}

.family-account-actions{
  flex:none;
}

.account-delete-btn{
  width:auto;
  min-width:82px;
  background:#fff!important;
  color:#b42318!important;
  border:1px solid #fda29b!important;
}

.account-delete-btn:hover{
  background:#fef3f2!important;
}

.account-protected{
  padding:5px 8px;
  border-radius:999px;
  background:#f2f4f7;
  color:#667085;
  font-size:.78rem;
}

.account-delete-warning{
  margin-top:14px;
  padding:12px;
  border:1px solid #fdb022;
  border-radius:12px;
  background:#fffaeb;
  color:#7a2e0e;
}

.account-delete-warning p{
  margin:5px 0 0;
  line-height:1.55;
  font-size:.88rem;
}

@media(max-width:760px){
  .account-card-head{
    align-items:flex-start;
  }

  .account-create-form{
    grid-template-columns:1fr;
  }

  .family-account-row{
    align-items:flex-start;
  }

  .family-account-actions{
    align-self:center;
  }

  .account-delete-btn{
    min-width:70px;
    padding-left:8px;
    padding-right:8px;
  }
}


/* R6.22B_MOBILE_CHAT_CSS_ONLY_BEGIN
   Mobile Family Chat layout fix.
   HTML/index.html is intentionally NOT modified.
*/
.family-chat-main{
  grid-template-rows:auto minmax(0,1fr) auto auto auto;
}

@media(max-width:760px){
  #familyChatPanel.active{
    height:calc(100dvh - 126px);
    min-height:0;
    padding:6px 6px 0;
    overflow:hidden;
  }

  #familyChatPanel .family-chat-shell{
    display:flex;
    flex-direction:column;
    height:100%;
    min-height:0;
    overflow:hidden;
    border-radius:12px;
  }

  #familyChatPanel .family-chat-sidebar{
    flex:0 0 auto;
    max-height:96px;
    overflow:auto;
    border-right:0;
    border-bottom:1px solid #e4e7ec;
  }

  #familyChatPanel .family-chat-side-head{
    min-height:38px;
    padding:5px 8px;
  }

  #familyChatPanel .family-chat-label{
    padding:5px 8px 3px;
  }

  #familyChatPanel .family-user,
  #familyChatPanel .family-room{
    padding:6px 8px;
  }

  #familyChatPanel .family-chat-main{
    flex:1 1 auto;
    height:auto;
    min-height:0;
    overflow:hidden;
    display:grid;
    grid-template-rows:auto minmax(0,1fr) auto auto auto;
  }

  #familyChatPanel .family-chat-head{
    min-height:40px;
    padding:6px 9px;
  }

  #familyChatPanel .family-chat-messages{
    min-height:0;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    padding:8px 7px 10px;
    scroll-padding-bottom:12px;
  }

  #familyChatPanel .family-reply-preview,
  #familyChatPanel .family-pending-files{
    min-height:0;
    flex:0 0 auto;
  }

  #familyChatPanel .family-chat-composer{
    position:relative !important;
    left:auto !important;
    right:auto !important;
    bottom:auto !important;
    width:100% !important;
    flex:0 0 auto;
    z-index:20;
    display:flex;
    gap:6px;
    padding:7px 8px calc(7px + env(safe-area-inset-bottom));
    background:#fff;
    border-top:1px solid #e4e7ec;
    box-sizing:border-box;
  }

  #familyChatPanel .family-chat-composer textarea{
    flex:1 1 auto;
    width:auto;
    min-width:0;
    min-height:42px;
    max-height:92px;
    font-size:16px;
    line-height:1.35;
    resize:none;
  }

  #familyChatPanel .family-chat-composer .family-attach-btn{
    flex:0 0 40px;
    width:40px;
    min-width:40px;
    height:40px;
    min-height:40px;
  }

  #familyChatPanel .family-chat-composer .family-send-btn{
    flex:0 0 56px;
    width:56px;
    min-width:56px;
    padding:8px 5px;
  }

  nav{
    min-height:58px;
    height:58px;
  }

  nav button{
    min-width:50px;
    font-size:17px;
    padding:3px 2px;
  }

  nav button span{
    font-size:10px;
  }
}

@supports not (height:100dvh){
  @media(max-width:760px){
    #familyChatPanel.active{height:calc(100vh - 126px)}
  }
}
/* R6.22B_MOBILE_CHAT_CSS_ONLY_END */



/* R6.22C_MOBILE_CHAT_LAYOUT_CACHE_FIX_BEGIN
   Mobile family chat: fixed viewport layout + always-visible composer.
*/
@media (max-width:760px){

  /* Header + bottom nav consume the screen edges. */
  #familyChatPanel.panel.active{
    display:block;
    height:calc(100dvh - 124px);
    min-height:0;
    margin:0;
    padding:6px;
    overflow:hidden;
    box-sizing:border-box;
  }

  #familyChatPanel .family-chat-shell{
    display:grid;
    grid-template-columns:1fr;
    grid-template-rows:auto minmax(0,1fr);
    width:100%;
    height:100%;
    min-height:0;
    margin:0;
    overflow:hidden;
    border-radius:12px;
  }

  /* Keep room/user selector compact on phones. */
  #familyChatPanel .family-chat-sidebar{
    min-height:0;
    max-height:82px;
    overflow-x:auto;
    overflow-y:auto;
    border-right:0;
    border-bottom:1px solid #e4e7ec;
  }

  #familyChatPanel .family-chat-side-head{
    min-height:32px;
    padding:3px 7px;
    position:static;
  }

  #familyChatPanel .family-chat-label{
    padding:4px 7px 2px;
    font-size:10px;
  }

  #familyChatPanel .family-user,
  #familyChatPanel .family-room{
    padding:4px 7px;
    min-height:30px;
  }

  /*
   * Five rows are present in the DOM:
   * head / messages / reply / pending-files / composer
   */
  #familyChatPanel .family-chat-main{
    display:grid;
    grid-template-rows:auto minmax(0,1fr) auto auto auto;
    width:100%;
    height:100%;
    min-height:0;
    overflow:hidden;
  }

  #familyChatPanel .family-chat-head{
    min-height:38px;
    padding:5px 8px;
  }

  #familyChatPanel .family-chat-messages{
    min-height:0;
    height:auto;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    padding:7px 6px 9px;
  }

  #familyChatPanel .family-reply-preview[hidden],
  #familyChatPanel .family-pending-files[hidden],
  #familyChatPanel #familyChatFile[hidden]{
    display:none!important;
  }

  #familyChatPanel .family-reply-preview:not([hidden]),
  #familyChatPanel .family-pending-files:not([hidden]){
    flex:0 0 auto;
  }

  /* Composer belongs to the grid, never below the bottom navigation. */
  #familyChatPanel .family-chat-composer{
    position:relative!important;
    inset:auto!important;
    bottom:auto!important;
    z-index:30;
    display:flex;
    align-items:flex-end;
    gap:5px;
    width:100%!important;
    min-width:0;
    margin:0;
    padding:6px 7px calc(6px + env(safe-area-inset-bottom));
    background:#fff;
    border-top:1px solid #e4e7ec;
    box-sizing:border-box;
  }

  #familyChatPanel .family-chat-composer textarea{
    flex:1 1 auto;
    width:auto!important;
    min-width:0;
    min-height:40px;
    max-height:86px;
    padding:8px 9px;
    font-size:16px;
    line-height:1.3;
    resize:none;
  }

  #familyChatPanel .family-chat-composer .family-attach-btn{
    flex:0 0 38px;
    width:38px!important;
    min-width:38px;
    height:38px;
    min-height:38px;
  }

  #familyChatPanel .family-chat-composer .family-send-btn{
    flex:0 0 54px;
    width:54px!important;
    min-width:54px;
    padding:8px 4px;
  }

  /* Slightly slimmer bottom navigation gives chat more usable height. */
  nav{
    min-height:58px;
    height:58px;
  }

  nav button{
    min-width:52px;
    padding:3px 2px;
    font-size:17px;
  }

  nav button span{
    font-size:10px;
  }
}

@supports not (height:100dvh){
  @media(max-width:760px){
    #familyChatPanel.panel.active{
      height:calc(100vh - 124px);
    }
  }
}
/* R6.22C_MOBILE_CHAT_LAYOUT_CACHE_FIX_END */



/* R6.22D_MOBILE_CHAT_LAYOUT_CACHE_FIX_BEGIN */
@media (max-width:760px){
  #familyChatPanel.panel.active{
    display:block;
    height:calc(100dvh - 124px);
    min-height:0;
    margin:0;
    padding:6px;
    overflow:hidden;
    box-sizing:border-box;
  }

  #familyChatPanel .family-chat-shell{
    display:grid;
    grid-template-columns:1fr;
    grid-template-rows:auto minmax(0,1fr);
    width:100%;
    height:100%;
    min-height:0;
    margin:0;
    overflow:hidden;
    border-radius:12px;
  }

  #familyChatPanel .family-chat-sidebar{
    min-height:0;
    max-height:82px;
    overflow-x:auto;
    overflow-y:auto;
    border-right:0;
    border-bottom:1px solid #e4e7ec;
  }

  #familyChatPanel .family-chat-side-head{
    min-height:32px;
    padding:3px 7px;
    position:static;
  }

  #familyChatPanel .family-chat-label{
    padding:4px 7px 2px;
    font-size:10px;
  }

  #familyChatPanel .family-user,
  #familyChatPanel .family-room{
    padding:4px 7px;
    min-height:30px;
  }

  #familyChatPanel .family-chat-main{
    display:grid;
    grid-template-rows:auto minmax(0,1fr) auto auto auto;
    width:100%;
    height:100%;
    min-height:0;
    overflow:hidden;
  }

  #familyChatPanel .family-chat-head{
    min-height:38px;
    padding:5px 8px;
  }

  #familyChatPanel .family-chat-messages{
    min-height:0;
    height:auto;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
    padding:7px 6px 9px;
  }

  #familyChatPanel .family-reply-preview[hidden],
  #familyChatPanel .family-pending-files[hidden],
  #familyChatPanel #familyChatFile[hidden]{
    display:none!important;
  }

  #familyChatPanel .family-chat-composer{
    position:relative!important;
    inset:auto!important;
    bottom:auto!important;
    z-index:30;
    display:flex;
    align-items:flex-end;
    gap:5px;
    width:100%!important;
    min-width:0;
    margin:0;
    padding:6px 7px calc(6px + env(safe-area-inset-bottom));
    background:#fff;
    border-top:1px solid #e4e7ec;
    box-sizing:border-box;
  }

  #familyChatPanel .family-chat-composer textarea{
    flex:1 1 auto;
    width:auto!important;
    min-width:0;
    min-height:40px;
    max-height:86px;
    padding:8px 9px;
    font-size:16px;
    line-height:1.3;
    resize:none;
  }

  #familyChatPanel .family-chat-composer .family-attach-btn{
    flex:0 0 38px;
    width:38px!important;
    min-width:38px;
    height:38px;
    min-height:38px;
  }

  #familyChatPanel .family-chat-composer .family-send-btn{
    flex:0 0 54px;
    width:54px!important;
    min-width:54px;
    padding:8px 4px;
  }

  nav{
    min-height:58px;
    height:58px;
  }

  nav button{
    min-width:52px;
    padding:3px 2px;
    font-size:17px;
  }

  nav button span{
    font-size:10px;
  }
}

@supports not (height:100dvh){
  @media(max-width:760px){
    #familyChatPanel.panel.active{
      height:calc(100vh - 124px);
    }
  }
}
/* R6.22D_MOBILE_CHAT_LAYOUT_CACHE_FIX_END */

