*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin-bottom: 50px;
}

/* ---- Header ---- */
.header {
  background: #ffffff;
  color: #0f172a;
  padding: 0 32px;
  height: 78px;
  min-height: 78px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 #e2e8f0, 0 4px 20px rgba(0,0,0,0.06);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}
.header-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}
.header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #0f172a;
}
.header-sub {
  font-size: 11px;
  color: #64748b;
  font-weight: 400;
  margin-top: 1px;
}
.btn-guide {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 8px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-guide:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* ---- Layout ---- */
.main {
  display: flex;
  gap: 20px;
  padding: 24px 28px;
  max-width: 1320px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}
.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding-right: 4px;
  padding-bottom: 80px;
}
.right-panel {
  width: 344px;
  flex-shrink: 0;
}

/* ---- Cards ---- */
.card {
  background: white;
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.06);
  border: 1px solid rgba(226,232,240,0.8);
}

/* ---- Section titles ---- */
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
  letter-spacing: -0.2px;
}
.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.icon-emerald { background: #dbeafe; }
.icon-violet  { background: #ede9fe; }
.icon-amber   { background: #fef3c7; }
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  color: #94a3b8;
  font-size: 10px;
  cursor: default;
  font-style: normal;
  font-weight: 700;
}
.section-desc {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 16px;
  line-height: 1.65;
}
.section-desc a { color: #3b82f6; text-decoration: none; font-weight: 500; }
.section-desc a:hover { text-decoration: underline; }

/* ---- Count badge ---- */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  min-width: 30px;
  letter-spacing: 0.2px;
}

/* ---- Toolbar buttons ---- */
.toolbar-row {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: -0.1px;
}
.btn-green {
  background: #3b82f6;
  color: white;
  box-shadow: 0 1px 4px rgba(59,130,246,0.25);
}
.btn-green:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.35);
}
.btn-teal {
  background: #6366f1;
  color: white;
  box-shadow: 0 1px 4px rgba(99,102,241,0.25);
}
.btn-teal:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}
.btn-red {
  background: #ef4444;
  color: white;
  box-shadow: 0 1px 4px rgba(239,68,68,0.2);
}
.btn-red:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(239,68,68,0.3);
}
.btn-outline {
  background: white;
  border: 1.5px solid #e2e8f0;
  color: #475569;
}
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }

/* ---- Code editor ---- */
.editor-wrapper {
  display: flex;
  border: 1.5px solid #e2e8f0;
  border-radius: 11px;
  overflow: hidden;
  background: #fafafa;
  transition: all 0.2s;
}
.editor-wrapper:focus-within {
  border-color: #3b82f6;
  background: white;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.line-numbers {
  background: #3b82f6;
  color: rgba(255,255,255,0.85);
  padding: 10px 0;
  min-width: 40px;
  text-align: center;
  user-select: none;
  overflow: hidden;
  font-size: 11px;
  line-height: 22px;
  font-family: 'Courier New', monospace;
  flex-shrink: 0;
  max-height: 350px;
}
.line-numbers span { display: block; padding: 0 6px; }
.editor-textarea {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 22px;
  resize: none;
  min-height: 100px;
  max-height: 350px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  color: #1e293b;
  background: transparent;
  white-space: pre;
  overflow-x: auto;
}
.editor-textarea::placeholder { color: #94a3b8; }

/* ---- Segmented radio control ---- */
.seg-group {
  display: flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 14px;
  width: fit-content;
}
.seg-group label {
  position: relative;
  padding: 6px 15px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s;
  user-select: none;
  white-space: nowrap;
}
.seg-group label:has(input:checked) {
  background: white;
  color: #3b82f6;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.04);
}
.seg-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ---- Toggle switch ---- */
.toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.toggle { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #e2e8f0;
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.toggle input:checked + .toggle-slider { background: #3b82f6; }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }
.toggle-status {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

/* ---- Right panel preview ---- */
.panel-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.chrome-dot { width: 10px; height: 10px; border-radius: 50%; }
.chrome-dot.r { background: #ff5f57; }
.chrome-dot.y { background: #ffbd2e; }
.chrome-dot.g { background: #28c840; }
.preview-title {
  font-size: 11.5px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  flex: 1;
  text-align: center;
  padding-right: 26px;
}
.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}
.preview-canvas-box {
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  min-width: 200px;
  padding: 6px;
}
.preview-canvas-box canvas { border-radius: 8px; }
#previewCanvas { display: block; }
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 24px;
  line-height: 1.7;
  gap: 8px;
}
.size-label {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 10px;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ---- Ruler ---- */
.ruler {
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    #cbd5e1 0px, #cbd5e1 1px,
    transparent 1px, transparent 8px,
    #e2e8f0 8px, #e2e8f0 9px,
    transparent 9px, transparent 40px
  );
  margin: 8px 0 2px;
  width: 100%;
  opacity: 0.55;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  background: #f8fafc;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 18px;
  border: 1px solid #f1f5f9;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.6px;
  border-radius: 8px;
  transition: all 0.15s;
  font-family: inherit;
  text-transform: uppercase;
}
.tab-btn:hover { color: #475569; background: rgba(255,255,255,0.7); }
.tab-btn.active {
  background: white;
  color: #3b82f6;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.04);
}

/* ---- Settings rows ---- */
.setting-row { margin-bottom: 15px; }
.setting-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}
.setting-val {
  font-weight: 700;
  color: #0f172a;
  font-size: 11px;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 5px;
  letter-spacing: 0.2px;
}
.setting-row input[type="range"] {
  width: 100%;
  height: 5px;
  accent-color: #3b82f6;
  cursor: pointer;
  border-radius: 3px;
}
.setting-row select, .setting-row input[type="color"] {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  background: #fafafa;
  color: #1e293b;
  transition: all 0.2s;
  cursor: pointer;
  font-family: inherit;
}
.setting-row select:focus, .setting-row input[type="color"]:focus {
  outline: none;
  border-color: #3b82f6;
  background: white;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.setting-row input[type="color"] { height: 40px; padding: 3px 5px; }

/* ---- Restore button ---- */
.btn-restore {
  background: white;
  color: #ef4444;
  padding: 7px 14px;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-restore:hover { background: #fef2f2; border-color: #ef4444; }

/* ---- Download button ---- */
.download-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 60%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: -0.2px;
  box-shadow: 0 4px 16px rgba(59,130,246,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.download-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  transform: translateX(-100%);
  transition: transform 0.55s ease;
}
.download-btn:hover:not(:disabled)::after { transform: translateX(100%); }
.download-btn:hover:not(:disabled) {
  box-shadow: 0 8px 28px rgba(59,130,246,0.45), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-2px);
}
.download-btn:active:not(:disabled) { transform: translateY(0); }
.download-btn:disabled {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ---- Progress ---- */
.progress-bar {
  height: 4px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
  box-shadow: 0 0 6px rgba(59,130,246,0.5);
}
.status-msg {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin-top: 8px;
  min-height: 18px;
  font-weight: 500;
}

/* ---- Section divider ---- */
.s-divider { height: 1px; background: #f1f5f9; margin: 4px 0 16px; }

/* ---- Disabled overlay ---- */
.disabled-section { opacity: 0.4; pointer-events: none; }

/* ---- Responsive ---- */
@media (max-width: 920px) {
  .main { flex-direction: column; padding: 14px 16px; }
  .right-panel { width: 100%; position: static; }
  .header { padding: 0 16px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Sticky Bottom Bar ---- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 12px 28px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bottom-bar-inner {
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Preview Nav ---- */
.preview-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  background: white;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.nav-btn:hover { background: #f1f5f9; border-color: #3b82f6; }
.nav-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

/* ---- Mismatch Warning ---- */
.mismatch-warn {
  font-size: 11.5px;
  color: #f59e0b;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 5px 10px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ---- Save One Button ---- */
.btn-save-one {
  margin-top: 8px;
  padding: 6px 16px;
  background: white;
  border: 1.5px solid #3b82f6;
  color: #3b82f6;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-save-one:hover { background: #eff6ff; }

/* ---- Result Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.6); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-box { background: white; border-radius: 20px; width: 100%; max-width: 1100px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 80px rgba(0,0,0,0.3); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid #f1f5f9; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.modal-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.modal-close { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid #e2e8f0; background: white; cursor: pointer; font-size: 14px; color: #64748b; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.modal-close:hover { background: #fef2f2; border-color: #ef4444; color: #ef4444; }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-card { border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: #fafafa; transition: all 0.15s; }
.modal-card:hover { border-color: #3b82f6; background: white; box-shadow: 0 4px 12px rgba(59,130,246,0.1); }
.modal-card img { width: 120px; height: 120px; border-radius: 8px; border: 1px solid #e2e8f0; object-fit: contain; background: white; }
.modal-card-name { font-size: 11px; font-weight: 600; color: #0f172a; text-align: center; word-break: break-all; max-width: 100%; }
.modal-card-url { font-size: 10px; color: #64748b; text-align: center; word-break: break-all; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.modal-card-label { font-size: 10px; color: #3b82f6; font-weight: 600; text-align: center; word-break: break-all; max-width: 100%; }
.modal-card-dl { margin-top: 2px; padding: 4px 12px; background: white; border: 1.5px solid #e2e8f0; color: #475569; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.modal-card-dl:hover { background: #eff6ff; border-color: #3b82f6; color: #3b82f6; }
.verify-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.2px; }
.verify-ok   { background: #dbeafe; color: #1e40af; }
.verify-fail { background: #fee2e2; color: #991b1b; }
.modal-verify-summary { display: flex; gap: 10px; align-items: center; font-size: 12px; margin-top: 3px; }
.vsumm-ok   { color: #3b82f6; font-weight: 600; }
.vsumm-fail { color: #ef4444; font-weight: 600; }
