/* Frontend recovery layer for Du Temple au Nouveau Monde
   Complements legacy style.css without replacing book typography/layout. */

/* AI */
.ai-fab{position:fixed;right:28px;bottom:28px;z-index:950;border:1px solid #cbb8a3;background:#fffdf9;color:#2e2924;border-radius:999px;padding:12px 18px;font:600 14px/1.2 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;box-shadow:0 10px 32px rgba(35,28,22,.16);cursor:pointer}
.ai-panel{position:fixed;top:0;right:0;width:min(520px,100vw);height:100vh;z-index:1200;background:#fffdf9;border-left:1px solid #ddd3ca;box-shadow:-20px 0 55px rgba(0,0,0,.18);display:flex;flex-direction:column;transform:translateX(102%);transition:transform .22s ease}
.ai-panel.open{transform:translateX(0)}
.ai-head,.external-head,.v2-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:20px 22px 18px;border-bottom:1px solid #e2d9d0}
.ai-head strong,.external-head strong,.v2-head strong{display:block;font:700 20px/1.2 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#27231f}
.ai-head small,.external-head small,.v2-head small{display:block;margin-top:3px;color:#7b726b;font:400 13px/1.3 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
#ai-close,#external-close,#v2-close{border:0;background:transparent;color:#171513;font-size:30px;line-height:1;cursor:pointer}
.ai-status{padding:11px 22px;border-bottom:1px solid #e6ddd4;background:#f7f3ed;color:#43684e;font:500 13px/1.3 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.ai-status.err{color:#9a3f33}
.ai-messages{flex:1;overflow-y:auto;padding:22px;display:flex;flex-direction:column;gap:16px}.ai-msg{max-width:92%;border-radius:14px;padding:16px 18px;font:400 17px/1.55 Georgia,"Times New Roman",serif;white-space:pre-wrap}.ai-user{align-self:flex-end;background:#27231f;color:white}.ai-assistant{align-self:flex-start;background:#f1ece4;color:#27231f}
.ai-sources,.v2-sources{margin-top:14px;padding-top:12px;border-top:1px solid #d6cec5;display:flex;flex-direction:column;gap:6px;font:400 13px/1.35 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.ai-sources a,.v2-sources a{color:#8b4e26;text-decoration:none}
.ai-form{display:flex;gap:10px;padding:16px 18px;border-top:1px solid #ddd3ca;background:#fffdf9}.ai-form textarea{flex:1;resize:vertical;min-height:64px;max-height:160px;border:1px solid #d4c9bf;border-radius:10px;padding:12px;background:white;color:#2d2925;font:400 16px/1.4 Georgia,"Times New Roman",serif}.ai-form button{align-self:flex-end;border:0;border-radius:9px;background:#8a4d27;color:white;padding:12px 18px;font-weight:700;cursor:pointer}
.ai-backdrop,.external-backdrop,.v2-backdrop{position:fixed;inset:0;background:rgba(20,18,16,.42);opacity:0;visibility:hidden;transition:.2s}.ai-backdrop{z-index:1150}.external-backdrop{z-index:1250}.v2-backdrop{z-index:1350}.ai-backdrop.open,.external-backdrop.open,.v2-backdrop.open{opacity:1;visibility:visible}

/* Header tools */
.header-tools-wrap{position:relative;z-index:1100;margin-left:auto}.header-tools-toggle{display:flex;align-items:center;gap:7px;border:1px solid #cbb8a3;background:#fffaf4;color:#4a392c;border-radius:999px;padding:9px 15px;font-weight:600;cursor:pointer}.header-tools-menu{position:absolute;top:calc(100% + 10px);right:0;width:340px;max-height:80vh;overflow:auto;padding:15px;background:#fffdf9;border:1px solid #d9cec3;border-radius:14px;box-shadow:0 18px 55px rgba(0,0,0,.18)}.header-tools-menu[hidden]{display:none!important}.header-tools-title{padding:2px 4px 11px;border-bottom:1px solid #e3d9d0}.header-tools-title strong{display:block;font:700 17px/1.2 system-ui}.header-tools-title small{color:#82786f;font-size:12px}.header-tools-menu section{padding:12px 4px;border-bottom:1px solid #ebe3dc}.header-tools-menu h4{margin:0 0 8px;color:#9a765f;text-transform:uppercase;letter-spacing:.12em;font:700 11px/1 system-ui}.header-tools-menu button{display:block;width:100%;text-align:left;border:0;background:transparent;padding:7px 4px;color:#332e29;cursor:pointer;font:500 14px/1.25 system-ui}.header-tools-menu button:hover{background:#f3ede6;border-radius:7px}

/* Contextual selection */
.term-popover{position:fixed;z-index:5000;min-width:270px;max-width:390px;padding:13px;background:#fffdf9;border:1px solid #d6cbc1;border-radius:12px;box-shadow:0 18px 50px rgba(0,0,0,.23);color:#302a25;font-family:system-ui}.term-popover[hidden]{display:none!important}.term-popover-title{margin-bottom:10px;font-size:15px;font-weight:700}.term-popover-actions{display:grid;gap:6px}.term-popover-actions button{display:block;width:100%;padding:8px 10px;border:0;border-radius:7px;background:#f2ece5;color:#332c27;text-align:left;cursor:pointer;font:500 13px/1.3 system-ui}.term-popover-actions button:hover{background:#e7ddd3}.term-popover small{display:block;margin-top:9px;color:#7d7269;font-size:11px}.selection-toolbar{position:fixed;z-index:5100;display:flex;flex-wrap:wrap;gap:5px;padding:6px;max-width:min(760px,calc(100vw - 20px));background:#2e2925;border-radius:10px;box-shadow:0 13px 38px rgba(0,0,0,.28)}.selection-toolbar[hidden]{display:none!important}.selection-toolbar button{border:0;border-radius:6px;background:#fffdf9;color:#302a25;padding:7px 10px;cursor:pointer;white-space:nowrap;font:600 12px/1.2 system-ui}

/* External search */
.external-drawer,.v2-drawer{position:fixed;top:0;right:0;width:min(620px,100vw);height:100vh;background:#fffdf9;border-left:1px solid #ddd2c8;box-shadow:-22px 0 60px rgba(0,0,0,.2);transform:translateX(102%);transition:transform .22s ease;display:flex;flex-direction:column}.external-drawer{z-index:1300}.v2-drawer{z-index:1400}.external-drawer.open,.v2-drawer.open{transform:translateX(0)}.external-warning{padding:11px 22px;background:#f4eee5;color:#80624f;border-bottom:1px solid #e1d6cc;font-size:13px}.external-loading{padding:18px 22px}.external-results,.v2-body{flex:1;overflow-y:auto;padding:20px 22px}.external-result{padding:14px 0;border-bottom:1px solid #e7ded6}.external-result a{display:block;margin-top:5px;color:#814b28;font-weight:600;text-decoration:none}.external-result p{margin:6px 0 0;color:#5e5650;font-size:14px;line-height:1.45}.external-badge{display:inline-block;padding:3px 7px;border-radius:999px;background:#eee6dd;color:#6d5e52;font-size:11px}.external-footer{padding:16px 22px;border-top:1px solid #ded4ca}.external-footer button,.external-empty button{border:1px solid #b99a82;border-radius:8px;background:white;color:#77451f;padding:9px 12px;cursor:pointer}

/* V2/V3/V4/V5 shared tool UI */
.v2-tools,.v3-tools,.v4-tools{display:none!important}.v2-head-copy{min-width:0}.v2-head-actions{display:flex;gap:8px}.v2-body input,.v2-body textarea,.v2-body select{box-sizing:border-box;width:100%;margin:6px 0 10px;padding:10px 12px;border:1px solid #d3c8be;border-radius:9px;background:#fff;color:#302a25;font:400 14px/1.4 system-ui}.v2-primary,.v5-matrix-btn{border:0;border-radius:9px;background:#332b25;color:#fff;padding:10px 14px;font-weight:700;cursor:pointer}.v2-output{margin-top:14px;padding:14px;border-radius:10px;background:#f4efe9;color:#302a25;white-space:pre-wrap;line-height:1.55}.v3-presets{display:flex;gap:6px;flex-wrap:wrap;margin:6px 0 12px}.v3-presets button{border:1px solid #d2c6bb;background:#fff;border-radius:999px;padding:6px 10px;cursor:pointer}.v4-codes{display:flex;gap:6px;flex-wrap:wrap}.v4-graph-wrap{overflow:auto;border:1px solid #ded4ca;border-radius:12px;background:#fff;padding:10px}.v4-graph-svg{min-width:760px}.v4-node{cursor:pointer}.v4-node-note,.v4-edge-label{font:12px system-ui}.v5-intro{padding:12px 14px;background:#f4efe9;border-radius:10px;margin-bottom:14px}.v5-level-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}.v5-level-card{border:1px solid #d7cdc3;background:#fff;border-radius:12px;padding:14px;text-align:left;cursor:pointer}.v5-level-card strong{display:block;margin-bottom:5px}.v5-level-card small{color:#71685f}.v5-level-card.active{border-color:#8a4d27;box-shadow:0 0 0 2px rgba(138,77,39,.1)}

/* Editorial / concept studios */
.studio-tabs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px}.studio-tabs button{border:1px solid #d6ccc2;background:#fff;border-radius:999px;padding:8px 11px;cursor:pointer}.studio-tabs button.active{background:#332b25;color:#fff;border-color:#332b25}.studio-tab-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:currentColor;margin-right:5px}.studio-form-card,.editorial-review,.concept-form-card{border:1px solid #dfd6ce;background:#fff;border-radius:12px;padding:14px;margin-bottom:14px}.studio-field{display:block;margin-bottom:12px}.studio-field>span{display:block;margin-bottom:5px;font:600 12px system-ui;color:#6d6259}.studio-input-wrap input,.studio-field select,.studio-field textarea{width:100%;box-sizing:border-box;border:1px solid #d3c8be;border-radius:9px;padding:10px;background:#fff}.editorial-actions,.studio-memory-actions{display:flex;gap:8px;flex-wrap:wrap}.studio-secondary{border:1px solid #cfc2b6;background:#f5efe9;border-radius:8px;padding:9px 12px;cursor:pointer}.studio-output,.editorial-answer{margin-top:14px;padding:14px;background:#f4efe9;border-radius:10px;white-space:pre-wrap}.editorial-memory-list,.concept-list{display:grid;gap:10px}.concept-relation,.editorial-memory-list>div{border:1px solid #e1d8d0;border-radius:10px;padding:12px;background:#fff}.concept-arrow{padding:0 6px;color:#8a4d27}.concept-epistemic,.coverage-status,.source-note{font-size:12px;color:#776d64}.studio-empty{padding:22px;text-align:center;color:#746a61}.studio-empty-icon{font-size:28px;margin-bottom:8px}.studio-save-zone,.studio-memory-feedback{margin-top:12px;padding:10px;background:#f4efe9;border-radius:9px}.studio-memory-label,.studio-memory-help{font-size:12px;color:#786e65}

/* Export */
.book-export-overlay{position:fixed;inset:0;z-index:100000;background:rgba(30,24,20,.55);display:flex;align-items:center;justify-content:center;padding:18px}.book-export-overlay[hidden]{display:none!important}.book-export-panel{width:min(720px,100%);max-height:90vh;overflow:auto;background:#fffdf9;border:1px solid #d8cec4;border-radius:18px;box-shadow:0 24px 80px rgba(0,0,0,.28);padding:22px;color:#2f2924}.book-export-head{display:flex;justify-content:space-between;gap:18px;align-items:flex-start;margin-bottom:16px}.book-export-close{border:0;background:#eee7df;border-radius:999px;width:36px;height:36px;font-size:22px;cursor:pointer}.book-export-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.book-export-card{border:1px solid #ded5cd;border-radius:14px;padding:14px;background:#fff}.book-export-card.full{grid-column:1/-1}.book-export-row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}.book-export-select,.book-export-file{width:100%;box-sizing:border-box;margin-top:8px;padding:10px;border:1px solid #cfc5bc;border-radius:10px;background:white}.book-export-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:18px}.book-export-btn{border:0;border-radius:10px;padding:10px 14px;cursor:pointer;font-weight:600}.book-export-btn.primary{background:#332b25;color:white}.book-export-btn.secondary{background:#eee7df;color:#332b25}.book-export-btn.danger{background:#f5e5e2;color:#7c2820}.book-export-feedback{margin-top:12px;padding:10px 12px;border-radius:10px;background:#f3eee8;display:none}

@media(max-width:700px){.ai-panel,.external-drawer,.v2-drawer{width:100vw}.header-tools-menu{width:min(340px,calc(100vw - 24px))}.v5-level-grid{grid-template-columns:1fr}.book-export-grid{grid-template-columns:1fr}.book-export-card.full{grid-column:auto}.selection-toolbar{left:10px!important;right:10px;max-width:none}}
