/* The writer page. Phone first (360 px); the two-column layout starts at 960 px. */
body{padding-bottom:24px}
.bar{display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;padding:8px 12px;background:var(--surface);border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:8px;font-weight:600;font-size:1.15rem;color:var(--text);text-decoration:none;min-height:44px}
.lang{margin-left:auto;font:inherit;font-weight:600;border:1px solid var(--line-strong);background:var(--surface);color:var(--text);border-radius:999px;padding:4px 14px;min-height:44px;cursor:pointer}
#nav{display:flex;flex-wrap:wrap;gap:4px;order:3;width:100%}
.nav-btn{flex:1 0 auto;font:inherit;font-weight:600;min-height:44px;padding:0 10px;border:0;border-bottom:3px solid transparent;background:none;color:var(--muted);cursor:pointer}
.nav-btn[aria-current=page]{color:var(--brand-ink);border-bottom-color:var(--brand)}
.screen{padding:12px}
.narrow{max-width:44rem;margin:0 auto}
h1{font-size:1.45rem;margin:10px 0 8px}
h2{font-size:1.1rem;margin:0 0 8px}
.lead{margin:0 0 10px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px;margin:0 0 12px;min-width:0}
fieldset.card>legend,details.card>summary,details>summary{font-weight:600}
fieldset.card>legend{padding:0 6px}
details>summary{min-height:44px;display:flex;align-items:center;cursor:pointer;color:var(--brand-ink)}
details>summary::before{content:"+";display:inline-block;width:1.2em;font-weight:600}
details[open]>summary::before{content:"−"}
details>summary::-webkit-details-marker{display:none}
.field{margin:0 0 12px;min-width:0}
.field>label,.label{display:block;font-weight:600;margin:0 0 3px}
input[type=text],input[type=search],input[type=number],input[type=date],select,textarea{width:100%;min-height:46px;font:inherit;color:var(--text);background:#fff;border:2px solid var(--line-strong);border-radius:10px;padding:4px 10px}
input[type=file]{width:100%;min-height:46px;font:inherit}
textarea{line-height:1.5;padding:8px 10px;resize:vertical}
input[aria-invalid=true]{border-color:var(--err)}
::placeholder{color:#78716c;opacity:1}
.check{display:flex;align-items:flex-start;gap:12px;min-height:44px;padding:8px 0;cursor:pointer}
.check input{width:24px;height:24px;flex:none;margin:2px 0 0;accent-color:var(--brand)}
.btn.small{min-height:44px;padding:0 14px;font-size:.95rem}
.btn.wide{width:100%}
.btn kbd{font:inherit;font-size:.8rem;font-weight:400;opacity:.85;margin-left:8px;display:none}
.icon{width:44px;height:46px;flex:none;border:0;background:none;color:var(--muted);font:inherit;font-size:1.5rem;line-height:1;cursor:pointer;border-radius:10px}
.acts{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0}
.notice{background:var(--brand-soft);border:1px solid #a7d7c5;border-radius:12px;padding:10px 12px;margin:10px 0}
.notice.warn{background:var(--accent-soft);border-color:#e3c36a;color:var(--accent-ink)}
.bar-note{margin:8px 12px;display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.toast{position:fixed;left:12px;right:12px;bottom:12px;margin:0 auto;max-width:30rem;background:#1c1917;color:#fff;border-radius:12px;padding:10px 14px;text-align:center;z-index:30;pointer-events:none}
.toast:empty{display:none}
ul.plain{margin:6px 0;padding-left:1.3rem}
ul.plain li{margin:4px 0}
.safety{color:var(--muted);font-size:.95rem}
.logo-box{display:flex;align-items:center;gap:12px;margin:8px 0}
.logo-box img{max-width:96px;max-height:72px;border:1px solid var(--line)}

/* Chips: one-tap choices. Radio chips are real radio inputs, so arrows and Space work natively. */
.chips{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
.chip{display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:44px;padding:0 12px;border:2px solid var(--line-strong);border-radius:999px;background:#fff;color:var(--text);font:inherit;cursor:pointer;position:relative}
button.chip:hover{border-color:var(--brand)}
label.chip{padding:0}
label.chip input{position:absolute;opacity:0;width:100%;height:100%;margin:0;cursor:pointer}
label.chip span{display:inline-flex;align-items:center;min-height:40px;padding:0 12px;border-radius:999px}
label.chip input:checked+span{background:var(--brand);color:#fff;font-weight:600}
label.chip:focus-within{outline:3px solid var(--brand);outline-offset:2px}

/* Write screen */
.tabs{display:flex;gap:6px;margin:0 0 10px}
.tabs button{flex:1;min-height:44px;font:inherit;font-weight:600;border:2px solid var(--line-strong);border-radius:10px;background:#fff;color:var(--text);cursor:pointer}
.tabs button[aria-pressed=true]{background:var(--brand);border-color:var(--brand);color:#fff}
#s-write[data-view=form] .preview,#s-write[data-view=preview] #rx-form{display:none}
.tpl-bar{margin:0 0 10px}
.tpl-bar-label{font-weight:600;font-size:.95rem;color:var(--muted)}
.tpl-bar .chip kbd{font:inherit;font-size:.75rem;color:var(--muted);margin-left:6px;display:none}
.pt-row{display:flex;gap:8px}
.pt-row .grow{flex:1}
.pt-row .age{width:8.6rem;flex:none}
.age-box{display:flex;gap:4px}
.age-box input{width:3.4rem;flex:none;padding:4px 6px}
.age-box select{padding:4px 2px}
.rows{list-style:none;margin:0;padding:0}
.row{border-bottom:1px solid var(--line);padding:8px 0;margin:0}
.row-main{display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start}
.row-main .f-form{width:5.4rem;flex:none;padding:4px 4px;order:1}
.combo{position:relative;flex:1 0 8rem;min-width:0;order:2}
.row-main .row-del{order:3}
.f-name,.f-strength{text-transform:uppercase}
.f-name::placeholder,.f-strength::placeholder{text-transform:none}
.f-name{font-weight:600}
.row-main .f-strength,.row-main .f-dose,.row-main .f-dur{width:calc(33.333% - 4px);flex:none;order:4}
.combo-list{position:absolute;left:0;right:0;min-width:min(22rem,calc(100vw - 8rem));top:100%;z-index:20;margin:2px 0 0;padding:4px;list-style:none;background:#fff;border:2px solid var(--brand);border-radius:10px;box-shadow:0 6px 18px rgba(0,0,0,.18);max-height:15rem;overflow:auto}
.combo-list li{padding:8px 10px;border-radius:8px;min-height:44px;cursor:pointer}
.combo-list li[aria-selected=true]{background:var(--brand-soft);outline:2px solid var(--brand)}
.combo-list .opt-name{font-weight:600}
.combo-list .opt-line{display:block;color:var(--muted);font-size:.9rem}
.combo-list .opt-hint{color:var(--muted);font-size:.82rem;padding:4px 10px;min-height:0;cursor:default}
.row-sum{margin:4px 0 0;color:var(--muted);font-size:.92rem}
.row-sum:empty{display:none}
.row.active .row-sum{display:none}
.row-tools{display:none}
.row.active .row-tools{display:block}
.row-btns{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
.row-fav[aria-pressed=true]{background:var(--brand-soft)}
.row-extra{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
.row-hint{margin:4px 0}
.hint{margin-top:8px}
.follow{margin-top:10px}
.preview{overflow:auto;background:#d6d3d1;border-radius:12px;padding:8px}
.list{list-style:none;margin:0;padding:0}
.list>li{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:10px 12px;margin:0 0 8px}
.list .item-title{font-weight:600}
.list .item-sub{color:var(--muted);font-size:.95rem;margin:2px 0}
.list .acts{margin:6px 0 0}
#fav-edit .row-tools{display:block}
#fav-edit .row-sum,#fav-edit .row-fav,#fav-edit .row-del{display:none}

@media (min-width:960px){
  #nav{order:0;width:auto;margin-left:16px}
  .tabs{display:none}
  #s-write[data-view] .preview,#s-write[data-view] #rx-form{display:block}
  .split{display:flex;gap:16px;align-items:flex-start}
  #rx-form{width:46%;min-width:35rem;flex:none}
  .preview{flex:1;min-width:0;position:sticky;top:8px;max-height:calc(100vh - 16px)}
  .btn kbd,.tpl-bar .chip kbd{display:inline}
  .row-main{flex-wrap:nowrap}
  .row-main .row-del{order:5}
  .row-main .f-form{width:5.2rem}
  .row-main .f-strength{width:6.4rem;flex:none}
  .row-main .f-dose{width:6.2rem;flex:none}
  .row-main .f-dur{width:5.6rem;flex:none}
  .chip{min-height:36px}
  label.chip span{min-height:32px}
}
@media print{
  .bar,.bar-note,.toast,.tabs,#rx-form,.screen:not(#s-write){display:none!important}
  body{background:#fff;padding:0}
  .screen{padding:0}
  #s-write,#s-write .preview{display:block!important}
  .split{display:block}
  .preview{position:static;overflow:visible;max-height:none;background:none;padding:0;border-radius:0}
}
