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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
}

/* Header */
header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1d1d1f;
}

/* Tab navigation */
nav { display: flex; gap: 4px; }

.tab-btn {
  background: none;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #555;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { background: #f0f0f5; color: #1d1d1f; }
.tab-btn.active { background: #e8e8ed; color: #1d1d1f; font-weight: 500; }

/* Main content */
main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* Tab sections */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section header */
.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.section-header p { color: #555; font-size: 0.9rem; }
.section-header-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Fetch form (proxies page) */
.fetch-form { margin-bottom: 24px; }

.input-row {
  display: flex;
  gap: 8px;
  max-width: 640px;
}

.input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.input-row input:focus { border-color: #0071e3; }

/* Buttons */
button {
  padding: 8px 18px;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover { background: #0077ed; }
button:active { background: #005ab4; }

/* Proxy list */
.proxy-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

@media (max-width: 640px) {
  .proxy-list { grid-template-columns: 1fr; }
}

.proxy-list li {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.proxy-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e8e8ed;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: "SF Mono", Menlo, monospace;
  letter-spacing: 0.03em;
}

.proxy-badge[data-type="SS"]       { background: #dbeafe; color: #1d4ed8; }
.proxy-badge[data-type="SSR"]      { background: #cffafe; color: #0e7490; }
.proxy-badge[data-type="VMess"]    { background: #ede9fe; color: #6d28d9; }
.proxy-badge[data-type="VLESS"]    { background: #dcfce7; color: #15803d; }
.proxy-badge[data-type="Trojan"]   { background: #ffedd5; color: #c2410c; }
.proxy-badge[data-type="Hy2"]      { background: #fef9c3; color: #a16207; }
.proxy-badge[data-type="Hysteria"] { background: #fef9c3; color: #a16207; }
.proxy-badge[data-type="TUIC"]     { background: #fce7f3; color: #9d174d; }

.proxy-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.proxy-meta {
  font-size: 0.76rem;
  color: #aaa;
  font-family: "SF Mono", Menlo, monospace;
  white-space: nowrap;
  flex-shrink: 0;
}

.result-meta {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 8px;
}

/* Config layout (surge/clash) */
.config-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .config-layout { grid-template-columns: 1fr; }
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-form label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
}

.config-form textarea {
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: "SF Mono", Menlo, monospace;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.config-form textarea:focus { border-color: #0071e3; }

/* Preview panel */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #f0f0f5;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #555;
}

.copy-btn {
  padding: 3px 10px;
  font-size: 0.78rem;
  background: #e0e0e5;
  color: #333;
  border-radius: 5px;
}

.copy-btn:hover { background: #d0d0d8; }

.preview-output {
  padding: 14px;
  font-size: 0.82rem;
  font-family: "SF Mono", Menlo, monospace;
  white-space: pre;
  overflow: auto;
  flex: 1;
  min-height: 260px;
  color: #1d1d1f;
  line-height: 1.55;
}

/* Utility */
.error { color: #d32f2f; font-size: 0.85rem; margin-top: 6px; }
.hidden { display: none !important; }

/* ── MITM section ────────────────────────────────────────────────────────── */

.mitm-form { display: flex; flex-direction: column; gap: 14px; }
.mitm-field { display: flex; flex-direction: column; gap: 6px; }
.mitm-label { font-size: 0.875rem; font-weight: 500; color: #1d1d1f; }
.mitm-cert-loaded { display: flex; align-items: center; gap: 10px; }
.mitm-cert-placeholder { font-size: 0.875rem; color: #6e6e73; font-style: italic; }
.mitm-toggles { display: flex; flex-direction: column; gap: 8px; }
.mitm-toggles label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; cursor: pointer; }
.mitm-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mitm-success { color: #1a7f37; font-size: 0.85rem; margin: 0; }
.btn-sm { font-size: 0.8rem; padding: 3px 10px; }

/* ── Managed Config row ─────────────────────────────────────────────────── */

.managed-config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.managed-config-row input[type="url"] {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.managed-config-row input[type="url"]:focus { border-color: #0071e3; }

.managed-config-row select {
  flex-shrink: 0;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
  outline: none;
}

.managed-config-row button { flex-shrink: 0; }
.managed-config-strict-label { flex-shrink: 0; }

.managed-config-strict-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.managed-config-success { color: #1a7f37; font-size: 0.85rem; margin: 0; }

/* ── Surge config editor ────────────────────────────────────────────────── */

.surge-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
}

.surge-section {
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.surge-section-toggle {
  list-style: none;
  padding: 12px 16px;
  background: #f7f7f9;
  font-size: 1rem;
  font-weight: 600;
  color: #1d1d1f;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: background 0.15s;
}

/* Hide default browser disclosure triangle */
.surge-section-toggle::-webkit-details-marker { display: none; }

.surge-section-toggle::before {
  content: '▾';
  font-size: 0.85rem;
  color: #888;
  width: 14px;
  display: inline-block;
  transition: transform 0.15s;
}

details.surge-section:not([open]) .surge-section-toggle::before {
  content: '▸';
}

.surge-section-toggle:hover { background: #efeff4; }

.surge-section-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 32px;
}

.entry-list.two-col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

@media (max-width: 900px) {
  .entry-list.two-col { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .entry-list.two-col { grid-template-columns: repeat(2, 1fr); }
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 7px 12px;
}

.entry-row.readonly {
  padding: 6px 12px;
}

.entry-value {
  flex: 1;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: #bbb;
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  padding: 0 2px;
}

.drag-handle:active { cursor: grabbing; }

.entry-row.dragging {
  opacity: 0.4;
}

.entry-row.drag-over {
  border-color: #0071e3;
  background: #f0f7ff;
}

.del-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 1rem;
  line-height: 1;
  background: #f0f0f5;
  color: #666;
  border-radius: 6px;
}

.del-btn:hover { background: #fde8e8; color: #d32f2f; }

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.add-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.add-row input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}

.add-row input[type="text"]:focus { border-color: #0071e3; }

/* General key-value rows */
.general-kv-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.general-kv-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.general-kv-row .general-key-select,
.general-add-row #surge-general-key-select {
  flex: 0 0 42%;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.general-value-container {
  flex: 1;
  display: flex;
}

.general-value-container .general-value-input,
.general-value-container .general-value-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.general-value-container .general-value-select {
  cursor: pointer;
  appearance: auto;
}

.general-value-container .general-value-input:focus,
.general-value-container .general-value-select:focus,
.general-kv-row .general-key-select:focus,
.general-add-row #surge-general-key-select:focus { border-color: #0071e3; }

/* Host section key-value rows */
.general-kv-row .host-row-key,
.general-add-row .host-key-input {
  flex: 0 0 42%;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
}

.general-kv-row .host-row-value,
.general-add-row .host-value-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.general-kv-row .host-row-key:focus,
.general-kv-row .host-row-value:focus,
.general-add-row .host-key-input:focus,
.general-add-row .host-value-input:focus { border-color: #0071e3; }

/* URL Rewrite rows */
.url-rewrite-row,
.url-rewrite-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.url-rewrite-row-pattern,
.url-rewrite-pattern {
  flex: 2;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.url-rewrite-row-replacement,
.url-rewrite-replacement {
  flex: 2;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.url-rewrite-row-type,
.url-rewrite-type {
  flex: 0 0 80px;
  padding: 7px 6px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.url-rewrite-row-pattern:focus,
.url-rewrite-row-replacement:focus,
.url-rewrite-pattern:focus,
.url-rewrite-replacement:focus,
.url-rewrite-row-type:focus,
.url-rewrite-type:focus { border-color: #0071e3; }

/* Header Rewrite — two-row layout */
.header-rewrite-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.header-rewrite-row,
.header-rewrite-add-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}

.header-rewrite-row-top,
.header-rewrite-add-top {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-rewrite-row-bottom,
.header-rewrite-add-bottom {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-left: 0;
}

.header-rewrite-row-direction,
.header-rewrite-direction {
  flex: 0 0 120px;
  padding: 7px 6px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.header-rewrite-row-pattern,
.header-rewrite-pattern {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.header-rewrite-row-action,
.header-rewrite-action {
  flex: 0 0 155px;
  padding: 7px 6px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.header-rewrite-row-field,
.header-rewrite-field {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.header-rewrite-row-value,
.header-rewrite-value,
.header-rewrite-row-template,
.header-rewrite-template {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.header-rewrite-row-direction:focus,
.header-rewrite-row-pattern:focus,
.header-rewrite-row-action:focus,
.header-rewrite-row-field:focus,
.header-rewrite-row-value:focus,
.header-rewrite-row-template:focus,
.header-rewrite-direction:focus,
.header-rewrite-pattern:focus,
.header-rewrite-action:focus,
.header-rewrite-field:focus,
.header-rewrite-value:focus,
.header-rewrite-template:focus { border-color: #0071e3; }

.entry-empty {
  font-size: 0.82rem;
  color: #aaa;
  padding: 6px 2px;
}

/* Custom sections */
.add-section-btn {
  align-self: flex-start;
  background: none;
  border: 1.5px dashed #bbb;
  color: #666;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.add-section-btn:hover {
  border-color: #0071e3;
  color: #0071e3;
  background: none;
}

.custom-title-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s;
}

.custom-title-input:focus { border-color: #0071e3; }

.custom-content-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: "SF Mono", Menlo, monospace;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.custom-content-input:focus { border-color: #0071e3; }

.custom-section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.del-section-btn {
  background: none;
  color: #d32f2f;
  border: 1px solid #f5c2c2;
  font-size: 0.84rem;
  padding: 6px 14px;
}

.del-section-btn:hover { background: #fde8e8; }

@media (max-width: 640px) {
  .add-row { flex-direction: column; }
  .add-row button { align-self: flex-start; }
}

/* ── Proxies controls ───────────────────────────────────────────────────── */

.proxy-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
}

.proxy-controls input[type="url"] {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

.proxy-controls input[type="url"]:focus { border-color: #0071e3; }

.proxy-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Auto-refresh interval */
.interval-control {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.interval-control label {
  font-size: 0.82rem;
  color: #666;
  white-space: nowrap;
}

.interval-control select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.82rem;
  background: #fff;
  color: #1d1d1f;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.interval-control select:focus { border-color: #0071e3; }

/* Fetch status row */
.fetch-status { min-height: 20px; }

.last-updated {
  font-size: 0.78rem;
  color: #888;
  margin-top: 4px;
}

/* Inline button spinner */
.btn-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

.btn-spinner.spinning {
  display: inline-block;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.proxy-empty-state {
  padding: 32px 0;
  font-size: 0.88rem;
  color: #aaa;
  text-align: center;
}

/* Skeleton loading rows */
.proxy-skeleton:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.skeleton-row {
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e8e8ed 25%, #f2f2f7 50%, #e8e8ed 75%);
  background-size: 200% 100%;
}

.proxy-skeleton:not(.hidden) .skeleton-row {
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-row:nth-child(2) { width: 82%; animation-delay: 0.1s; }
.skeleton-row:nth-child(3) { width: 64%; animation-delay: 0.2s; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Add Group trigger button ────────────────────────────────────────────── */

.add-entry-btn {
  align-self: flex-start;
  background: none;
  border: 1.5px dashed #bbb;
  color: #555;
  font-size: 0.84rem;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.add-entry-btn:hover {
  border-color: #0071e3;
  color: #0071e3;
  background: none;
}

/* ── Add Group Modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}


.modal-panel {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 1rem;
  font-weight: 600;
  color: #1d1d1f;
  flex-shrink: 0;
}

.modal-close-btn {
  background: #f0f0f5;
  color: #555;
  padding: 2px 9px;
  font-size: 1.1rem;
  line-height: 1.4;
  border-radius: 6px;
}

.modal-close-btn:hover { background: #e0e0e8; color: #1d1d1f; }

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.type-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.type-btn {
  background: #f0f0f5;
  color: #555;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-family: "SF Mono", Menlo, monospace;
  border-radius: 6px;
}

.type-btn:hover { background: #e0e0e8; color: #1d1d1f; }
.type-btn.active { background: #0071e3; color: #fff; }
.type-btn.active:hover { background: #0077ed; }

.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #333;
}

.modal-field input[type="text"],
.modal-field input[type="number"],
.modal-field textarea {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "SF Mono", Menlo, monospace;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}

.modal-field input[type="text"]:focus,
.modal-field input[type="number"]:focus,
.modal-field textarea:focus { border-color: #0071e3; }

.modal-field textarea { resize: vertical; }

.modal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-field-check label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 400;
  color: #1d1d1f;
  cursor: pointer;
}

.modal-field-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.field-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: #999;
}

.modal-details-section {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.modal-details-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f7f7f9;
  font-size: 0.82rem;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.modal-details-toggle::-webkit-details-marker { display: none; }

.modal-details-toggle::before {
  content: '▸';
  font-size: 0.75rem;
  color: #888;
  width: 12px;
  display: inline-block;
}

details.modal-details-section[open] .modal-details-toggle::before {
  content: '▾';
}

.modal-details-toggle:hover { background: #efeff4; }

.modal-details-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
}

.icon-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-url-row input {
  flex: 1;
}

.icon-url-preview {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #f5f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.icon-url-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.btn-secondary {
  background: #f0f0f5;
  color: #333;
}

.btn-secondary:hover { background: #e0e0e8; color: #1d1d1f; }

@media (max-width: 480px) {
  .modal-field-row { grid-template-columns: 1fr; }
  .type-selector { gap: 4px; }
}

/* ── Proxy group row ────────────────────────────────────────────────────── */

.group-row {
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.12s;
}

.group-row:hover {
  background: #f5f5f9;
}

.group-row .drag-handle {
  margin-top: 2px;
}

.group-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.group-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.group-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1d1d1f;
  white-space: nowrap;
}

.group-type-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e8e8ed;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: "SF Mono", Menlo, monospace;
  letter-spacing: 0.03em;
}

.group-type-badge[data-type="url-test"]     { background: #dbeafe; color: #1d4ed8; }
.group-type-badge[data-type="select"]       { background: #dcfce7; color: #15803d; }
.group-type-badge[data-type="fallback"]     { background: #ffedd5; color: #c2410c; }
.group-type-badge[data-type="load-balance"] { background: #ede9fe; color: #6d28d9; }
.group-type-badge[data-type="subnet"]       { background: #fef9c3; color: #a16207; }
.group-type-badge[data-type="smart"]        { background: #ccfbf1; color: #0f766e; }

.group-args {
  font-size: 0.82rem;
  font-family: "SF Mono", Menlo, monospace;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.group-desc {
  font-size: 0.78rem;
  color: #aaa;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-auto-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0f5;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.system-group {
  cursor: default;
  opacity: 0.85;
  background: #fafafa;
}

/* Import / Export */
.import-instructions { color: #555; font-size: 0.88rem; margin-bottom: 12px; }
.import-section-list { display: flex; flex-direction: column; gap: 8px; }
.import-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e0e0e8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.import-section-row:hover { background: #f5f5fa; }
.import-section-disabled { cursor: default; opacity: 0.6; }
.import-section-disabled:hover { background: transparent; }
.import-section-label { flex: 1; font-weight: 500; }
.import-section-meta { color: #888; font-size: 0.82rem; }
.import-section-hint { font-size: 0.78rem; color: #999; font-style: italic; }
.import-empty { color: #888; font-size: 0.9rem; }
.modal-panel-sm { max-width: 400px; }

/* ── Quote standalone page ──────────────────────────────────────── */

body.quote-page {
  background: #f7f3eb;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.quote-container {
  width: 100%;
  max-width: 760px;
  padding: 60px 48px 48px;
}

/* ── Camus quote banner (shared styles) ─────────────────────────── */

.quote-banner {
  background: #f7f3eb;
  border-bottom: 1px solid #e8e0d0;
  padding: 40px 48px 32px;
  position: relative;
}

.quote-mark {
  font-size: 3rem;
  line-height: 1;
  color: #b0a898;
  font-family: Georgia, serif;
  margin-bottom: 12px;
  user-select: none;
}

.quote-text {
  font-size: 1.45rem;
  font-style: italic;
  font-family: "Hiragino Mincho ProN", "Songti SC", Georgia, serif;
  color: #2a2118;
  line-height: 1.7;
  max-width: 680px;
  margin-bottom: 20px;
}

.quote-divider {
  border: none;
  border-top: 1.5px solid #c8bfaf;
  width: 40px;
  margin: 0 0 16px;
}

.quote-source {
  font-size: 1rem;
  color: #5a5040;
  margin-bottom: 24px;
  font-family: "Hiragino Mincho ProN", "Songti SC", Georgia, serif;
}

.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quote-author-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quote-author {
  font-size: 0.9rem;
  color: #8a8070;
  letter-spacing: 0.02em;
}

/* Dot pagination */
.quote-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.quote-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c8bfaf;
  display: inline-block;
  transition: background 0.2s;
}

.quote-dot.active {
  background: #5a5040;
}

/* 换一句 button */
.quote-next-btn {
  background: transparent;
  color: #3a3028;
  border: 1.5px solid #b0a898;
  border-radius: 20px;
  padding: 8px 22px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.quote-next-btn:hover {
  background: #ede8dc;
  border-color: #8a8070;
}

.quote-next-btn:active {
  background: #e0d9cc;
}

@media (max-width: 480px) {
  .quote-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

/* ── Magic button (fixed top-right) ────────────────────────────── */

.magic-btn {
  position: fixed;
  top: 14px;
  right: 20px;
  z-index: 1000;
  background: #fff;
  color: #1d1d1f;
  border: 1.5px solid #d0d0d5;
  border-radius: 20px;
  padding: 7px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: background 0.15s, box-shadow 0.15s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.magic-btn:hover {
  background: #f5f5f7;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

@media (max-width: 640px) {
  .quote-banner { padding: 28px 20px 24px; }
  .quote-text { font-size: 1.2rem; }
}

