.cm-llm-templates{
  display:grid;
  gap:12px;
  width:100%;
  min-width:0;
  max-width:1150px;
  margin:0 auto;
}
.cm-llm-templates__bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:18px;
  border:1px solid var(--cm-border);
  border-radius:16px;
  background:#fff;
  box-shadow:var(--cm-shadow-soft);
}
.cm-llm-templates__title{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
  color:var(--cm-title);
  font-size:14px;
  font-weight:800;
  text-transform:uppercase;
}
.cm-llm-templates__actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  min-width:0;
}
.cm-llm-templates .sel,
.cm-llm-templates .inp,
.cm-llm-templates .btn{
  min-height:32px;
  padding:8px 12px;
  border:1px solid var(--cm-border);
  border-radius:6px;
  background:#fff;
  font:600 14px/1.3 inherit;
}
.cm-llm-templates #tpl-q{
  padding-left:30px;
  background-image:url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_11001_43182)'%3E%3Ccircle cx='5.5' cy='5.5' r='4.5' stroke='%23BDBDBD' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M9 9L11 11' stroke='%23BDBDBD' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_11001_43182'%3E%3Crect width='12' height='12' fill='white'/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:12px center;
  background-size:12px 12px;
}
.cm-llm-templates .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  cursor:pointer;
  font-weight:800;
}
.cm-llm-templates .btn.primary{
  background:linear-gradient(180deg, var(--cm-brand) 0%, var(--cm-brand-strong) 100%);
  border-color:var(--cm-brand-strong);
}
.cm-llm-templates__grid{
  display:grid;
  grid-template-columns:minmax(0, 898px) 240px;
  gap:12px;
  align-items:start;
  width:100%;
  min-width:0;
}
.cm-llm-templates .card{
  padding:18px;
  border:1px solid var(--cm-border);
  border-radius:16px;
  background:#fff;
  box-shadow:var(--cm-shadow-soft);
  min-width:0;
}
.cm-llm-templates__grid > aside.card{
  width:240px;
  min-width:240px;
  height:664px;
  min-height:664px;
  overflow:hidden;
}
.cm-llm-templates__grid > aside.card .title{
  margin-bottom:14px;
}
.cm-llm-templates__grid > aside.card .item{
  padding:10px 12px;
  border-radius:6px;
}
.cm-llm-templates__grid > aside.card .meta{
  font-size:12px;
  line-height:1.2;
}
.cm-llm-templates .title{
  margin:0 0 12px;
  color:var(--cm-title);
  font-size:14px;
  font-weight:800;
  text-transform:uppercase;
}
.cm-llm-templates .item{
  padding:10px 12px;
  border:1px solid var(--cm-border);
  border-radius:10px;
  background:#fbfdf7;
}
.cm-llm-templates .item + .item{
  margin-top:10px;
}
.cm-llm-templates .meta{
  color:var(--cm-text);
  font-size:13px;
}
.cm-llm-templates__table-wrap{
  width:100%;
  min-width:0;
  overflow-x:auto;
  overflow-y:hidden;
}
.cm-llm-templates .table{
  width:100%;
  min-width:720px;
  border-collapse:collapse;
}
.cm-llm-templates .table th,
.cm-llm-templates .table td{
  padding:12px 10px;
  border-bottom:1px solid rgba(214, 230, 185, 0.7);
  text-align:left;
  vertical-align:middle;
}
.cm-llm-templates .table th{
  background:#fbfdf7;
  color:#a0b45f;
  font-size:13px;
  font-weight:800;
}
.cm-llm-templates .table tr.tpl-row{
  cursor:pointer;
}
.cm-llm-templates .table tr.tpl-row:hover td{
  background:#fbfdf7;
}
.cm-llm-templates .pager{
  display:flex;
  gap:8px;
  margin-top:12px;
  flex-wrap:wrap;
}
.cm-llm-templates .btn--page{
  min-height:30px;
  padding:0 10px;
  border:1px solid var(--cm-border);
  border-radius:999px;
  background:#fff;
}
.cm-llm-templates .btn--page.is-active{
  background:linear-gradient(180deg, var(--cm-brand) 0%, var(--cm-brand-strong) 100%);
  border-color:var(--cm-brand-strong);
}
#tpl-modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:60;
}
#tpl-modal.is-open{
  display:block;
}
#tpl-modal .backdrop{
  position:absolute;
  inset:0;
  background:rgba(90, 105, 45, 0.24);
}
#tpl-modal .dialog{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  width:min(860px, 96vw);
  max-height:90vh;
  overflow:auto;
  background:#fff;
  border:1px solid var(--cm-border);
  border-radius:18px;
  box-shadow:0 24px 70px rgba(104, 121, 57, 0.2);
}
#tpl-modal header,
#tpl-modal footer{
  position:sticky;
  background:#fff;
  z-index:2;
}
#tpl-modal header{
  top:0;
  border-bottom:1px solid var(--cm-border);
}
#tpl-modal footer{
  bottom:0;
  border-top:1px solid var(--cm-border);
}
#tpl-modal .head,
#tpl-modal .foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:14px 16px;
}
#tpl-modal .body{
  padding:16px;
  display:grid;
  gap:14px;
}
#tpl-modal .grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
}
#tpl-modal .field{
  display:grid;
  gap:6px;
}
#tpl-modal .field label{
  color:var(--cm-text-soft);
  font-size:12px;
  font-weight:700;
}
#tpl-modal input[type="text"],
#tpl-modal textarea,
#tpl-modal select{
  width:100%;
  min-height:32px;
  padding:8px 12px;
  border:1px solid var(--cm-border);
  border-radius:6px;
  background:#fff;
  font:600 14px/1.3 inherit;
}
#tpl-modal textarea{
  min-height:240px;
}
#tpl-modal .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:32px;
  padding:0 14px;
  border:1px solid var(--cm-border);
  border-radius:6px;
  background:#fff;
  cursor:pointer;
  font-weight:800;
}
#tpl-modal .btn.primary{
  background:linear-gradient(180deg, var(--cm-brand) 0%, var(--cm-brand-strong) 100%);
  border-color:var(--cm-brand-strong);
}
#tpl-modal .hint{
  color:var(--cm-text-soft);
  font-size:12px;
}
#tpl-modal .xbtn{
  min-height:34px;
  padding:0 10px;
  border:1px solid var(--cm-border);
  border-radius:8px;
  background:#fff;
  cursor:pointer;
}

@media (max-width: 980px){
  .cm-llm-templates__grid{
    grid-template-columns:1fr;
  }

  .cm-llm-templates__grid > aside.card{
    width:auto;
    min-width:0;
    height:auto;
    min-height:0;
    overflow:visible;
  }

  #tpl-modal .grid{
    grid-template-columns:1fr;
  }
}

@media (max-width: 760px){
  .cm-llm-templates{
    width:100%;
    min-width:0;
  }

  .cm-llm-templates__bar{
    padding:14px;
    flex-direction:column;
    align-items:stretch;
  }

  .cm-llm-templates__title{
    width:100%;
    justify-content:flex-start;
  }

  .cm-llm-templates__actions{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:10px;
    width:100%;
  }

  .cm-llm-templates__actions > *{
    min-width:0;
  }

  #tpl-refresh{
    order:1;
    width:100%;
  }

  #btn-new-tpl{
    order:2;
    width:100%;
  }

  #tpl-q{
    order:3;
    grid-column:1 / -1;
    width:100%;
  }

  #tpl-type-filter{
    order:4;
    grid-column:1 / -1;
    width:100%;
  }

  .cm-llm-templates .card{
    padding:14px;
  }

  .cm-llm-templates .title{
    margin-bottom:12px;
  }

  .cm-llm-templates__placeholders .title{
    color:#b9b7a3;
  }

  .cm-llm-templates__placeholders .item{
    padding:8px 10px;
    border-radius:6px;
    background:#fff;
  }

  .cm-llm-templates__placeholders .meta{
    font-size:11px;
    line-height:1.25;
  }

  #tpl-modal .dialog{
    width:min(540px, calc(100vw - 24px));
    max-height:min(88vh, 900px);
  }

  #tpl-modal .head,
  #tpl-modal .body,
  #tpl-modal .foot{
    padding-left:14px;
    padding-right:14px;
  }

  #tpl-modal .foot{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  #tpl-modal .foot .btn{
    width:100%;
    min-width:0;
  }
}

@media (max-width: 430px){
  .cm-llm-templates__actions{
    grid-template-columns:1fr 1fr;
    gap:12px;
  }

  .cm-llm-templates .table{
    min-width:560px;
  }

  .cm-llm-templates__placeholders .item{
    min-height:30px;
  }
}

@media (max-width: 350px){
  .cm-llm-templates__actions{
    grid-template-columns:1fr;
  }

  #tpl-refresh,
  #btn-new-tpl,
  #tpl-q,
  #tpl-type-filter{
    grid-column:auto;
    width:100%;
  }

  #tpl-modal .foot{
    grid-template-columns:1fr;
  }
}
