:root {
  --bg: #ffffff;
  --surface: #f7f7f8;
  --surface-hover: #efefef;
  --text: #1a1a1a;
  --text-2: #6b6b6b;
  --text-3: #9a9a9a;
  --border: #e4e4e4;
  --accent: #1a1a1a;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --mono: 'SF Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  --sans: -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image: radial-gradient(circle, #ececec 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  flex-shrink: 0;
}
.logo-icon { stroke: var(--text); }
.logo-text {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.logo-accent { color: var(--text-3); font-weight: 400; }

.level-tabs {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  margin: 0 auto;
}

.level-tab {
  padding: 6px 18px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 7px;
  transition: all var(--t);
  font-family: var(--sans);
}
.level-tab:hover { color: var(--text); }
.level-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ===== Language Button ===== */
.lang-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--t);
  font-family: var(--mono);
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.lang-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-3);
}

/* ===== Icon Button ===== */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--t);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.icon-btn.sm { width: 28px; height: 28px; }

/* ===== Main ===== */
.main {
  flex: 1;
  display: flex;
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.char-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  margin-right: 4px;
}

.editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  tab-size: 2;
}
.editor::placeholder { color: var(--text-3); }

/* ===== Footer ===== */
.footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--t);
  font-family: var(--sans);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}
.status.success { color: #0a8a3c; }
.status.error { color: #c41e1e; }

/* ===== Spinner ===== */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Overlay & Modal ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t), visibility var(--t);
  z-index: 100;
}
.overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg);
  border-radius: var(--radius);
  width: 460px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(8px);
  opacity: 0;
  transition: transform var(--t), opacity var(--t);
}
.overlay.active .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 8px 24px 20px;
  overflow-y: auto;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }

/* ===== Settings Sections ===== */
.settings-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--surface);
}
.settings-section:last-of-type { border-bottom: none; }

.settings-section h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.setting-row label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

/* ===== Select ===== */
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
  outline: none;
  transition: border-color var(--t);
}
select:focus { border-color: var(--text-3); }

/* ===== Toggle ===== */
.toggle {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background var(--t);
  flex-shrink: 0;
}
.toggle.active { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform var(--t);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.active::after { transform: translateX(16px); }

/* ===== Slider ===== */
.slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.slider-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  min-width: 32px;
}

/* ===== Reset Button ===== */
.btn-reset {
  width: 100%;
  padding: 8px;
  margin-top: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--t);
  font-family: var(--sans);
}
.btn-reset:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ===== Modal Footer Info ===== */
.modal-footer-info {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}
.version-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--accent);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  transition: all var(--t);
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.error { background: #c41e1e; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .level-tabs { order: 3; width: 100%; margin: 0; }
  .level-tab { flex: 1; padding: 6px 8px; font-size: 12px; }
  .main { flex-direction: column; }
  .footer { padding: 10px 16px; }
}
