:root.bl-root {
  --bg:#0a0a0a; --fg:#f2f2f2; --muted:#9ea0a4;
  --card:#121212; --surface:#151515; --border:#252525;
  --accent:#00ff00; --danger:#ff375f; --shadow:0 12px 32px rgba(0,0,0,.45);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html,body.bl-root { background: var(--bg); color: var(--fg); }
body.bl-root { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, 'Noto Sans JP', sans-serif; }
header{ position:sticky; top:0; z-index:5; background:var(--surface); border-bottom:1px solid var(--border); padding:12px 14px; }
header h1{ margin:0; font-size:18px; color:var(--accent); }
main{ padding:12px; display:grid; gap:16px; }

.card{ background:var(--card); border:1px solid var(--border); border-radius:16px; padding:12px; box-shadow:var(--shadow); }
.section-title{ color:var(--accent); font-weight:700; margin:0; font-size:22px; }
.muted{ color:var(--muted); }

.row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.btn{ appearance:none; border:1px solid var(--border); background:#1a1a1a; color:var(--fg); padding:10px 14px; border-radius:14px; font-size:14px; cursor:pointer; }
.btn-acc{ background: var(--accent); color:#001b00; border-color:#026902; font-weight:700; }
.btn-ghost{ background: transparent; }

.form-grid{ display:grid; gap:14px; }
.field{ display:grid; gap:8px; }
.label{ font-size:18px; color:var(--muted); }
.input{ width:100%; border:1px solid var(--border); background:#0f0f0f; color:#f2f2f2; padding:14px; border-radius:12px; font-size:18px; }
textarea.input{ resize:vertical; }

.backdrop[hidden]{ display:none!important; }
.backdrop{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:grid; place-items:center; z-index:2000; }
.modal{ width:min(92vw,560px); max-height:min(86vh,640px); overflow:auto; background:#151515; border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow); position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border); }
.modal-title{ margin:0; font-size:20px; color:var(--accent); }
.modal-body{ padding:12px; display:grid; gap:12px; line-height:1.3; }
.modal-foot{ padding:12px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }
.close-x{ appearance:none; background:transparent; border:none; color:#cfd1d4; font-size:22px; line-height:1; cursor:pointer; }

.toast[hidden]{ display:none!important; }
.toast{ position:fixed; left:50%; bottom:18px; transform:translateX(-50%); background:#111; color:#f2f2f2; padding:10px 12px; border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow); z-index:2100; opacity:0; transition:opacity .2s ease; }
.toast.show{ opacity:1; }

.title-row{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.pain-container{ display:grid; gap:12px; }
.pain-set{ background:#101010; border:1px solid var(--border); border-radius:12px; padding:12px; display:grid; gap:10px; }
.pain-grid{ display:grid; gap:10px; grid-template-columns: repeat(3, minmax(160px,1fr)); }
@media (max-width: 860px){ .pain-grid{ grid-template-columns: 1fr; } }
.pain-set .field{ margin:0; }
.pain-set .set-head{ display:flex; justify-content:flex-end; }
.pain-set .set-head .btn{ padding:6px 10px; border-radius:10px; }
.pain-note{ grid-column: 1 / -1; }

/* --- b4333: accordion and save button tweaks --- */
details { border-top: 1px solid var(--border,#e5e7eb); padding: 4px 0; }
details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
details > summary::-webkit-details-marker { display: none; }
details + details { margin-top: 8px; }
.section-title { margin: 8px 0; } /* keep visual consistency */

/* Keep the "痛み・違和感の記録" heading style for all section-title */
.card .section-title { /* assume this matches existing green */ }

/* Save button larger */
#save.btn { font-size: 1.05rem; padding: 14px 18px; min-width: 200px; height: 48px; }
        
/* --- b4334: accordion caret + header size tune --- */
.card details > summary{
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
}
.card details > summary::-webkit-details-marker{ display:none; }
.card details > summary::before{
  content: "▸";
  display:inline-block;
  transform: translateY(0.5px);
  transition: transform .15s ease;
  font-size: 18px;
  line-height: 1;
  opacity:.9;
}
.card details[open] > summary::before{
  transform: rotate(90deg);
}
/* label-size titles (keep green color) */
.card .section-title{ font-size:18px; color:var(--accent); margin:0; font-weight:700; }

/* --- b4334: pain actions full-width stacked --- */
#pain_actions{
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
#pain_actions .btn{
  width: 100%;
  display: block;
}
/* Ensure the title-row pushes the "追加" button to the far right */
#sec-pain summary .title-row{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}
#sec-pain #pain_add_set{
  margin-left: auto;
}

/* --- b4335: move Add button outside summary and pin to right --- */
#sec-pain{ position: relative; }
#sec-pain > .title-actions{
  position: absolute;
  top: 6px;
  right: 6px;
}
#sec-pain > .title-actions .btn{ padding: 6px 10px; }
@media (max-width: 480px){
  #sec-pain > .title-actions{ top: 6px; right: 4px; }
}

/* --- b4338: keep actions visible & full width --- */
#pain_actions{
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
#pain_actions .btn{
  width: 100%;
  display: block;
  min-height: 48px;
}

/* unify help '?' style */
.btn.ghost.q{ background:#0f0f0f; color:var(--fg); border:1px solid var(--border); }
