:root {
  --bg: #0a0a0a;
  --card: #171717;
  --card-elevated: #1a1a1a;
  --border: #404040;
  --border-soft: rgba(64, 64, 64, 0.5);
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --accent: #fafafa;
  --accent-dim: #e5e5e5;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --ok: #d4d4d4;
  --ok-soft: rgba(255, 255, 255, 0.06);
  --warn: #a3a3a3;
  --danger: #a3a3a3;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

/* 纯黑底，无彩色光晕 */
.petiloop-body {
  background-color: #0a0a0a;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

.btn:hover {
  border-color: #737373;
  background: var(--card);
}

.btn:active {
  opacity: 0.92;
}

.btn.primary {
  background: #fafafa;
  border-color: #d4d4d4;
  color: #0a0a0a;
  box-shadow: none;
}

.btn.primary:hover {
  background: #fff;
  border-color: #fff;
}

.btn.ghost {
  background: transparent;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px 18px;
  background: var(--card-elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.stat:hover {
  border-color: #737373;
}

.stat .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.stat .value {
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

textarea.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
  line-height: 1.6;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
}

.row > div {
  flex: 1;
  min-width: 180px;
}

.form-group {
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.err {
  color: #d4d4d4;
  font-size: 0.88rem;
  margin-top: 8px;
}

.ok-msg {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

pre.doc {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0;
  color: var(--muted);
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0;
  padding: 12px 14px;
  background: var(--card-elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.help-section {
  margin-bottom: 20px;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

.help-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.help-row input {
  flex: 1;
}

.help-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}

.current-selection {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--card-elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.current-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.current-selection-main {
  flex: 1;
  min-width: 0;
}

.current-selection-main label {
  margin-bottom: 6px;
}

.current-selection-value {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}

.current-selection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.current-selection-save-msg {
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .current-selection-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .current-selection-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* 胶囊式开关：勾选 = 亮起，未勾选 = 熄灭 */
.pill-toggle-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 4px;
}

.pill-toggle {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pill-toggle-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.pill-toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.pill-toggle-input:checked + .pill-toggle-pill {
  background: rgba(255, 255, 255, 0.1);
  border-color: #a3a3a3;
  color: var(--text);
  box-shadow: none;
}

.pill-toggle:hover .pill-toggle-pill {
  border-color: #737373;
  color: var(--text);
}

.pill-toggle-input:not(:checked) + .pill-toggle-pill {
  box-shadow: none;
}

.pill-toggle:focus-within .pill-toggle-pill {
  outline: 1px solid #737373;
  outline-offset: 2px;
}

/* 禁止 file:// 打开时的说明页 */
.file-protocol-panel {
  max-width: 680px;
  margin: 64px auto;
  padding: 36px 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.file-protocol-panel h1 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 700;
}

.file-protocol-panel code {
  display: block;
  margin: 16px 0;
  padding: 16px 18px;
  background: var(--card-elevated);
  border-radius: 12px;
  font-size: 0.9rem;
  word-break: break-all;
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
}

.file-protocol-panel ul {
  margin: 12px 0 0;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
}
