.sms-dialog.picker[open] {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 82dvh;
  overflow: hidden;
}

.text-action {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.template-search {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 236px)) auto;
  justify-content: start;
  gap: 8px;
  margin: 0 0 16px;
}

#edit-vars {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
}

#edit-vars:hover {
  filter: brightness(1.1);
}

.template-search input,
.template-search .dialog-primary {
  width: 100%;
}

.sms-dialog :is(.template-search, .phone-search) .dialog-primary {
  min-width: 88px;
}

.table-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.table-scroll table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.template-table {
  min-width: 780px;
}

.template-table col:nth-child(1) { width: 112px; }
.template-table col:nth-child(2) { width: 164px; }
.template-table col:nth-child(4) { width: 206px; }
.template-table col:nth-child(5) { width: 76px; }

.table-scroll th,
.table-scroll td {
  padding: 6px 16px;
  border-bottom: 1px solid #ebeef5;
  text-align: left;
  font-size: inherit;
  line-height: var(--dialog-line);
  overflow-wrap: anywhere;
}

.table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: var(--dialog-heading-row);
  background: #f3f8ff;
  color: #606266;
  font-weight: 600;
}

.table-scroll td {
  height: var(--dialog-row);
  color: #606266;
}

.table-scroll td:first-child,
.template-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
}

.table-scroll .no-results {
  height: calc(var(--dialog-row) * 1.5);
  color: #606266;
  text-align: center;
}

.template-variable {
  color: var(--orange);
  font-weight: 700;
}

.text-action {
  color: var(--blue);
  font-size: inherit;
  line-height: inherit;
  white-space: nowrap;
}

.text-action:hover {
  text-decoration: underline;
}

.template-pages,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.template-pages {
  flex-wrap: wrap;
  margin-top: 16px;
  color: #606266;
  font-size: inherit;
}

.template-pages button {
  min-width: var(--dialog-control);
  height: var(--dialog-control);
  padding: 0 8px;
  border: 0;
  background: #f4f4f5;
  color: #606266;
  font-size: inherit;
  cursor: pointer;
}

.template-pages button:not(:disabled):hover {
  color: var(--blue);
}

.template-pages button[aria-current="page"],
.template-pages button[aria-current="page"]:not(:disabled):hover {
  background: var(--blue);
  color: #fff;
}

.template-pages button:disabled {
  color: #c0c4cc;
  cursor: default;
}

.variable-fields {
  margin: 0 0 24px;
  display: grid;
  gap: 12px;
}

.variable-row {
  display: grid;
  grid-template-columns: 148px max-content minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.variable-row input {
  width: 100%;
}

.variable-row input:disabled {
  background: var(--field);
  color: #c0c4cc;
}

.variables .modal-actions .dialog-primary {
  min-width: 104px;
}

#template-status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 8px;
  padding-bottom: 5px;
  font-size: var(--text-note);
  line-height: 24px;
}

#template-status span {
  color: var(--orange);
}

#edit-vars {
  width: 80px;
  height: var(--control-compact);
  margin: 0 8px 0 0;
  padding: 0;
  font-size: var(--text-body);
}

#open-templates {
  cursor: pointer;
}

#body-text:disabled,
.sign-fields :is(input, select):disabled,
.sign-fields label:last-child:has(select:disabled)::after {
  color: #c0c4cc;
}

@media (max-width: 1100px), (max-height: 960px) {
  .template-search {
    margin-bottom: 12px;
  }

  .template-table col:nth-child(1) { width: 100px; }
  .template-table col:nth-child(2) { width: 152px; }
  .template-table col:nth-child(4) { width: 184px; }
  .template-table col:nth-child(5) { width: 68px; }

  .template-pages {
    margin-top: 10px;
  }
}

@media (max-width: 560px) {
  .variable-row {
    grid-template-columns: 104px max-content minmax(0, 1fr);
    gap: 8px;
  }

  .variable-row input {
    padding-inline: 10px;
  }

  .sms-dialog.picker[open] {
    height: calc(100dvh - var(--dialog-gutter));
  }

  .template-search {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-table col:nth-child(1) { width: 100px; }
  .template-table col:nth-child(2) { width: 132px; }
  .template-table col:nth-child(4) { width: 192px; }

  .table-scroll th,
  .table-scroll td {
    padding-inline: 8px;
    padding-block: 4px;
  }

  .template-table tr > :nth-child(5) {
    position: sticky;
    right: 0;
    box-shadow: -1px 0 #ebeef5;
    text-align: center;
  }

  .template-table td:nth-child(5) {
    background: #fff;
  }

  .template-table th:nth-child(5) {
    z-index: 2;
  }

  .template-table .text-action {
    min-width: var(--dialog-control);
    min-height: var(--dialog-control);
  }

  .compose-footer:has(#edit-vars:not([hidden])) {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 480px) {
  .sms-dialog.picker[open] {
    grid-template-rows: auto auto minmax(108px, 1fr) auto;
    height: calc(100dvh - var(--dialog-gutter));
    overflow-y: auto;
  }
}
