:root {
  --primary-50: #eff6ff; --primary-100: #dbeafe; --primary-200: #bfdbfe;
  --primary-300: #93c5fd; --primary-400: #60a5fa; --primary-500: #3b82f6;
  --primary-600: #2563eb; --primary-700: #1d4ed8;

  --success-50: #ecfdf5; --success-100: #d1fae5; --success-200: #a7f3d0;
  --success-400: #34d399; --success-500: #10b981; --success-600: #059669; --success-700: #047857;

  --warning-50: #fffbeb; --warning-100: #fef3c7; --warning-200: #fde68a;
  --warning-400: #fbbf24; --warning-500: #f59e0b; --warning-600: #d97706;

  --danger-50: #fef2f2; --danger-100: #fee2e2; --danger-200: #fecaca;
  --danger-400: #f87171; --danger-500: #ef4444; --danger-600: #dc2626; --danger-700: #b91c1c;

  --info-50: #eff6ff; --info-100: #dbeafe; --info-200: #bfdbfe;
  --info-400: #60a5fa; --info-500: #3b82f6; --info-600: #2563eb;

  --bg-app: #f5f6f8; --bg-primary: #ffffff; --bg-secondary: #f5f6f8;
  --bg-tertiary: #eef0f4; --bg-hover: #f8f9fa; --bg-overlay: rgba(0,0,0,0.35);

  --text-primary: #1f2937; --text-secondary: #4b5563; --text-tertiary: #9ca3af; --text-inverse: #fff;

  --border-light: #e5e7eb; --border-medium: #d1d5db; --border-strong: #9ca3af;

  --control-bg: #ffffff; --control-bg-hover: #f9fafb; --control-bg-active: #f3f4f6;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px rgba(0,0,0,0.03);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 1.75rem; --space-8: 2.25rem; --space-10: 3rem; --space-12: 3.5rem;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --fs-xs: 0.8125rem; --fs-sm: 0.875rem; --fs-base: 0.9375rem;
  --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.25rem;

  --radius-sm: 5px; --radius-md: 7px; --radius-lg: 10px;
  --radius-xl: 14px; --radius-2xl: 18px; --radius-full: 9999px;


  --bg: var(--bg-app); --bg2: var(--bg-primary); --bg3: var(--bg-tertiary);
  --border: var(--border-medium); --border2: var(--border-strong);
  --text: var(--text-primary); --text2: var(--text-secondary); --text3: var(--text-tertiary);
  --accent: var(--primary-600); --accent-bg: var(--primary-50); --accent-border: var(--primary-200);
  --green: var(--success-700); --green-bg: var(--success-50); --green-border: var(--success-200);
  --yellow: var(--warning-600); --yellow-bg: var(--warning-50); --yellow-border: var(--warning-200);
  --radius: var(--radius-md); --font: var(--font-mono);
}
[data-theme="dark"] {
  --bg-app: #1a1a1a; --bg-primary: #232323; --bg-secondary: #1a1a1a;
  --bg-tertiary: #2d2d2d; --bg-hover: #333; --bg-overlay: rgba(0,0,0,0.55);

  --text-primary: #f0f0f0; --text-secondary: #b0b0b0; --text-tertiary: #777; --text-inverse: #1a1a1a;

  --border-light: #333; --border-medium: #444; --border-strong: #666;

  --control-bg: #2a2a2a; --control-bg-hover: #333; --control-bg-active: #3a3a3a;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.3), 0 10px 10px rgba(0,0,0,0.15);

  --bg: var(--bg-app); --bg2: var(--bg-primary); --bg3: var(--bg-tertiary);
  --border: var(--border-medium); --border2: var(--border-strong);
  --text: var(--text-primary); --text2: var(--text-secondary); --text3: var(--text-tertiary);
  --accent: var(--primary-400); --accent-bg: #1f2633; --accent-border: #334155;
  --green: var(--success-400); --green-bg: #1f2f27; --green-border: #2e5b43;
  --yellow: var(--warning-400); --yellow-bg: #2d291f; --yellow-border: #5f5130;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  -webkit-font-smoothing: antialiased;
}
.root {
  width: 100%;
  max-width: 680px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  height: fit-content;
}
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.header-spacer { flex: 1; }
.theme-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.lang-sel {
  width: 110px;
  height: 30px;
  padding: 4px 28px 4px 10px;
  font-size: 11px;
  border-radius: var(--radius);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--font);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23777' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.lang-sel:focus {
  outline: none;
  border-color: var(--border2);
  color: var(--text);
}
.theme-toggle-track {
  width: 56px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  position: relative;
}
.theme-toggle-track.dark {
  background: var(--bg-hover);
  border-color: var(--border2);
}
.theme-toggle-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border);
  position: absolute;
  left: 2px;
  top: 2px;
}
.theme-toggle-thumb.dark {
  transform: translateX(26px);
  border-color: var(--border2);
}
.theme-toggle-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  pointer-events: none;
}
.theme-toggle-sun,
.theme-toggle-moon {
  width: 12px;
  height: 12px;
  color: var(--text3);
}
.theme-toggle-track .theme-toggle-sun { opacity: 1; }
.theme-toggle-track .theme-toggle-moon { opacity: 0.45; }
.theme-toggle-track.dark .theme-toggle-sun { opacity: 0.45; }
.theme-toggle-track.dark .theme-toggle-moon { opacity: 1; color: var(--text2); }
h1 { font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.subtitle { font-size: 12px; color: var(--text3); margin-bottom: 1.5rem; margin-top: 18px; line-height: 1.5; }
.subtitle a { color: var(--accent); text-decoration: none; }
.subtitle a:hover { text-decoration: underline; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 520px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
select, input[type=text] {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6f85' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
select option { background: var(--bg3); color: var(--text); }
select optgroup { color: var(--text2); }
select:focus, input:focus { outline: none; border-color: var(--border2); }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.slabel {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.dl-btn {
  width: 100%;
  padding: 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 0.02em;
  text-decoration: none;
  display: block;
  text-align: center;
}
.dl-btn:hover:not(:disabled):not(.disabled) { background: var(--bg-hover); border-color: var(--text3); }
.dl-btn:disabled, .dl-btn.disabled {
  background: var(--bg3);
  border-color: var(--border);
  color: var(--text3);
  cursor: not-allowed;
  opacity: 0.65;
  pointer-events: none;
}
.info-box, .preview-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 1rem 0 8px;
  font-size: 12px;
  font-family: var(--font);
  overflow-x: auto;
}
.info-row, .preview-row { display: flex; gap: 10px; margin-bottom: 6px; }
.info-row:last-child, .preview-row:last-child { margin-bottom: 0; }
.info-label, .offset { color: var(--text3); min-width: 75px; flex-shrink: 0; }
.info-value, .json-b1 { color: var(--text); word-break: break-all; }
.info-value-green, .json-b2 { color: var(--green); word-break: break-all; }
.info-value-dim, .json-ff { color: var(--text3); opacity: 0.6; }
.info-msg, .info {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  margin: 8px 0;
  line-height: 1.5;
}
.warning-msg, .warning {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  margin: 8px 0;
  line-height: 1.5;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text3); text-decoration: none;
  margin-bottom: 12px; font-family: var(--font);
}
.back-link:hover { color: var(--text); }
.url-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 11px; font-family: var(--font); color: var(--text3);
  margin-top: 10px; word-break: break-all; line-height: 1.6; user-select: all; cursor: pointer;
  position: relative;
}
.url-box span { color: var(--text); }
.url-box:hover { border-color: var(--border2); }
.url-box .copy-hint {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--text3); opacity: 0;
}
.url-box:hover .copy-hint { opacity: 1; }
.copied-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: var(--text-inverse); padding: 8px 18px;
  border-radius: var(--radius); font-size: 12px; font-family: var(--font);
  box-shadow: var(--shadow-lg); opacity: 0;
  pointer-events: none; z-index: 100;
}
.copied-toast.show { opacity: 1; }
.rev-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.rev-btn {
  flex: 1;
  min-width: 140px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  cursor: pointer;
  text-align: center;
}
.rev-btn:hover { border-color: var(--border2); color: var(--text); }
.rev-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}
.flash-cmd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text3);
  margin-top: 10px;
  word-break: break-all;
  line-height: 1.6;
  user-select: all;
}
.flash-cmd span { color: var(--text); }
.mac-hint { font-size: 11px; color: var(--text3); margin-top: 2px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 18px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  cursor: pointer; min-height: 160px; justify-content: center;
}
.tile:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.tile-icon { width: 40px; height: 40px; color: var(--text2); flex-shrink: 0; }
.tile-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.tile-desc { font-size: 11px; color: var(--text3); line-height: 1.5; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 520px) {
  .root { padding: 1.25rem; }
  .header { flex-wrap: wrap; }
  .header-spacer { display: none; }
  .lang-sel { margin-left: auto; }
}
