.tl-tool {
  --tl-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f7a4d' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4m0 0L7.5 8.5M12 4l4.5 4.5'/%3E%3Cpath d='M4 14.5V18a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3.5'/%3E%3C/svg%3E");
  --tl-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f7a4d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h8l4 4v14H6z'/%3E%3Cpath d='M14 3v4h4M9 12h6M9 15.5h6M12 10.5v8'/%3E%3C/svg%3E");
  --tl-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%231f7a4d' stroke-width='1.7' stroke-linejoin='round'%3E%3Cpath d='M7 5.5v9l7-4.5z'/%3E%3C/svg%3E");
  --tl-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23b42318' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='7.5'/%3E%3Cpath d='M10 6.5v4.5M10 13.6v.1'/%3E%3C/svg%3E");
  --tl-done: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5.5 10.5 3 3 6-6.5'/%3E%3C/svg%3E");
  --tl-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23ffffff' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3v10m0 0-4-4m4 4 4-4M4 16h12'/%3E%3C/svg%3E");
  --tl-download-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2317201b' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3v10m0 0-4-4m4 4 4-4M4 16h12'/%3E%3C/svg%3E");

  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-auto-flow: row dense;
  gap: 16px 20px;
  padding: 24px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e7e4);
  border-radius: var(--r-lg, 12px);
  box-shadow: var(--shadow, 0 1px 2px rgba(23, 32, 27, 0.05));
}

.tl-tool [hidden] {
  display: none !important;
}

.tl-tool > *,
.tl-input > * {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
}

.tl-input {
  display: contents;
}

.tl-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tl-tool button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  font: 600 0.9375rem/1.2 var(--ui, system-ui, sans-serif);
  color: var(--text, #17201b);
  background: var(--surface, #ffffff);
  border: 1px solid var(--line-strong, #c5cec9);
  border-radius: var(--radius, 8px);
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), opacity 150ms var(--ease);
}

.tl-tool button:hover {
  border-color: var(--text-2, #36413b);
}

.tl-tool button:active {
  background: var(--panel, #f5f7f6);
}

.tl-tool button:focus-visible,
.tl-pick:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(31, 122, 77, 0.25));
}

.tl-tool button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tl-tool button:disabled:hover {
  border-color: var(--line-strong, #c5cec9);
}

.tl-tool .tl-run,
.tl-tool .tl-download {
  min-height: 48px;
  padding: 12px 22px;
  font-size: 1rem;
  color: #ffffff;
  background: var(--accent, #1f7a4d);
  border-color: var(--accent, #1f7a4d);
}

.tl-tool .tl-run:hover,
.tl-tool .tl-download:hover {
  background: var(--accent-hover, #196641);
  border-color: var(--accent-hover, #196641);
}

.tl-tool .tl-run:active,
.tl-tool .tl-download:active {
  background: var(--accent-press, #145535);
}

.tl-tool .tl-run:disabled {
  color: var(--muted, #5a6660);
  background: var(--panel-2, #edf1ef);
  border-color: var(--panel-2, #edf1ef);
  opacity: 1;
}

.tl-run {
  justify-self: start;
}

.tl-download::before {
  content: "";
  width: 20px;
  height: 20px;
  background: var(--tl-download) no-repeat center / 20px 20px;
}

.tl-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 184px;
  padding: 28px 24px;
  text-align: center;
  background: var(--accent-tint, #f3f8f5);
  border: 1.5px dashed #8fc2a6;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.tl-drop::before {
  content: "";
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface, #ffffff) var(--tl-upload) no-repeat center / 26px 26px;
  box-shadow: 0 0 0 1px var(--accent-soft, #e8f3ed);
  transition: transform 200ms var(--ease);
}

.tl-drop:hover {
  background: var(--accent-soft, #e8f3ed);
  border-color: var(--accent, #1f7a4d);
}

.tl-drop:focus-visible {
  outline: none;
  border-color: var(--accent, #1f7a4d);
  border-style: solid;
  box-shadow: var(--ring, 0 0 0 3px rgba(31, 122, 77, 0.25));
}

.tl-drop.tl-drop-active {
  background: var(--accent-soft, #e8f3ed);
  border-color: var(--accent, #1f7a4d);
  border-style: solid;
}

.tl-drop.tl-drop-active::before {
  transform: translateY(-4px);
}

.tl-drop-text {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text, #17201b);
}

.tl-pick {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 20px;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent, #1f7a4d);
  border-radius: var(--radius, 8px);
  cursor: pointer;
  transition: background-color 150ms var(--ease);
}

.tl-drop:hover .tl-pick {
  background: var(--accent-hover, #196641);
}

.tl-hint {
  grid-column: 1;
  align-self: center;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--muted, #5a6660);
}

.tl-note {
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text-2, #36413b);
  background: var(--panel, #f5f7f6);
  border-radius: var(--radius, 8px);
}

.tl-tool .tl-sample {
  grid-column: 2;
  justify-self: end;
  align-self: start;
  padding: 8px 12px 8px 8px;
  color: var(--accent, #1f7a4d);
  background: transparent;
  border-color: transparent;
}

.tl-tool .tl-sample::before {
  content: "";
  width: 20px;
  height: 20px;
  background: var(--tl-play) no-repeat center / 20px 20px;
}

.tl-tool .tl-sample:hover {
  background: var(--accent-soft, #e8f3ed);
  border-color: transparent;
}

.tl-files {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
}

.tl-files:empty,
.tl-settings:empty,
.tl-summary:empty,
.tl-preview:empty {
  display: none;
}

.tl-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e2e7e4);
  border-radius: 10px;
}

.tl-card::before {
  content: "";
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 40px;
  height: 40px;
  border-radius: var(--radius, 8px);
  background: var(--accent-soft, #e8f3ed) var(--tl-file) no-repeat center / 22px 22px;
}

.tl-card-index {
  grid-column: 3;
  grid-row: 1 / span 2;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted, #5a6660);
  background: var(--panel, #f5f7f6);
  border-radius: 999px;
  white-space: nowrap;
}

.tl-card-name {
  grid-column: 2;
  grid-row: 1;
  overflow-wrap: anywhere;
  font-weight: 600;
  line-height: 1.3;
}

.tl-card-meta {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.8125rem;
  color: var(--muted, #5a6660);
}

.tl-settings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr));
  gap: 16px 20px;
  align-items: end;
}

.tl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tl-label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-2, #36413b);
}

.tl-textarea {
  width: 100%;
  min-height: 9rem;
}

.tl-number {
  max-width: 12rem;
}

.tl-columns {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0 16px;
  min-width: 0;
  max-height: 240px;
  margin: 0;
  padding: 8px 14px 10px;
  overflow: auto;
  border: 1px solid var(--line, #e2e7e4);
  border-radius: var(--radius, 8px);
}

.tl-columns legend {
  padding: 0 6px;
  margin-left: -6px;
}

.tl-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-size: 0.9375rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.tl-check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.tl-settings > .tl-check {
  align-self: end;
}

.tl-progress {
  position: relative;
  height: 4px;
  overflow: hidden;
  background: var(--accent-soft, #e8f3ed);
  border-radius: 999px;
}

.tl-progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: var(--accent, #1f7a4d);
  border-radius: 999px;
  animation: tl-slide 1.1s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.tl-progress-bar {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

@keyframes tl-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

.tl-error {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: #7a1a12;
  background: var(--danger-soft, #fef1ef);
  border: 1px solid var(--danger-line, #f3c6c0);
  border-radius: var(--radius, 8px);
}

.tl-error::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  background: var(--tl-alert) no-repeat center / 20px 20px;
}

.tl-status {
  font-size: 0.875rem;
  color: var(--muted, #5a6660);
}

.tl-status:empty,
.tl-tool:has(.tl-viewer:not([hidden])) .tl-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tl-tool:has(.tl-viewer:not([hidden])) .tl-sample {
  display: none;
}

@media (min-width: 641px) {
  .tl-tool:has(> .tl-input[hidden]) .tl-sample {
    order: 1;
    align-self: center;
  }

  .tl-tool:has(> .tl-input[hidden]) .tl-run {
    grid-column: 1;
  }
}

.tl-result {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line, #e2e7e4);
}

.tl-result-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.125rem;
}

.tl-result-title::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent, #1f7a4d) var(--tl-done) no-repeat center / 16px 16px;
}

.tl-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.tl-summary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  background: var(--panel, #f5f7f6);
  border-radius: var(--radius, 8px);
}

.tl-summary dt {
  font-size: 0.875rem;
  color: var(--muted, #5a6660);
}

.tl-summary dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tl-preview {
  max-width: 100%;
  max-height: 480px;
  overflow: auto;
  overscroll-behavior-x: contain;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line-strong, #c5cec9);
  border-radius: var(--radius, 8px);
}

.tl-table {
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tl-table caption {
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: var(--muted, #5a6660);
  text-align: left;
  background: var(--panel, #f5f7f6);
  border-bottom: 1px solid var(--line, #e2e7e4);
}

.tl-table th,
.tl-table td {
  max-width: 320px;
  padding: 6px 12px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  border-right: 1px solid var(--line, #e2e7e4);
  border-bottom: 1px solid var(--line, #e2e7e4);
}

.tl-table th:last-child,
.tl-table td:last-child {
  border-right: 0;
}

.tl-table tbody tr:last-child td,
.tl-table tbody tr:last-child th {
  border-bottom: 0;
}

.tl-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2, #36413b);
  background: var(--panel, #f5f7f6);
  border-bottom-color: var(--line-strong, #c5cec9);
}

.tl-table tbody tr:hover td {
  background: var(--accent-tint, #f3f8f5);
}

.tl-table .tl-rownum {
  position: sticky;
  left: 0;
  min-width: 2.75rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted, #5a6660);
  text-align: right;
  background: var(--panel, #f5f7f6);
}

.tl-table thead .tl-rownum {
  z-index: 2;
}

.tl-view-table .tl-table thead th {
  font-weight: 400;
  color: var(--muted, #5a6660);
  text-align: center;
}

.tl-table .tl-rownum,
.tl-view-table .tl-table thead .tl-rownum {
  width: 1%;
  text-align: right;
}

.tl-table tr.tl-hit td,
.tl-table tr.tl-hit:hover td {
  background: var(--hit, #fff1b8);
}

.tl-viewer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tl-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line, #e2e7e4);
  scrollbar-width: thin;
}

.tl-tool .tl-tab {
  flex: none;
  min-height: 40px;
  padding: 8px 16px;
  font-weight: 500;
  color: var(--muted, #5a6660);
  background: transparent;
  border: 0;
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 -2px 0 transparent;
}

.tl-tool .tl-tab:hover {
  color: var(--text, #17201b);
  background: var(--panel, #f5f7f6);
}

.tl-tool .tl-tab[aria-selected="true"] {
  font-weight: 600;
  color: var(--accent, #1f7a4d);
  box-shadow: inset 0 -2px 0 var(--accent, #1f7a4d);
}

.tl-tool .tl-tab:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent, #1f7a4d);
}

.tl-search,
.tl-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.tl-query {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 28rem;
}

.tl-view-info,
.tl-page {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted, #5a6660);
  font-variant-numeric: tabular-nums;
}

.tl-pager {
  justify-content: center;
}

.tl-page {
  padding: 0 8px;
}

.tl-viewer .tl-tool .tl-download,
.tl-tool .tl-viewer .tl-download {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.9375rem;
  color: var(--text, #17201b);
  background: var(--surface, #ffffff);
  border-color: var(--line-strong, #c5cec9);
}

.tl-tool .tl-viewer .tl-download::before {
  background-image: var(--tl-download-dark);
}

.tl-tool .tl-viewer .tl-download:hover {
  border-color: var(--text-2, #36413b);
}

.tl-viewer .tl-actions {
  padding-top: 4px;
}

@media (max-width: 640px) {
  .tl-tool {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .tl-hint,
  .tl-tool .tl-sample {
    grid-column: 1 / -1;
  }

  .tl-tool .tl-sample {
    justify-self: start;
    margin: -6px 0 -4px -4px;
  }

  .tl-drop {
    min-height: 0;
    padding: 20px 16px;
    gap: 10px;
  }

  .tl-drop::before {
    width: 40px;
    height: 40px;
    background-size: 22px 22px;
  }

  .tl-drop-text {
    font-size: 1rem;
  }

  .tl-tool button {
    min-height: 44px;
  }

  .tl-run,
  .tl-actions > button {
    justify-self: stretch;
    flex: 1 1 100%;
  }

  .tl-tool .tl-tab {
    min-height: 44px;
  }

  .tl-pager {
    justify-content: space-between;
  }

  .tl-pager .tl-page {
    flex: 1;
    text-align: center;
  }
}
