@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('./fonts/dm-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('./fonts/dm-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #111827;
  --surface: #1f2937;
  --hover: #253044;
  --border: #374151;
  --border-strong: #4b5563;
  --text: #f9fafb;
  --muted: #9ca3af;
  --brand: #6366f1;
  --brand-btn: #4f46e5;
  --brand-btn-hover: #4338ca;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg); color: #d1d5db;
  font: 14px/1.5 "DM Sans", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
.tool-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.docs-link { flex: none; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; text-decoration: none; }
.brand svg, .brand img { width: 28px; height: 28px; flex: none; display: block; }
.brand .bname { color: #fff; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand .tname { color: var(--muted); font-weight: 500; font-size: 15px; white-space: nowrap; }
.brand .tname::before { content: "/"; margin: 0 8px 0 2px; opacity: .5; }
.tool-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tool-header-actions .ver { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
button, .btn-ghost, .btn {
  font: inherit; font-weight: 600; border-radius: 8px; cursor: pointer; gap: 7px; white-space: nowrap;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn { padding: 8px 16px; background: var(--brand-btn); color: #fff; }
.btn:hover { background: var(--brand-btn-hover); }
.btn-ghost { padding: 8px 16px; background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
button:disabled, .btn:disabled { opacity: .5; cursor: default; }

.tool-body {
  flex: 1 1 auto; display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}
.tool-left {
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px 16px 16px 24px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.tool-right {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 24px; overflow-y: auto;
}

.tool-dropzone {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  border-radius: 14px; border: 2px dashed var(--border-strong);
  background: var(--surface); min-height: 220px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.tool-dropzone:hover, .tool-dropzone.over { border-color: var(--brand); background: rgba(99, 102, 241, 0.06); }
.tool-dropzone-inner { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; }
.tool-dropzone-inner .ph { width: 40px; height: 40px; color: var(--muted); margin-bottom: 12px; }
.tool-dropzone:hover .ph, .tool-dropzone.over .ph { color: var(--brand); }
.tool-dropzone-inner strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.tool-dropzone-inner span { color: var(--muted); font-size: 13px; }

.tool-file-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 8px;
}
.tool-file-row {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: start; gap: 10px; padding: 10px 12px;
  border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border);
}
.tool-file-row:hover { background: var(--hover); }
.tool-file-num {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(99, 102, 241, 0.15); font-size: 11px; font-weight: 600; color: var(--text);
}
.tool-file-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tool-file-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tool-file-sub { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.tool-file-sub .dot { opacity: .5; }
.lock-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 600; }
.lock-badge .ph { width: 13px; height: 13px; }
.lock-badge.unlocked { color: var(--good); cursor: pointer; }
.tool-file-status { margin-top: 2px; font-size: 11px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-file-status .ok, .tool-file-status .err, .tool-file-status .warn, .tool-file-status .busy {
  display: inline-flex; align-items: center; gap: 4px;
}
.tool-file-status .ok { color: var(--good); }
.tool-file-status .err { color: var(--bad); }
.tool-file-status .warn { color: var(--warn); }
.tool-file-status .busy { color: var(--muted); }
.tool-file-pw { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tool-file-pw input[type=password] { width: 200px; padding: 6px 10px; font-size: 13px; }
.tool-file-pw .btn-ghost { padding: 6px 12px; font-size: 12.5px; }
.pw-err { color: var(--bad); font-size: 12px; }
.tool-file-actions { display: flex; align-items: center; gap: 6px; align-self: start; }
.tool-file-actions .btn-ghost, .tool-file-actions .btn { padding: 5px 12px; font-size: 12.5px; }
.icon-x {
  background: none; border: none; color: var(--muted);
  padding: 4px; line-height: 1;
}
.icon-x .ph { width: 16px; height: 16px; }
.icon-x:hover { color: var(--bad); }
.addstrip {
  flex: none; margin-top: 10px; text-align: center;
  border: 1.5px dashed var(--border); border-radius: 10px;
  padding: 9px; color: var(--muted); font-size: 12.5px; cursor: pointer;
  transition: border-color .12s, color .12s;
}
.addstrip:hover, .addstrip.over { border-color: var(--brand); color: var(--text); }
.addstrip .ph { width: 15px; height: 15px; margin-right: 6px; vertical-align: -3px; }

.tool-field-group { display: flex; flex-direction: column; gap: 6px; }
.tool-field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.tool-field-help { font-size: 11.5px; color: var(--muted); margin: 0; }
.tool-field-divider { border: none; border-top: 1px solid var(--border); margin: 2px 0; }
select, input[type=number], input[type=text], input[type=password] {
  font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  width: 100%; outline: none;
}
select:focus, input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 36px; height: 20px; border-radius: 10px; flex: none; position: relative;
  background: var(--border); transition: background .15s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35); }
.switch input:disabled + .track { opacity: .4; }
.switch span { font-size: 13.5px; color: var(--text); }
.switch.off span { color: var(--muted); }

.opt-head { display: flex; justify-content: space-between; align-items: center; }
.opt-head .tool-field-label { display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
.opt-head .tool-field-label .ph { width: 14px; height: 14px; }
.opt-head button { padding: 4px 11px; font-size: 12px; }
#options .optgroup { border-bottom: 1px solid var(--border); }
#options .optgroup:last-child { border-bottom: none; }
#options .optgroup > summary {
  cursor: pointer; padding: 10px 2px; font-weight: 600; font-size: 12.5px;
  list-style: none; display: flex; align-items: center; gap: 7px; color: var(--text);
}
#options .optgroup > summary::-webkit-details-marker { display: none; }
#options .optgroup > summary::before {
  content: ''; width: 5px; height: 5px; flex: none;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s; margin-left: 3px;
}
#options .optgroup[open] > summary::before { transform: rotate(45deg); }
#options .optbody { padding: 2px 2px 12px 15px; display: flex; flex-direction: column; gap: 10px; }
#options .optrow { display: flex; flex-direction: column; gap: 5px; }
#options .optrow.check { flex-direction: row; align-items: center; gap: 9px; flex-wrap: wrap; }
#options .optrow.check label { font-size: 13.5px; color: var(--text); font-weight: 400; }
#options .optrow label { font-size: 12px; color: var(--muted); font-weight: 500; }
#options input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); margin: 0; }
#options .rangeline { display: flex; align-items: center; gap: 11px; }
#options .rangeline input[type=range] { flex: 1; accent-color: var(--brand); }
#options .rangeval { font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 26px; color: var(--muted); }
#options .opthelp { margin: 0; font-size: 11.5px; color: var(--muted); flex-basis: 100%; padding-left: 24px; }
#options .optrow:not(.check) .opthelp { padding-left: 0; }

.tool-apply { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.tool-apply .btn { width: 100%; padding: 11px 16px; font-size: 15px; }
#status { font-size: 12.5px; color: var(--muted); min-height: 18px; text-align: center; }
#status.err { color: var(--bad); }

.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge.ok { color: var(--good); background: rgba(52, 211, 153, 0.14); }
.badge.err { color: var(--bad); background: rgba(248, 113, 113, 0.14); }
.badge.warn { color: var(--warn); background: rgba(251, 191, 36, 0.14); }
.link-btn {
  background: none; border: none; color: var(--brand); font-size: 12px; font-weight: 600;
  padding: 0; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
.saved { color: var(--good); font-weight: 600; }
.saved.none { color: var(--muted); font-weight: 400; }
.err { color: var(--bad); }
#resultPanel { flex: none; margin-top: 12px; max-height: 40%; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }

.ph { width: 16px; height: 16px; fill: currentColor; flex: none; display: inline-block; vertical-align: -3px; }
.ic { display: inline-flex; align-items: center; }
.hidden { display: none !important; }

@media (max-width: 760px) {
  .tool-body { grid-template-columns: 1fr; overflow-y: auto; display: flex; flex-direction: column; }
  .tool-left { border-right: none; border-bottom: 1px solid var(--border); padding: 14px 16px; overflow: visible; }
  .tool-file-list { overflow: visible; }
  .tool-right { padding: 16px; overflow: visible; }
  .tool-header { padding: 12px 16px; row-gap: 10px; }
  .brand { order: 0; }
  .docs-link { order: 1; margin-left: auto; }
  .tool-header-actions { order: 2; flex: 1 1 100%; margin-left: 0; }
  .tool-header-actions .btn { flex: 1 1 auto; }
  .tool-header-actions .btn-ghost, .tool-header-actions .btn { padding: 8px 12px; font-size: 13px; }
  .tool-header-actions .ver { display: none; }
  .tool-dropzone { min-height: 160px; }
  .tool-apply { margin-top: 4px; }
  #resultPanel { max-height: none; }
  body { height: auto; min-height: 100%; }
}
