:root{
  /* Brand-inspired palette (match the logo’s blue/orange/purple/teal) */
  --white:#ffffff;
  --text:#0c1222;
  --muted:#6c7386;
  --line:#e9edf3;

  --brand1:#246BFD;  /* blue */
  --brand2:#FF7A2F;  /* orange */
  --brand3:#6A5CFF;  /* purple */
  --accent:#11D6A0;  /* teal */

  --panel:#ffffff;
  --panel-hover:#f6f8fc;
  --shadow:0 6px 24px rgba(0,0,0,.06);

  --radius:16px;

  --page-width: 8.5in;
  --page-height: 11in;
  --page-margin-top: 1in;
  --page-margin-bottom: 1in;
  --page-margin-left: 1in;
  --page-margin-right: 1in;
  
  --page-content-height: calc(
    var(--page-height) - var(--page-margin-top) - var(--page-margin-bottom)
  );


}

/* Base reset */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font:16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* WHITE base + soft, split-color gradients inspired by the logo */
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(36,107,253,.18), transparent 60%),
    radial-gradient(900px 500px at 88% 110%, rgba(255,122,47,.20), transparent 62%),
    radial-gradient(600px 400px at 85% 0%, rgba(106,92,255,.13), transparent 55%),
    radial-gradient(700px 420px at 0% 100%, rgba(17,214,160,.10), transparent 58%),
    var(--white);
}

/* Top bar (white, subtle blur & shadow) */
.topbar{
  height:72px;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 22px;
  background:rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-bottom:1px solid var(--line);
  box-shadow: var(--shadow);
  position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:12px; text-decoration:none}
.logo{
  width:44px; height:44px; border-radius:12px; object-fit:cover;
  box-shadow: 0 4px 16px rgba(36,107,253,.25), 0 4px 16px rgba(255,122,47,.18);
}
.topnav .btn-primary{
  display:inline-block;
  padding:10px 16px;
  border-radius:12px;
  background:linear-gradient(90deg, var(--brand1), var(--brand2));
  color:#fff; font-weight:700; text-decoration:none; border:0;
  box-shadow: 0 8px 24px rgba(36,107,253,.25);
  transition: transform .05s ease;
}
.topnav .btn-primary:active{ transform: translateY(1px); }

/* Layout */
.shell{display:grid; grid-template-columns:260px 1fr; min-height:calc(100vh - 72px)}
.sidebar{
  padding:18px;
  border-right:1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(106,92,255,.06), transparent 40%),
    var(--white);
}
.navlink{
  display:block; padding:12px 14px; border-radius:12px;
  color:var(--text); text-decoration:none; font-weight:600;
  transition: background .15s ease, transform .05s ease;
}
.navlink:hover{ background:var(--panel-hover); transform: translateY(-1px); }
.navlink.danger{ color:#d24d57; }
.divider{height:1px; background:var(--line); margin:12px 0}
.content{ padding:26px 28px 54px; }

/* Cards / panels */
.page h1{margin:0 0 12px; letter-spacing:.2px}
.cards{display:grid; gap:18px; grid-template-columns:repeat(auto-fit, minmax(280px,1fr))}
.card{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
  box-shadow: var(--shadow);
}
.btn-secondary{
  display:inline-block; margin-top:8px; padding:10px 12px; border-radius:10px;
  background:linear-gradient(90deg, rgba(36,107,253,.12), rgba(255,122,47,.12));
  color:var(--text); text-decoration:none; font-weight:600;
}

/* Auth forms */
.authcard{
  max-width:560px; margin:48px auto;
  background:var(--panel);
  border:1px solid var(--line); border-radius:var(--radius); padding:26px;
  box-shadow: var(--shadow);
}
.title{margin:0 0 6px}
.muted{color:var(--muted)} .small{font-size:.92rem}
.form{display:grid; gap:14px; margin-top:14px}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px}
label{display:grid; gap:6px; font-weight:600}
input, select, textarea{
  background:#fff; border:1px solid var(--line); color:var(--text);
  border-radius:12px; padding:10px 12px; outline:none;
}
input:focus, select:focus, textarea:focus{
  border-color: rgba(36,107,253,.45);
  box-shadow: 0 0 0 4px rgba(36,107,253,.12);
}
.password-wrap{display:grid; grid-template-columns:1fr auto; align-items:center}
.eye{
  background:transparent; border:0; color:var(--muted); cursor:pointer; padding:0 8px; font-size:14px
}
.btn-primary{
  padding:10px 14px; border-radius:12px;
  background:linear-gradient(90deg,var(--brand1),var(--brand2));
  border:0; color:#fff; font-weight:700; cursor:pointer;
  box-shadow: 0 10px 26px rgba(36,107,253,.25);
}

/* Tables / lists */
.list{
  margin-top:12px; border:1px solid var(--line); border-radius:12px; overflow:hidden;
  background:#fff; box-shadow: var(--shadow);
}
.row{display:grid; grid-template-columns:2fr 2fr 1fr; gap:12px; padding:12px 14px; border-top:1px solid var(--line)}
.row.head{background:linear-gradient(90deg, rgba(36,107,253,.06), rgba(255,122,47,.06)); font-weight:700}

/* Utilities */
.badge{
  display:inline-block; padding:4px 8px; border-radius:999px; font-weight:700; font-size:.82rem;
  background:linear-gradient(90deg, rgba(106,92,255,.14), rgba(17,214,160,.14));
}

/* --- My Templates UI --- */
.mt-12{margin-top:12px} .mt-20{margin-top:20px}
.btn-group{display:flex; gap:14px; flex-wrap:wrap}
.bigbtn{
  display:inline-block; padding:16px 18px; border-radius:14px; text-decoration:none;
  background:#fff; border:1px solid var(--line); color:var(--text); font-weight:700; box-shadow: var(--shadow);
}
.bigbtn.primary{background:linear-gradient(90deg, rgba(36,107,253,.10), rgba(255,122,47,.10)); border-color:rgba(36,107,253,.25)}
.panel{
  margin-top:18px; background:#fff; border:1px solid var(--line); border-radius:16px; box-shadow: var(--shadow); padding:16px;
}
.panel.hidden{display:none}
.panel-top{display:flex; align-items:center; justify-content:space-between}
.badge{display:inline-block; padding:6px 10px; border-radius:999px; font-weight:700; font-size:.82rem;
  background:linear-gradient(90deg, rgba(106,92,255,.16), rgba(17,214,160,.16));
}
.btn-light{
  padding:10px 14px; border-radius:12px; border:1px solid var(--line); background:#fff; font-weight:700; cursor:pointer;
}
.btn-primary.small{padding:8px 12px; font-size:.92rem}

/* ---------- Quill editor: Word-like Letter page ---------- */

/* Remove the old framed wrapper look; keep a little spacing under the toolbar */
.ql-editor-wrap{
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 0;
  margin-top: 8px;
}

/* The Quill container becomes the sheet */
#quill-editor {
  width: var(--page-width);
  min-height: var(--page-height);
  margin: 0 auto;
  background: #ffffff;
  box-shadow:
    0 0 0 1px #e5e7eb,
    0 12px 30px rgba(15,23,42,0.12);
  position: relative;
}

/* Actual editable area inside the sheet, with margins */
#quill-editor .ql-editor {
  min-height: var(--page-height);
  padding: var(--page-margin);
  box-sizing: border-box;
  /* Visual page breaks every page height */
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--page-height) - 1px),
      rgba(148,163,184,0.7) calc(var(--page-height) - 1px),
      rgba(148,163,184,0.7) var(--page-height)
    );
}


/* Comfortable default spacing/heading sizes */
#quill-editor .ql-editor > *{ margin: 0 0 10pt; }
#quill-editor .ql-editor h1{ font-size: 20pt; margin: 0 0 12pt; }
#quill-editor .ql-editor h2{ font-size: 16pt; margin: 16pt 0 8pt; }
#quill-editor .ql-editor h3{ font-size: 13pt; margin: 14pt 0 6pt; }

/* Keep the toolbar crisp and separate */
#quill-toolbar.ql-toolbar.ql-snow{
  border-radius: 10px;
  border:1px solid var(--line);
  background:#fff;
  box-shadow: var(--shadow);
}

/* Quill container default border off (we control it above) */
.ql-container.ql-snow{ border:0 }

/* Parameter "chip" style inside the editor */
.param-chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:2px 8px; border-radius:999px; background:linear-gradient(90deg, rgba(36,107,253,.12), rgba(255,122,47,.12));
  border:1px solid rgba(36,107,253,.25);
  font-weight:700;
  user-select:none;
}
.param-chip::after{
  content:"×";
  display:inline-block; width:14px; height:14px; line-height:14px; text-align:center;
  border-radius:50%; margin-left:2px; font-weight:900; cursor:pointer;
}

/* Modal */
.modal{position:fixed; inset:0; background:rgba(0,0,0,.35); display:flex; align-items:center; justify-content:center}
.modal.hidden{display:none}
.modal-card{
  width:min(520px, 92%); background:#fff; border:1px solid var(--line); border-radius:16px; box-shadow: var(--shadow);
  padding:18px 18px 14px; position:relative;
}
.modal-actions{display:flex; gap:10px; justify-content:flex-end; margin-top:12px}
.modal-close{position:absolute; top:8px; right:10px; background:transparent; border:0; font-size:20px; cursor:pointer}

/* Template list grid */
.list-templates .template-row{
  grid-template-columns: 2fr 2fr 1.2fr 1.4fr;
  align-items: center;
}
.t-actions{display:flex; gap:8px; justify-content:flex-end}
.btn-ghost{
  padding:8px 12px; border-radius:10px; border:1px solid var(--line); background:#fff;
  font-weight:700; text-decoration:none; color:var(--text);
}
.btn-danger{
  padding:8px 12px; border-radius:10px; border:1px solid #ffe0e0;
  background:#fff5f5; color:#b3202a; font-weight:700; cursor:pointer;
}
.btn-secondary.btn-send{
  background:linear-gradient(90deg, rgba(36,107,253,.10), rgba(255,122,47,.10));
  border:1px solid var(--line);
  padding:8px 12px; border-radius:10px; font-weight:700; cursor:pointer;
}

/* Signature block preview inside editor */
.sigblock{
  display:grid; gap:12px; margin:12px 0; padding:12px;
  border:1px dashed rgba(36,107,253,.35); border-radius:12px; background:#fff;
}
.siggrid{display:grid; gap:12px}
.sigcell{
  border:1px solid var(--line); border-radius:10px; padding:10px; background:#fff
}
.sigtitle{font-weight:700; margin-bottom:6px}
.sigmeta{font-size:.9rem; color:var(--muted)}
.sig-list .sig-item{margin-bottom:8px}

/* Pretty chips for personalization parameters */
.chips{display:flex; flex-wrap:wrap; gap:8px}
.chip{
  display:inline-block; padding:6px 10px; border-radius:999px;
  background:linear-gradient(90deg, rgba(36,107,253,.10), rgba(255,122,47,.10));
  border:1px solid var(--line);
  font-weight:700; font-size:.9rem;
}

/* Signature block cards inside editor */
.sigblock{
  display:block;
  margin:16px 0;
  padding:12px;
  border:1px dashed rgba(36,107,253,.35);
  border-radius:12px;
  background:#fff;
}
.sighead{
  display:flex; align-items:center; justify-content:space-between; margin-bottom:10px;
}
.sigtitle{ font-weight:800; letter-spacing:.2px }
.sigactions{ display:flex; gap:8px }
.sigbtn{
  padding:6px 10px; border-radius:8px; border:1px solid var(--line);
  background:#fff; font-weight:700; cursor:pointer;
}
.sigbtn.danger{ border-color:#ffe0e0; background:#fff5f5; color:#b3202a }
.siggrid{ display:grid; gap:12px }
.sigcell{
  border:1px solid var(--line);
  border-radius:10px;
  padding:12px; background:#fff
}
.sigperson{ font-weight:700; margin-bottom:6px }
.sigmeta{ color:var(--muted); font-size:.95rem; margin-bottom:6px }
.sigrow{ display:flex; align-items:center; gap:8px; margin:6px 0 }
.sigrow .label{ font-weight:700; font-size:.95rem }
.mini-chip{
  display:inline-block; padding:4px 8px; border-radius:999px;
  background:linear-gradient(90deg, rgba(36,107,253,.10), rgba(255,122,47,.10));
  border:1px solid var(--line); font-weight:700; font-size:.85rem;
}

/* ---------- Print: Letter w/ 1" margins ---------- */
@media print{
  body{ background:#fff; }
  #quill-toolbar{ display:none !important; }
  #quill-editor.ql-container.ql-snow{
    box-shadow:none; border:0; width:auto; min-height:auto; margin:0;
  }
  #quill-editor .ql-editor{ padding:var(--page-margin) !important; }

  @page{
    size: var(--page-width) var(--page-height);
    margin: var(--page-margin);
  }
}



/* Make template rows uniform height and nicely aligned */
.list-templates .row.template-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;          /* fixed-ish height for all rows */
}

/* Column widths (adjust to taste) */
.list-templates .t-name {
  flex: 0 0 28%;
}

.list-templates .t-ph {
  flex: 1 1 45%;
}

.list-templates .t-upd {
  flex: 0 0 18%;
  white-space: nowrap;
}

.list-templates .t-actions {
  flex: 0 0 18%;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* Parameters cell: compact + scrollable when too many chips */
.list-templates .t-ph {
  max-height: 40px;          /* controls row height together with min-height above */
  overflow-y: auto;
  padding-right: 4px;        /* small space for scrollbar */
}

/* Chips layout: tight rows */
.list-templates .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* More compact chip styling */
.list-templates .chip-small {
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 6px;
  border-radius: 999px;
}

/* Optional: hover hint for lots of params */
.list-templates .t-ph::-webkit-scrollbar {
  width: 4px;
}

.list-templates .t-ph::-webkit-scrollbar-thumb {
  border-radius: 4px;
}

/* Layout shell */
.templates-shell {
  padding: 0;
}

.templates-layout {
  display: flex;
  height: calc(100vh - 80px); /* adjust 80px to your top nav height if needed */
  background: #e5e5e5;
}

/* Sidebar (left) */
.templates-sidebar {
  position: relative;
  width: 280px;
  min-width: 220px;
  max-width: 480px;
  border-right: 1px solid #ccc;
  background: #fafafa;
  display: flex;
  flex-direction: column;
}

.templates-sidebar-top {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
}

.templates-sidebar-title span {
  font-weight: 600;
  font-size: 14px;
}

.templates-sidebar-toggle .link-small {
  font-size: 12px;
}

.templates-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Sidebar rows: stacked (title, date, buttons) */
.templates-sidebar .template-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  background: #f3f4f6;             /* light grey for non-selected */
  transition: background .12s ease, box-shadow .12s ease, transform .05s ease;
}

.templates-sidebar .template-row:hover {
  background: #e5edff;
  transform: translateY(-1px);
}

/* Selected = active template: full white card */
.templates-sidebar .template-row.selected {
  background: #ffffff;
  box-shadow: 0 0 0 1px #c7d2ff, 0 4px 14px rgba(15, 23, 42, 0.08);
}

/* Title row */
.t-name-line {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Date/time row */
.t-upd-mini {
  font-size: 11px;
  color: #6b7280;
}

/* Buttons row */
.t-actions-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.btn-xxs {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
}


/* Sidebar chips */
.templates-sidebar .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.templates-sidebar .chips-scroll {
  max-height: 30px;
  overflow-y: auto;
}

.templates-sidebar .chip-small {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
}

/* Resizer handle */
.templates-resizer {
  width: 4px;
  cursor: col-resize;
  background: #ddd;
}

/* Right side (main) */
.templates-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Ribbon / toolbar area */
.templates-ribbon {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f3f3f3;
  border-bottom: 1px solid #ccc;
}

.templates-ribbon {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.templates-ribbon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.templates-ribbon-row.secondary {
  border-top: 1px solid #e5e7eb;
  padding-top: 4px;
}

.ribbon-left,
.ribbon-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ribbon-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #fff;
  cursor: pointer;
}

.ribbon-btn.primary {
  background: #1d72f3;
  color: #fff;
  border-color: #1d72f3;
}

.ribbon-btn.small {
  font-size: 11px;
  padding: 3px 8px;
}

/* Editor frame */
.templates-editor-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Center the "sheet" and give a grey background like Word */
.templates-editor-frame {
  overflow: auto;
  padding: 16px 0;
  background: #f3f4f6;
}


/* Template name input (sticky above toolbar) */
.editor-top-bar {
  padding: 10px 20px 4px;
  background: #f3f3f3;
}

.editor-title-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #ccc;
  font-size: 16px;
  font-weight: 600;
  background: transparent;
  outline: none;
}

/* Quill toolbar styled like ribbon */
.editor-toolbar {
  position: sticky;
  top: 38px; /* height of editor-top-bar */
  z-index: 9;
  background: #f3f3f3;
  border-radius: 0;
}

/* Sheet area */
.editor-sheet-wrap {
  flex: 1;
  overflow: auto;
  padding: 20px 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* The white "page" */
.ql-editor-wrap {
  background: #fff;
  width: 800px;
  min-height: 1000px;
  padding: 40px 60px;
  box-shadow: 0 0 0 1px #ddd, 0 8px 20px rgba(0,0,0,0.12);
}

/* Archived message */
.archived-empty {
  padding: 24px;
}

.ribbon-btn.ai-new {
  position: relative;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-right: 46px; /* room for the corner tag */
}

/* Orange diagonal NEW tag */
.ribbon-btn.ai-new::after {
  content: "NEW";
  position: absolute;
  top: -8px;
  right: -18px;
  transform: rotate(40deg);
  background: linear-gradient(135deg, #FF7A2F, #FFB26A);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0,0,0,.20);
  pointer-events: none;
}

.param-list-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin-top: 8px;
}

.param-key {
  font-family: monospace;
  font-size: 12px;
  background: #f3f5fa;
  border-radius: 6px;
  padding: 4px 8px;
}

.ai-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 380px;        /* fixed chat height */
  overflow-y: auto;
  padding-right: 4px;
}

.ai-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-input {
  flex: 1;
  min-height: 60px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid #d7dbe4;
  border-radius: 10px;
  resize: vertical;
}

.ai-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.ribbon-label{
  display:flex;
  align-items:center;
  gap:6px;
}

.ribbon-label select{
  font-size:11px;
  padding:3px 6px;
  border-radius:6px;
  border:1px solid #bbb;
  background:#fff;
}

/* AI snippet context menu */
.ai-snippet-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  padding: 4px;
}
.ai-snippet-hidden {
  display: none;
}
.ai-snippet-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.ai-snippet-menu button:hover {
  background: #eef2ff;
}

/* AI snippet side panel */
.ai-snippet-panel {
  position: fixed;
  top: 72px; /* match your top bar height */
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100%;
  background: #ffffff;
  border-left: 1px solid #d1d5db;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.18);
  z-index: 1100;
  display: flex;
  flex-direction: column;
}

.ai-snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.ai-snippet-title {
  font-size: 14px;
  font-weight: 700;
}

.ai-snippet-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.ai-snippet-label {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.ai-snippet-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
  background: #f9fafb;
}

.ai-snippet-chat {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 8px 10px;
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
}

.ai-snippet-msg {
  margin-bottom: 6px;
  display: flex;
}

.ai-snippet-msg-user {
  justify-content: flex-end;
}

.ai-snippet-msg-assistant {
  justify-content: flex-start;
}

.ai-snippet-bubble {
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.ai-snippet-msg-user .ai-snippet-bubble {
  background: #e5edff;
}

.ai-snippet-msg-assistant .ai-snippet-bubble {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.ai-snippet-footer {
  padding: 10px 14px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-snippet-input {
  width: 100%;
  min-height: 70px;
  max-height: 140px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
}

.ai-snippet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- AI selection editor ---------- */

/* Right-click context menu */
.ai-ctx-menu {
  position: fixed;
  z-index: 1500;
  min-width: 160px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.18);
}

.ai-ctx-item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  text-align: left;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.ai-ctx-item:hover {
  background: #eff6ff;
}

/* Modal layout */
.ai-edit-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-edit-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.ai-edit-label {
  font-weight: 600;
}

.ai-edit-selected,
.ai-edit-input {
  width: 100%;
  min-height: 60px;
  max-height: 140px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  resize: vertical;
}

.ai-edit-selected {
  background: #f9fafb;
}

.ai-edit-conversation {
  flex: 1;
  min-height: 80px;
  max-height: 220px;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  overflow-y: auto;
}

.ai-edit-msg {
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.ai-edit-msg.ai-user {
  text-align: right;
}

.ai-edit-msg.ai-user span {
  display: inline-block;
  background: #ffffff;
  border-radius: 12px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
}

.ai-edit-msg.ai-assistant span {
  display: inline-block;
  background: #eef2ff;
  border-radius: 12px;
  padding: 6px 10px;
  border: 1px solid #c7d2fe;
}

.ai-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ai-snippet-hidden {
  display: none !important;
}
