/* ================= Dendritic Mail ================= */
:root {
  --brand: #0b7285;
  --brand-2: #4c2fb0;
  --brand-soft: #e3f4f6;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --line: #e2e6ec;
  --text: #1c2430;
  --muted: #677386;
  --hover: #eef2f6;
  --sel: #dcedf0;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --shadow: 0 10px 40px rgba(16, 24, 40, .18);
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3bc9db;
    --brand-soft: #123a42;
    --bg: #12161c;
    --panel: #1a1f27;
    --panel-2: #20262f;
    --line: #2c333e;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --hover: #252c36;
    --sel: #17414a;
    --shadow: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.boot { height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 6px 14px; }
.err { color: var(--danger); }
.hidden { display: none !important; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 13px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; color: var(--text); flex: none; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.on { color: var(--brand); background: var(--brand-soft); }
.tool { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; white-space: nowrap; }
.tool:hover { background: var(--hover); }
.tool .lbl { font-size: 13px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

/* ---------- login ---------- */
.login { height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #0b7285, #4c2fb0); }
.login form { width: min(380px, 100%); background: var(--panel); border-radius: 16px; padding: 30px 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login .logo { display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .input { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 11px; outline: none; width: 100%; }
.field input:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- estructura ---------- */
.shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 250px minmax(300px, 400px) 1fr; }
.sidebar { background: var(--panel-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; }
.compose-btn { margin: 6px 14px 10px; justify-content: center; padding: 10px; }
#folders { flex: 1; overflow-y: auto; padding: 4px 0 10px; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; gap: 4px; }
.side-foot .tool { flex: 1; justify-content: center; }

.fitem { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 14px 7px calc(16px + var(--depth, 0) * 14px); border-radius: 0 20px 20px 0; margin-right: 10px; }
.fitem:hover { background: var(--hover); }
.fitem.active { background: var(--sel); font-weight: 600; }
.fitem .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem .count { font-size: 12px; font-weight: 700; color: var(--brand); }
.acc { margin-top: 6px; }
.acc-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 8px 14px; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.acc-head .acc-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chev { transition: transform .15s; font-size: 16px; }
.chev.open { transform: rotate(90deg); }

.listpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px 14px; }
.pane-head h2 { flex: 1; font-size: 17px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchbar { display: flex; gap: 8px; align-items: center; padding: 2px 12px 10px; border-bottom: 1px solid var(--line); }
.search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--hover); border-radius: 8px; padding: 0 10px; }
.search input { flex: 1; border: 0; background: transparent; padding: 8px 0; outline: none; min-width: 0; }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.row { position: relative; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--sel); }
.row.unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.row.unread .who, .row.unread .subj { font-weight: 700; }
.row.unread .when { color: var(--brand); font-weight: 600; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-sub { display: flex; align-items: center; gap: 5px; margin-top: 2px; color: var(--text); }
.row-sub .subj { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.row-sub .i { width: 14px; height: 14px; color: var(--muted); }
.row-sub .i.flag { color: #e67700; fill: #e67700; }
.row .accdot { position: absolute; left: 8px; top: 15px; width: 6px; height: 6px; border-radius: 50%; }
.row-actions { position: absolute; right: 8px; bottom: 6px; display: none; gap: 2px; background: var(--hover); border-radius: 7px; }
.row:hover .row-actions { display: flex; }
.row-actions .icon-btn { width: 28px; height: 28px; }
.row-actions .i { width: 15px; height: 15px; }
.list-more { padding: 14px; text-align: center; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- lectura ---------- */
.readpane { min-width: 0; min-height: 0; background: var(--panel); display: flex; flex-direction: column; }
.reader-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; }
.reader-empty img { width: 90px; opacity: .25; }
.reader-bar { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.reader-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: none; }
.reader-scroll { flex: 1; overflow-y: auto; padding: 18px 24px 40px; }
.subject { font-size: 21px; margin: 0 0 16px; font-weight: 600; word-break: break-word; }
.hdr { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-size: 15px; }
.hdr-main { flex: 1; min-width: 0; }
.hdr .from { word-break: break-word; }
.hdr .to { font-size: 12.5px; word-break: break-word; }
.hdr .date { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--brand-soft); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.banner button { margin-left: auto; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.att { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; text-decoration: none; color: var(--text); max-width: 280px; background: var(--panel); }
.att:hover { background: var(--hover); }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.att .sz { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.att .x { border: 0; background: transparent; padding: 0 0 0 4px; color: var(--muted); display: grid; }
.body-frame { width: 100%; border: 0; min-height: 120px; display: block; background: #fff; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .body-frame { padding: 8px; } }

/* ---------- Dendritic-CIS: paciente e historia ---------- */
.reader-split { flex: 1; display: flex; min-height: 0; }
.reader-split .reader-scroll { flex: 1; min-width: 0; }
.tool.on { background: var(--brand-soft); color: var(--brand); }
#pt-strip:empty { display: none; }
#pt-strip { display: grid; gap: 8px; margin: -6px 0 16px; }
.pt-loading { display: flex; align-items: center; gap: 8px; }
.pt-note { margin: 0; }
.pt-card { border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); display: grid; gap: 6px; }
.pt-l1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.pt-nhc { font: 700 12px/1 ui-monospace, Consolas, monospace; background: var(--brand-2); color: #fff; border-radius: 6px; padding: 4px 7px; letter-spacing: .05em; }
.pt-name { font-size: 15px; }
.pt-item { color: var(--text); font-size: 13.5px; }
.pt-doc { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; user-select: all; }
.pt-emb { background: #fce4ec; color: #a61e4d; border-radius: 10px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }
.pt-emb.beta { background: #fff3bf; color: #8f5b00; }
.pt-l2 { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 12.5px; color: var(--muted); }
.pt-l2 b { color: var(--text); font-weight: 600; }
.pt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-actions .btn { padding: 5px 10px; font-size: 13px; text-decoration: none; color: var(--text); }
@media (prefers-color-scheme: dark) {
  .pt-emb { background: #4a1530; color: #ffb3cf; }
  .pt-emb.beta { background: #4a3b00; color: #ffe066; }
}

.hc-panel { width: min(460px, 45%); flex: none; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.hc-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.hc-who { flex: 1; min-width: 0; display: grid; }
.hc-who b, .hc-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.hc-tabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 12px; border-radius: 8px 8px 0 0; color: var(--muted); border-bottom: 2px solid transparent; }
.hc-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.hc-tabs .i { width: 16px; height: 16px; }
.hc-nav { display: flex; gap: 4px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }
.hc-nav select { flex: 1; min-width: 0; padding: 7px 8px; }
.hc-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.hc-body { flex: 1; overflow-y: auto; padding: 14px 16px 40px; }
.hc-title h3 { margin: 0; font-size: 17px; }
.hc-title { margin-bottom: 12px; }
.hc-model { background: #fff0f6; border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; font-size: 13.5px; }
@media (prefers-color-scheme: dark) { .hc-model { background: #3a1328; } }
.hc-sec { margin-bottom: 14px; }
.hc-sec h4 { margin: 0 0 4px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); }
.hc-html { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.hc-html p { margin: 0 0 .5em; }
.hc-html ul, .hc-html ol { margin: .2em 0 .5em; padding-left: 1.3em; }
.hc-html.pre { white-space: pre-wrap; }
.hc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hc-table th, .hc-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hc-table th { color: var(--muted); font-weight: 600; }
.hc-table tr.alt td { color: var(--danger); }
.hc-citas { display: grid; gap: 8px; }
.hc-cita { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.hc-cita.future { border-color: var(--brand); }
.hc-cita.cancel b { text-decoration: line-through; color: var(--muted); }

/* ---------- menús, diálogos, avisos ---------- */
.menu { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; max-height: 60vh; overflow-y: auto; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; text-align: left; }
.menu button:hover, .menu button.hl { background: var(--hover); }
.menu .sub { font-size: 12px; color: var(--muted); }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 20, .42); display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; width: min(440px, 100%); }
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 18px; color: var(--muted); white-space: pre-line; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: #222a35; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 90vw; animation: tin .2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 40px; }

/* ---------- redacción ---------- */
.compose-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 20, .35); display: grid; place-items: center; padding: 2vh 2vw; }
.compose { width: min(1000px, 100%); height: min(860px, 100%); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.compose-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.compose-head .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head .saved { font-size: 12px; color: var(--muted); }
.cf { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 0 14px; position: relative; }
.cf > label { width: 52px; color: var(--muted); font-size: 13px; flex: none; }
.cf input, .cf select { flex: 1; border: 0; background: transparent; padding: 10px 0; outline: none; min-width: 0; }
.cf .link { border: 0; background: transparent; color: var(--brand); font-size: 13px; padding: 4px; }
.toolbar { display: flex; align-items: center; gap: 1px; padding: 5px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; flex: none; }
.toolbar button { border: 0; background: transparent; min-width: 32px; height: 32px; border-radius: 6px; display: inline-grid; place-items: center; padding: 0 6px; }
.toolbar button:hover { background: var(--hover); }
.toolbar select { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 4px; height: 30px; font-size: 13px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }
.toolbar .color { position: relative; overflow: hidden; }
.toolbar .color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.toolbar .color .bar { position: absolute; left: 7px; right: 7px; bottom: 5px; height: 3px; border-radius: 2px; }
.editor { flex: 1; overflow-y: auto; padding: 16px 18px; outline: none; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 15px; line-height: 1.5; word-wrap: break-word; }
.editor img { max-width: 100%; height: auto; }
.editor p { margin: 0 0 .6em; }
.editor .dm-quote { color: var(--muted); }
.editor blockquote { margin: 0 0 0 .8em; padding-left: .8em; border-left: 3px solid var(--line); }
.compose-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); max-height: 120px; overflow-y: auto; }
.compose-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
.compose-foot .grow { flex: 1; }
.ai-toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 8px; flex: none; }
.ai-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ai-toggle .knob { width: 36px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.ai-toggle .knob::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.ai-toggle input:checked + .knob { background: linear-gradient(135deg, #0b7285, #4c2fb0); }
.ai-toggle input:checked + .knob::after { transform: translateX(16px); }
.ai-toggle input:focus-visible + .knob { outline: 2px solid var(--brand); outline-offset: 2px; }
.ai-toggle .ai-lbl { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.ai-toggle input:checked ~ .ai-lbl { color: var(--brand); }
.ai-toggle .i { width: 15px; height: 15px; }
.mic-btn { background: linear-gradient(135deg, #0b7285, #4c2fb0) !important; color: #fff !important; border: 0 !important; }
.dropzone { position: absolute; inset: 0; background: rgba(11, 114, 133, .14); border: 3px dashed var(--brand); border-radius: 14px; display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--brand); pointer-events: none; z-index: 5; }

.suggest { position: absolute; left: 60px; top: 100%; z-index: 20; min-width: 260px; }

/* ---------- dictado ---------- */
.dictate { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0, 0, 0, .12); padding: 16px 18px calc(16px + var(--safe-b)); border-radius: 14px 14px 0 0; display: grid; gap: 12px; }
.dictate-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dictate-head .grow { flex: 1; }
.rec { display: flex; align-items: center; gap: 16px; justify-content: center; padding: 8px 0; }
.rec-dot { width: 64px; height: 64px; border-radius: 50%; background: #e03131; display: grid; place-items: center; color: #fff; border: 0; box-shadow: 0 0 0 0 rgba(224, 49, 49, .5); animation: ring 1.4s infinite; }
.rec-dot .i { width: 26px; height: 26px; }
@keyframes ring { 70% { box-shadow: 0 0 0 18px rgba(224, 49, 49, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 49, 49, 0); } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.level { height: 6px; width: 160px; background: var(--line); border-radius: 3px; overflow: hidden; }
.level > div { height: 100%; width: 0; background: var(--brand); transition: width .08s; }
.dictate textarea { width: 100%; min-height: 110px; max-height: 30vh; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel-2); outline: none; }
.dictate .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.working { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 18px 0; color: var(--muted); }

/* ---------- configuración ---------- */
.settings { width: min(820px, 100%); height: min(720px, 100%); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); display: grid; grid-template-columns: 190px 1fr; overflow: hidden; }
.settings nav { background: var(--panel-2); border-right: 1px solid var(--line); padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; }
.settings nav h3 { margin: 0 8px 12px; font-size: 16px; }
.settings nav button { border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 8px; }
.settings nav button.active { background: var(--sel); font-weight: 600; }
.settings section { overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.settings section h2 { margin: 0; font-size: 18px; }
.settings .close { position: absolute; right: 10px; top: 10px; }
.acc-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.acc-card .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.switch b { display: block; font-weight: 600; }
.sig-editor { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-height: 260px; }
.sig-editor .editor { min-height: 200px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

.only-mobile { display: none !important; }
.fab { position: fixed; right: 18px; bottom: calc(20px + var(--safe-b)); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--brand); color: #fff; box-shadow: var(--shadow); z-index: 20; }
.fab .i { width: 24px; height: 24px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 29; display: none; }

/* ---------- móvil ---------- */
@media (max-width: 1100px) and (min-width: 861px) {
  .shell { grid-template-columns: 220px 330px 1fr; }
}
/* con el visor de historia abierto en pantallas medianas, se estrecha la lista */
@media (max-width: 1500px) and (min-width: 861px) {
  .shell:has(#reader.hc-open) { grid-template-columns: 210px 300px 1fr; }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 84vw); z-index: 30; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; }
  .listpane { border: 0; padding-top: env(safe-area-inset-top); }
  .readpane { position: fixed; inset: 0; z-index: 25; transform: translateX(102%); transition: transform .22s ease; padding-top: env(safe-area-inset-top); }
  .shell.view-message .readpane { transform: none; }
  .shell.view-message .fab { display: none !important; }
  .reader-scroll { padding: 14px 14px 40px; }
  .hc-panel { position: fixed; inset: 0; width: auto; z-index: 36; border: 0; padding-top: env(safe-area-inset-top); }
  .pt-actions .btn { flex: 1; justify-content: center; }
  .hdr { flex-wrap: wrap; }
  .hdr .date { order: 3; width: 100%; padding-left: 52px; white-space: normal; margin-top: -6px; }
  .subject { font-size: 19px; }
  .row-actions { display: none !important; }
  .row { padding: 12px 14px 12px 18px; }
  .compose-wrap { padding: 0; background: transparent; }
  .compose { width: 100%; height: 100%; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 100%; border-radius: 0; }
  .settings nav { flex-direction: row; overflow-x: auto; padding: 8px; padding-top: calc(8px + env(safe-area-inset-top)); border-right: 0; border-bottom: 1px solid var(--line); }
  .settings nav h3 { display: none; }
  .settings section { padding: 18px 16px; }
  .overlay.full { padding: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .tool .lbl { display: none; }
  .compose-foot { gap: 2px; padding-left: 6px; padding-right: 6px; }
  .compose-foot .tool { padding: 7px 8px; }
  .compose-foot .mic-btn { padding: 7px 11px; }
}
@media (prefers-color-scheme: light) {
  .hc-panel { background: #f1f3f5; }
  .hc-panel .hc-head, .hc-panel .hc-tabs, .hc-panel .hc-nav { background: #e9ecef; }
  .hc-panel .hc-nav select { background: #fff; }
  .hc-panel .hc-cita, .hc-panel .att { background: #fff; }
}
