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

/* Matrix — phosphor green on black, monospace, glow */
:root[data-theme='matrix'] {
  --font: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  --bg: #010703;
  --card: #04150b;
  --border: #0d3a20;
  --text: #c8ffd8;
  --text-soft: #4e9d68;
  --accent: #00ff41;
  --accent-glow: 0 0 8px rgba(0, 255, 65, 0.45);
  --header-bg: #000000;
  --header-border: #0d3a20;
  --title-color: #00ff41;
  --brand-dot: #00ff41;
  --brand-dot-radius: 2px;
  --ok-bg: rgba(0, 255, 65, 0.12);
  --ok-fg: #00ff41;
  --warn-bg: rgba(255, 42, 60, 0.12);
  --warn-fg: #ff5c6c;
  --off-bg: rgba(78, 157, 104, 0.12);
  --off-fg: #4e9d68;
  --busy-bg: rgba(0, 255, 65, 0.08);
  --busy-fg: #7dffa3;
  --hover-glow: 0 0 10px rgba(0, 255, 65, 0.2);
  --knob: #c8ffd8;
  --knob-on: #010703;
  --status-border: rgba(255, 42, 60, 0.35);
}

/* Light — white cards on soft gray, navy header, blue accent */
:root[data-theme='light'] {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg: #eef1f7;
  --card: #ffffff;
  --border: #e3e7f0;
  --text: #1a2038;
  --text-soft: #7c85a0;
  --accent: #3555e5;
  --accent-glow: none;
  --header-bg: #0c102b;
  --header-border: #0c102b;
  --title-color: #ffffff;
  --brand-dot: #e8272e;
  --brand-dot-radius: 3px;
  --ok-bg: #e4f5ec;
  --ok-fg: #177a4c;
  --warn-bg: #fdeaec;
  --warn-fg: #c4314b;
  --off-bg: #edf0f6;
  --off-fg: #7c85a0;
  --busy-bg: #e8edfb;
  --busy-fg: #3555e5;
  --hover-glow: 0 2px 10px rgba(53, 85, 229, 0.12);
  --knob: #ffffff;
  --knob-on: #ffffff;
  --status-border: transparent;
}

/* Dark — default theme: deep navy, soft blue accent */
:root,
:root[data-theme='dark'] {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg: #0c102b;
  --card: #161b3d;
  --border: #272e57;
  --text: #eef0f8;
  --text-soft: #8f96b5;
  --accent: #7b93ff;
  --accent-glow: none;
  --header-bg: #070a1e;
  --header-border: #272e57;
  --title-color: #ffffff;
  --brand-dot: #e8272e;
  --brand-dot-radius: 3px;
  --ok-bg: #12352a;
  --ok-fg: #5ad598;
  --warn-bg: #3d1b26;
  --warn-fg: #ff8296;
  --off-bg: #1d2347;
  --off-fg: #8f96b5;
  --busy-bg: #1c2650;
  --busy-fg: #9db0ff;
  --hover-glow: 0 2px 10px rgba(123, 147, 255, 0.15);
  --knob: #ffffff;
  --knob-on: #ffffff;
  --status-border: rgba(255, 130, 150, 0.25);
}

body {
  font-family: var(--font);
  background: var(--bg);
}

/* CRT scanlines — Matrix theme only */
:root[data-theme='matrix'] body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.16) 0,
    rgba(0, 0, 0, 0.16) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 9999;
}

.popup-container {
  width: 320px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 13px 16px;
}

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

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--brand-dot-radius);
  background: var(--brand-dot);
  box-shadow: var(--accent-glow);
}

.header h3 {
  color: var(--title-color);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-shadow: var(--accent-glow);
}

/* Blinking terminal cursor — Matrix theme only */
:root[data-theme='matrix'] .header h3::after {
  content: '_';
  animation: cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes cursor-blink {
  to {
    visibility: hidden;
  }
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}

:root[data-theme='light'] .icon-btn,
:root[data-theme='dark'] .icon-btn {
  color: #aab1d6;
}

.icon-btn:hover {
  color: var(--accent);
  background: rgba(127, 127, 127, 0.15);
}

:root[data-theme='light'] .icon-btn:hover,
:root[data-theme='dark'] .icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.content {
  padding: 14px 14px 6px;
}

.status-message {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--status-border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 12px;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  min-height: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.copy-btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: var(--hover-glow);
}

.copy-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.btn-row .copy-btn {
  flex: 1;
  min-width: 0;
}

.side-btn {
  width: 42px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-soft);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.side-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.side-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.token-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.token-exp {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.token-json {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--bg);
  border-radius: 6px;
  padding: 8px;
  margin: 0;
  max-height: 150px;
  overflow: auto;
  white-space: pre;
}

.btn-icon {
  font-size: 15px;
}

.btn-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-preview {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-preview:empty {
  display: none;
}

.btn-chip {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--off-bg);
  color: var(--off-fg);
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-chip:empty {
  visibility: hidden;
}

.btn-chip.ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
  text-shadow: var(--accent-glow);
}

.btn-chip.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.btn-chip.busy {
  background: var(--busy-bg);
  color: var(--busy-fg);
}

.footer {
  text-align: center;
  padding: 8px 0;
  color: var(--text-soft);
  font-size: 10px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.setting-info {
  flex: 1;
}

.setting-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.setting-desc {
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.45;
}

.setting-binding {
  margin-top: 6px;
}

.setting-desc b {
  color: var(--accent);
  font-weight: 600;
}

.theme-options {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.theme-option {
  flex: 1;
  padding: 6px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option.active {
  border-color: var(--accent);
  color: var(--accent);
  text-shadow: var(--accent-glow);
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--knob);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch input:checked + .slider {
  background: var(--accent);
  box-shadow: var(--accent-glow);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--knob-on);
}

.link-btn {
  margin-top: 2px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  align-self: flex-start;
}

.link-btn:hover {
  text-decoration: underline;
  text-shadow: var(--accent-glow);
}

.settings-author {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-soft);
}

.settings-author b {
  color: var(--text);
  font-weight: 600;
}

/* Own line under the name; visible only when the text is selected */
.hidden-magic {
  display: block;
  color: var(--bg);
}

.hidden-magic::selection {
  color: #ffffff;
  background: var(--accent);
}
