.ws {
  --ws-muted: var(--muted, #535770);
  --ws-accent: var(--accent, #593be5);
  --ws-ink: var(--ink, #18182a);
  --ws-line: var(--line, #e7e5f0);
  --ws-surface: var(--surface, #fff);
  --ws-panel: var(--panel, #f6f4fc);
  --ws-accent-ink: #4930bd;
  --ws-accent-bg: #f0ebff;
  --ws-accent-edge: #dbcfff;
  --ws-cta: #593be5;
  --ws-cta-hover: #4629c1;
  --ws-cta-ink: #fff;
  --ws-cta-shadow: #593be53d;
  --ws-field-line: #dcd8e8;
  --ws-checker-base: #f7f5fb;
  --ws-checker-grid: #ede9f4;
  --ws-success: #145847;
  --ws-success-bg: #e7f5ed;
  --ws-danger: #8b292b;
  --ws-danger-bg: #ffeded;
  --ws-warn: #76500b;
  --ws-warn-bg: #fff3d9;
  --ws-warn-edge: #f0ddaf;
  --ws-drop-edge: #bdb0f3;
  --ws-drop-dot: #c4b7ef78;
  --ws-drop-glow: #e4daff;
  --ws-drop-base: #faf8ff;
  --ws-shadow: 0 2px 4px #23153c05, 0 11px 30px #3525590b;
  --ws-pop-shadow: 0 10px 28px #28174a3b;
  --ws-toast-bg: #221936;
  --ws-toast-ink: #faf6ff;
  --ws-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23535770' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(340px, 1fr);
  grid-template-areas: 'media sidebar' 'results results' 'private private';
  align-items: start;
  gap: 20px;
  color: var(--ws-ink);
}

:root[data-theme="dark"] .ws {
  --ws-accent-ink: #c3b0ff;
  --ws-accent-bg: #30254a;
  --ws-accent-edge: #574373;
  --ws-cta: #ac94ff;
  --ws-cta-hover: #c0aaff;
  --ws-cta-ink: #1a1234;
  --ws-cta-shadow: #100b1f6e;
  --ws-field-line: #48415e;
  --ws-checker-base: #221e34;
  --ws-checker-grid: #2c2640;
  --ws-success: #a0e8c1;
  --ws-success-bg: #233b35;
  --ws-danger: #ffb2b4;
  --ws-danger-bg: #462b3c;
  --ws-warn: #ffd789;
  --ws-warn-bg: #403324;
  --ws-warn-edge: #625133;
  --ws-drop-edge: #65578a;
  --ws-drop-dot: #8a73b55c;
  --ws-drop-glow: #3a2c60;
  --ws-drop-base: #28223c;
  --ws-shadow: 0 2px 4px #0c091a4f, 0 12px 32px #0c091b2e;
  --ws-pop-shadow: 0 10px 28px #0b081a92;
  --ws-toast-bg: #e8dfff;
  --ws-toast-ink: #211838;
  --ws-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23b0acc7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.ws:has(.ws-results[hidden]) { grid-template-areas: 'media sidebar' 'private private'; }
.ws-media, .ws-sidebar { display: grid; min-width: 0; gap: 20px; }
.ws-media { grid-area: media; }
.ws-sidebar { grid-area: sidebar; }
.ws [hidden] { display: none !important; }
.ws-results { grid-area: results; }

.ws-panel {
  min-width: 0;
  border: 1px solid var(--ws-line);
  background: var(--ws-surface);
  border-radius: 20px;
  box-shadow: var(--ws-shadow);
}

.ws-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ws-panel-head h2 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 750;
  letter-spacing: -.033em;
  line-height: 1.24;
}

.ws-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  transition: background-color .16s, border-color .16s, box-shadow .16s;
}

.ws-primary { background: var(--ws-cta); color: var(--ws-cta-ink); box-shadow: 0 5px 12px var(--ws-cta-shadow); }
.ws-primary:hover { background: var(--ws-cta-hover); }
.ws-secondary { border-color: var(--ws-accent-edge); background: var(--ws-surface); color: var(--ws-accent-ink); }
.ws-secondary:hover { background: var(--ws-accent-bg); border-color: var(--ws-drop-edge); }
.ws-plain { padding-inline: 11px; color: var(--ws-accent-ink); background: transparent; }
.ws-plain:hover { background: var(--ws-accent-bg); }
.ws-btn:disabled, .ws-toggle button:disabled { box-shadow: none; cursor: default; }
.ws-btn:disabled, .ws-btn:disabled:hover { background: var(--ws-panel); border-color: var(--ws-line); color: var(--ws-muted); }
.ws-toggle button:disabled { opacity: .68; }

.ws-upload { padding: 14px; transition: background-color .16s; }
.ws-drop {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  border: 1px dashed var(--ws-drop-edge);
  border-radius: 13px;
  background:
    radial-gradient(ellipse at center, var(--ws-drop-base) 8%, transparent 56%),
    radial-gradient(circle, var(--ws-drop-dot) 1px, transparent 1.4px) 0 0 / 17px 17px,
    radial-gradient(ellipse at 52% 4%, var(--ws-drop-glow), transparent 69%),
    var(--ws-drop-base);
  text-align: center;
}

.ws-upload.is-dragover { background: var(--ws-accent-bg); }
.ws-upload.is-dragover .ws-drop { border-color: var(--ws-accent); background-color: var(--ws-accent-bg); box-shadow: inset 0 0 0 1px var(--ws-accent); }
.ws-drop-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 21px;
  place-items: center;
  border: 1px solid var(--ws-accent-edge);
  border-radius: 18px;
  background: linear-gradient(150deg, var(--ws-surface) 10%, var(--ws-accent-bg));
  color: var(--ws-accent);
  box-shadow: 0 8px 16px var(--ws-cta-shadow), inset 0 1px var(--ws-surface);
}
.ws-drop h2 { font-size: clamp(1.14rem, 2.3vw, 1.62rem); line-height: 1.24; font-weight: 760; letter-spacing: -.048em; }
.ws-drop p { margin-top: 9px; color: var(--ws-muted); font-size: .9rem; }
.ws-drop .ws-btn { margin-top: 22px; min-height: 48px; padding-inline: 20px; }
.ws-tray-head { padding: 2px 5px 11px; }
.ws-tray-head > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.ws-add { margin-top: 12px; min-height: 44px; }

.ws-file-list {
  display: grid;
  gap: 6px;
  max-height: 334px;
  margin: 0;
  padding: 1px;
  overflow: auto;
  list-style: none;
}

.ws-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 38px;
  align-items: center;
  gap: 7px;
  min-height: 62px;
  border: 1px solid var(--ws-line);
  border-radius: 12px;
  background: var(--ws-panel);
}
.ws-file.is-selected { background: var(--ws-accent-bg); border-color: var(--ws-accent-edge); }
.ws-file-main { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 60px; padding: 7px 9px; border: 0; border-radius: 11px; text-align: start; background: transparent; color: inherit; }
.ws-file-main:hover { background: var(--ws-accent-bg); }
.ws-file.is-selected .ws-file-main:hover { background: var(--ws-surface); }
.ws-file-thumb, .ws-file-icon { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--ws-line); border-radius: 8px; }
.ws-file-thumb { object-fit: cover; background: var(--ws-panel); }
.ws-file-icon { display: grid; place-items: center; color: var(--ws-accent-ink); background: var(--ws-surface); }
.ws-file-labels { display: grid; min-width: 0; gap: 1px; }
.ws-name { display: block; max-width: 100%; overflow-wrap: anywhere; }
.ws-file-labels .ws-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .86rem; font-weight: 720; }
.ws-sub { color: var(--ws-muted); font-size: .795rem; line-height: 1.43; }
.ws-file-labels .ws-sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.ws-icon-button { width: 34px; min-height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; color: var(--ws-muted); background: transparent; }
.ws-icon-button:hover:not(:disabled) { color: var(--ws-danger); background: var(--ws-danger-bg); }
.ws-icon-button:disabled { opacity: .45; cursor: default; }

.ws-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 99px;
  color: var(--ws-muted);
  background: var(--ws-surface);
  border: 1px solid var(--ws-line);
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.36;
  text-align: center;
}
.ws-status-success, .ws-check-pass { color: var(--ws-success); background: var(--ws-success-bg); border-color: transparent; }
.ws-status-failed, .ws-check-fail { color: var(--ws-danger); background: var(--ws-danger-bg); border-color: transparent; }
.ws-status-unreachable, .ws-status-cancelled { color: var(--ws-warn); background: var(--ws-warn-bg); border-color: transparent; }
.ws-status-running { color: var(--ws-accent-ink); background: var(--ws-accent-bg); border-color: var(--ws-accent-edge); }

.ws-settings-head { min-height: 73px; padding: 12px 18px; border-bottom: 1px solid var(--ws-line); }
.ws-settings-title { display: flex; align-items: center; gap: 9px; }
.ws-tune { display: grid; width: 35px; height: 35px; place-items: center; color: var(--ws-accent-ink); background: var(--ws-accent-bg); border: 1px solid var(--ws-accent-edge); border-radius: 10px; }
.ws-toggle {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--ws-line);
  border-radius: 11px;
  background: var(--ws-panel);
}
.ws-toggle button {
  display: inline-grid;
  align-items: center;
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ws-muted);
  font-size: .83rem;
  font-weight: 650;
  line-height: 1.18;
}
.ws-toggle button[aria-pressed="true"] { color: var(--ws-accent-ink); background: var(--ws-surface); border-color: var(--ws-line); box-shadow: 0 1px 4px var(--ws-cta-shadow); }
.ws-toggle button:hover:not(:disabled):not([aria-pressed="true"]) { color: var(--ws-accent-ink); background: var(--ws-accent-bg); }
.ws-setting-content { display: grid; gap: 15px; padding: 18px; }
.ws-block, .ws-fields { display: grid; gap: 11px; }
.ws-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ws-field { display: grid; min-width: 0; gap: 5px; }
.ws-field label { min-width: 0; color: var(--ws-ink); font-size: .84rem; font-weight: 675; line-height: 1.35; }
.ws-field label:has(output) { display: flex; justify-content: space-between; gap: 10px; }
.ws-field output { color: var(--ws-accent-ink); }
.ws-field small, .ws-note { color: var(--ws-muted); font-size: .83rem; line-height: 1.45; }
.ws-note { margin: 0; }
.ws-field input:not([type="range"]), .ws-field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--ws-field-line);
  border-radius: 10px;
  background-color: var(--ws-panel);
  color: var(--ws-ink);
  font-size: 1rem;
  line-height: 1.2;
}
.ws-field input:not([type="range"]):focus, .ws-field select:focus { border-color: var(--ws-accent); background-color: var(--ws-surface); }
.ws-field select {
  appearance: none;
  padding-inline-end: 29px;
  background-image: var(--ws-chevron);
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.ws-field input::placeholder { color: var(--ws-muted); opacity: 1; }
.ws-field input[aria-invalid="true"] { border-color: var(--ws-danger); background: var(--ws-danger-bg); }
.ws-field input:disabled, .ws-field select:disabled { color: var(--ws-muted); background-color: var(--ws-panel); }
.ws-field input[type="range"] { width: 100%; min-height: 38px; margin: 0; accent-color: var(--ws-accent); }
.ws-field input[type="color"] { width: 62px; padding: 4px; }
.ws-check { display: flex; align-items: center; gap: 8px; min-height: 36px; color: var(--ws-ink); font-size: .875rem; cursor: pointer; }
.ws-check input { width: 18px; height: 18px; margin: 0; flex: 0 0 18px; accent-color: var(--ws-accent); }
.ws-plan { margin: 0; padding: 9px 11px; border: 1px solid var(--ws-accent-edge); border-radius: 9px; color: var(--ws-accent-ink); background: var(--ws-accent-bg); font-size: .82rem; font-weight: 675; }
.ws-settings-footer { display: flex; justify-content: space-between; gap: 6px; padding: 5px 8px; border-top: 1px solid var(--ws-line); }

.ws-preview { padding: 16px; }
.ws-preview-head { margin-bottom: 14px; }
.ws-preview-head h2 { margin-bottom: 2px; }
.ws-preview-stage {
  display: grid;
  justify-items: center;
  align-items: center;
  min-height: 140px;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--ws-line);
  border-radius: 13px;
  background-color: var(--ws-checker-base);
  background-image: conic-gradient(var(--ws-checker-grid) 25%, transparent 0 50%, var(--ws-checker-grid) 0 75%, transparent 0);
  background-size: 18px 18px;
}
.ws-preview-image { display: block; max-width: 100%; max-height: 380px; width: auto; height: auto; object-fit: contain; border-radius: 3px; }
.ws-compare-stage { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.ws-preview-figure { display: grid; width: 100%; min-width: 0; margin: 0; gap: 6px; align-content: end; justify-items: center; }
.ws-preview-figure .ws-preview-image { align-self: center; }
.ws-preview-figure figcaption { padding: 3px 9px; border: 1px solid var(--ws-line); border-radius: 999px; background: var(--ws-surface); color: var(--ws-muted); font-size: .77rem; font-weight: 650; text-align: center; }
.ws-crop-frame { position: relative; max-width: 100%; overflow: hidden; }
.ws-crop-rect { position: absolute; outline: 2px solid white; outline-offset: -2px; box-shadow: 0 0 0 2000px #16132982; cursor: move; touch-action: none; }
.ws-crop-rect::before, .ws-crop-rect::after { content: ''; position: absolute; pointer-events: none; }
.ws-crop-rect::before { inset: 0 33.33%; border-inline: 1px solid #ffffff70; }
.ws-crop-rect::after { inset: 33.33% 0; border-block: 1px solid #ffffff70; }
.ws-crop-handle { position: absolute; right: 0; bottom: 0; width: 38px; height: 38px; cursor: nwse-resize; touch-action: none; }
.ws-crop-handle::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 13px; height: 13px; border-right: 4px solid white; border-bottom: 4px solid white; filter: drop-shadow(0 0 2px #17182b); }
.ws-crop-frame.is-locked .ws-crop-rect, .ws-crop-frame.is-locked .ws-crop-handle { cursor: default; }
.ws-crop-help { margin-top: 10px; }

.ws-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: start;
  align-items: center;
  gap: 10px;
  padding: 13px 15px 15px;
}
.ws-action-message { flex: 1 1 100%; color: var(--ws-muted); font-size: .83rem; margin: 0; }
.ws-action-message.ws-msg-error { color: var(--ws-danger); }
.ws-action-buttons { display: flex; flex-wrap: wrap; min-width: 0; gap: 7px; }
.ws-actions .ws-action-buttons { width: 100%; }
.ws-actions [data-action="process"] { flex: 1 1 auto; }
.ws-progress { width: 100%; height: 8px; flex: 1 0 100%; border: 0; border-radius: 99px; accent-color: var(--ws-accent); overflow: hidden; }
.ws-progress::-webkit-progress-bar { background: var(--ws-accent-bg); }
.ws-progress::-webkit-progress-value { background: var(--ws-accent); transition: width .15s; }
.ws-progress::-moz-progress-bar { background: var(--ws-accent); }
.ws-private { grid-area: private; display: flex; align-items: center; justify-content: center; gap: 7px; margin: 0; color: var(--ws-muted); font-size: .82rem; }
.ws-private svg { color: var(--ws-accent); }

.ws-results-head { padding: 16px 18px; border-bottom: 1px solid var(--ws-line); }
.ws-results-head > div:first-child { min-width: 0; flex: 1 1 160px; }
.ws-results-head h2 { margin-bottom: 4px; }
.ws-result-content { padding: 17px 18px 18px; }
.ws-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 9px; }
.ws-metric { display: grid; align-content: start; padding: 12px 14px; gap: 4px; border: 1px solid var(--ws-line); border-radius: 12px; background: var(--ws-panel); }
.ws-metric:nth-child(2) { background: var(--ws-accent-bg); border-color: var(--ws-accent-edge); }
.ws-metric strong { line-height: 1.18; font-size: 1.3rem; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.ws-difference { place-content: center; color: var(--ws-ink); font-size: 1rem; font-weight: 720; }
.ws-difference.is-smaller { color: var(--ws-success); background: var(--ws-success-bg); border-color: transparent; }
.ws-result-content h3 { margin: 14px 0 6px; font-size: .94rem; }
.ws-result-content > .ws-note { margin-top: 9px; }
.ws-result-warning, .ws-warnings {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--ws-warn-edge);
  border-radius: 10px;
  color: var(--ws-warn);
  background: var(--ws-warn-bg);
  font-size: .85rem;
}
.ws-warnings { padding-inline-start: 25px; }
.ws-check-table { width: 100%; border-collapse: collapse; table-layout: fixed; color: var(--ws-ink); font-size: .84rem; font-variant-numeric: tabular-nums; }
.ws-check-table th, .ws-check-table td { padding: 8px 6px; border-bottom: 1px solid var(--ws-line); text-align: start; overflow-wrap: anywhere; }
.ws-check-table thead th { color: var(--ws-muted); font-weight: 700; }
.ws-check-table tbody th { font-weight: 580; }

.ws-sr { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; white-space: nowrap; }
.ws-toast { position: fixed; z-index: 10; left: 18px; bottom: 18px; max-width: min(430px, calc(100% - 36px)); padding: 12px 15px; background: var(--ws-toast-bg); color: var(--ws-toast-ink); border: 1px solid var(--ws-accent-edge); border-radius: 12px; box-shadow: var(--ws-pop-shadow); font-size: .875rem; pointer-events: none; }

@media (max-width: 900px) {
  .ws { grid-template-columns: minmax(0, 1.22fr) minmax(285px, 1fr); gap: 12px; }
  .ws-media, .ws-sidebar { gap: 12px; }
  .ws-settings-head { padding-inline: 12px; }
  .ws-setting-content { padding-inline: 13px; }
}

@media (max-width: 700px) {
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'upload' 'preview' 'settings' 'actions' 'results' 'private'; gap: 12px; }
  .ws:has(.ws-preview[hidden]) { grid-template-areas: 'upload' 'settings' 'actions' 'results' 'private'; }
  .ws:has(.ws-results[hidden]) { grid-template-areas: 'upload' 'preview' 'settings' 'actions' 'private'; }
  .ws:has(.ws-preview[hidden]):has(.ws-results[hidden]) { grid-template-areas: 'upload' 'settings' 'actions' 'private'; }
  .ws-media, .ws-sidebar { display: contents; }
  .ws-upload { grid-area: upload; }
  .ws-preview { grid-area: preview; }
  .ws-settings { grid-area: settings; }
  .ws-actions { grid-area: actions; }
  .ws-drop { min-height: 262px; padding: 24px 14px; }
  .ws-drop-icon { width: 54px; height: 54px; margin-bottom: 15px; border-radius: 15px; }
  .ws-upload { padding: 10px; }
  .ws-toggle button { min-height: 42px; }
  .ws-preview-image { max-height: 290px; }
  .ws-actions { padding: 12px; }
  .ws-action-message { flex-basis: 100%; }
  .ws-settings-head, .ws-result-content, .ws-results-head { padding-inline: 12px; }
  .ws-file { grid-template-columns: minmax(0, 1fr) auto 42px; gap: 4px; }
  .ws-icon-button { width: 42px; }
  .ws-check { min-height: 44px; }
}

@media (max-width: 395px) {
  .ws-preview { padding: 10px; }
  .ws-preview-stage { padding: 7px; }
  .ws-check-table th, .ws-check-table td { padding-inline: 3px; }
  .ws-check-table { font-size: .8rem; }
  .ws-metric { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .ws *, .ws *::before, .ws *::after { transition-duration: 0s !important; }
}
