:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  background: #eef4f3;
  color: #12161d;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at top left, rgba(15, 143, 122, 0.12), transparent 32%), #eef4f3;
}

.vector-shell {
  width: min(1440px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 30px;
}

.vector-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
}

.vector-topbar p,
.vector-topbar h1,
.vector-topbar span { margin: 0; }

.vector-topbar p {
  color: #0b6f61;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.vector-topbar h1 {
  margin-top: 3px;
  font-size: 26px;
  line-height: 1.15;
}

.vector-topbar span {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 13px;
}

.back-link,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.back-link {
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: #334155;
  background: #fff;
}

.download-button {
  color: #fff;
  background: #111827;
  cursor: pointer;
}

.vector-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.canvas-panel,
.settings-panel {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
}

.canvas-panel { padding: 16px; }

.progress-wrap { margin-bottom: 12px; }

.drop-card {
  min-height: 0;
  border-radius: 16px;
  border: 1px dashed rgba(15, 143, 122, 0.28);
  background: linear-gradient(45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.08) 75%),
    linear-gradient(45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.08) 75%);
  background-color: #f8fafc;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  overflow: hidden;
}

.compare-drop {
  padding: 14px;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.compare-card {
  display: flex;
  min-width: 0;
  min-height: 460px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.compare-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.92);
}

.compare-actions {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.compare-title span {
  color: #111827;
  font-size: 14px;
  font-weight: 900;
}

.compare-title small {
  min-width: 0;
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-button {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 0 9px;
  white-space: nowrap;
}

.mini-button:hover {
  border-color: rgba(15, 143, 122, 0.35);
  color: #0b6f61;
  background: rgba(15, 143, 122, 0.08);
}

.compare-stage {
  position: relative;
  width: 100%;
  min-height: 414px;
  flex: 1;
  background: #fff;
}

.source-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.source-preview {
  display: block;
}

#sourcePreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-placeholder {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 280px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed rgba(15, 143, 122, 0.3);
  border-radius: 12px;
  color: #64748b;
  text-align: center;
}

.source-placeholder strong {
  color: #111827;
  font-size: 18px;
}

.source-placeholder span {
  max-width: 320px;
  font-size: 13px;
  line-height: 1.6;
}

#canvas-container {
  width: 100% !important;
  margin-bottom: 0 !important;
}

#frame,
#svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

#svg > path:hover { stroke: #0f8f7a; }

.droptext {
  position: absolute;
  inset: 22px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed rgba(15, 143, 122, 0.34);
  border-radius: 14px;
  color: #64748b;
  text-align: center;
}

.droptext strong { color: #111827; font-size: 20px; }
.droptext span { font-size: 13px; }
.droptext a {
  display: inline-flex;
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  background: #0f8f7a;
  font-weight: 900;
  text-decoration: none;
}

.compare-hint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.settings-panel {
  position: sticky;
  top: 16px;
  margin: 0;
  padding: 18px;
}

.settings-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-title span,
.setting-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.settings-title strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.reset-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 143, 122, 0.28);
  border-radius: 9px;
  background: rgba(15, 143, 122, 0.08);
  color: #0b6f61;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 0 10px;
  white-space: nowrap;
}

.reset-button:hover {
  background: #0f8f7a;
  color: #fff;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segmented button {
  min-height: 38px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-weight: 900;
  cursor: pointer;
}

.segmented button.selected {
  border-color: rgba(15, 143, 122, 0.35);
  background: rgba(15, 143, 122, 0.1);
  color: #0b6f61;
}

.range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.range-head b {
  color: #0b6f61;
}

.uk-range::-webkit-slider-thumb { background: #0f8f7a; }
.hidden-controls { display: none; }

body.preview-open { overflow: hidden; }

.preview-modal[hidden] { display: none; }

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}

.preview-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1280px, 100%);
  height: min(820px, calc(100vh - 44px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: #f8fafc;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.28);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
}

.preview-toolbar strong {
  color: #111827;
  font-size: 15px;
  font-weight: 900;
}

.preview-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.preview-controls button {
  min-width: 38px;
  min-height: 34px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 9px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  font-weight: 900;
}

.preview-controls button:hover {
  border-color: rgba(15, 143, 122, 0.35);
  color: #0b6f61;
}

.preview-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: rgba(15, 23, 42, 0.1);
}

.preview-card {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 42px minmax(0, 1fr);
  background: #fff;
}

.preview-title {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.preview-pane {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.12) 75%),
    linear-gradient(45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.12) 75%);
  background-color: #f8fafc;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  cursor: grab;
}

.preview-pane:active { cursor: grabbing; }

.preview-zoom-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  transform-origin: center;
}

#previewSourceImage,
.preview-svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-vector-content {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.preview-empty {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(15, 23, 42, 0.18);
  border-radius: 12px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
  padding: 24px;
  text-align: center;
}

@media (max-width: 920px) {
  .vector-shell { width: min(100% - 20px, 720px); padding-top: 12px; }
  .vector-topbar { grid-template-columns: 1fr; align-items: stretch; }
  .vector-layout { grid-template-columns: 1fr; }
  .settings-panel { position: static; }
  .compare-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .compare-card { min-height: 360px; }
  .compare-stage { min-height: 314px; }
}

@media (max-width: 460px) {
  .vector-topbar h1 { font-size: 22px; }
  .compare-drop { padding: 10px; }
  .compare-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .compare-card { min-height: 260px; }
  .compare-stage { min-height: 214px; }
  .compare-title { padding: 0 8px; }
  .compare-title span { font-size: 12px; }
  .compare-title small { display: none; }
  .compare-actions { gap: 4px; }
  .mini-button { min-height: 26px; padding: 0 6px; font-size: 11px; }
  .source-placeholder { min-height: 180px; padding: 12px; }
  .source-placeholder strong { font-size: 14px; }
  .source-placeholder span { display: none; }
  .compare-hint { flex-direction: column; gap: 4px; }
  .droptext { inset: 12px; }
  .droptext strong { font-size: 14px; }
  .droptext span { display: none; }
  .droptext a { padding: 8px 10px; font-size: 12px; }
  .preview-modal { padding: 10px; }
  .preview-dialog { height: calc(100vh - 20px); }
  .preview-toolbar { align-items: flex-start; flex-direction: column; min-height: auto; padding: 12px; }
  .preview-controls { width: 100%; }
  .preview-controls button { flex: 1; min-width: 0; }
  .settings-title-row { align-items: flex-start; flex-direction: column; }
  .reset-button { width: 100%; }
  .preview-grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .preview-card { grid-template-rows: 34px minmax(0, 1fr); }
  .preview-zoom-layer { padding: 14px; }
}
