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

html {
  background: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #e6edf3;
  background: transparent;
  width: 316px;
  padding: 8px;
}

.popup {
  padding: 16px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(1, 4, 9, 0.75);
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.logo {
  font-size: 24px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 4px;
}

.header-btn {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  cursor: pointer;
  padding: 5px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.header-btn:hover {
  background: #21262d;
  color: #e6edf3;
  border-color: #8b5cf6;
}

/* About Modal */
.about-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-content {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  padding: 28px 24px 20px;
  text-align: center;
  width: 260px;
  box-shadow: 0 16px 48px rgba(1, 4, 9, 0.8);
}

.about-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.about-logo {
  font-size: 36px;
  display: block;
}

.about-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #e6edf3;
}

.about-version {
  font-size: 12px;
  color: #8b949e;
  margin-bottom: 4px;
}

.about-subtitle {
  font-size: 11px;
  color: #484f58;
  margin-bottom: 16px;
  font-style: italic;
}

.about-links-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.about-links-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8b5cf6;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.about-links-list a:hover {
  color: #a78bfa;
}

.about-links-list a svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.about-footer {
  border-top: 1px solid #30363d;
  padding-top: 12px;
  margin-bottom: 12px;
}

.about-copyright {
  font-size: 11px;
  color: #484f58;
}

.about-close-btn {
  background: #8b5cf6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.about-close-btn:hover {
  background: #7c3aed;
}

/* Launch button */
.launch-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px;
}

.launch-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
}

.launch-circle:hover {
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  transform: scale(1.05);
}

.launch-circle:active {
  transform: scale(0.95);
}

.launch-circle svg {
  margin-left: 3px;
}

.launch-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
  letter-spacing: 0.5px;
}

.section {
  margin-bottom: 12px;
}

.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.strong-label {
  color: #e6edf3;
  margin-bottom: 2px;
}

.companion-card {
  padding: 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 10px;
}

.companion-card .hint {
  margin: 0;
  line-height: 1.35;
}

.install-command-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.install-command-row code {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-btn {
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #21262d;
  color: #e6edf3;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
}

.small-btn:hover {
  border-color: #8b5cf6;
}

.one-click-row {
  justify-content: space-between;
  margin-top: 10px;
  color: #8b949e;
  font-size: 13px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #8b949e;
  margin-bottom: 6px;
}

.select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
  color: #e6edf3;
  cursor: pointer;
  outline: none;
}

.select:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
  color: #e6edf3;
  outline: none;
  box-sizing: border-box;
}

.input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: #30363d;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-input:checked + .toggle-slider {
  background: #8b5cf6;
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
}

.hint {
  font-size: 12px;
  color: #484f58;
  margin-top: 4px;
  margin-left: 46px;
}

.textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
  color: #e6edf3;
  outline: none;
  resize: vertical;
}

.textarea:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.textarea::placeholder {
  color: #8b949e;
  font-family: inherit;
}

.divider {
  height: 1px;
  background: #30363d;
  margin: 12px 0;
}

/* Stats */
.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stats-total {
  font-size: 12px;
  font-weight: 600;
  color: #8b5cf6;
}

.stats-tiers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-tier-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.stats-tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stats-tier-name {
  width: 64px;
  color: #8b949e;
  text-transform: capitalize;
}

.stats-tier-bar {
  flex: 1;
  height: 6px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
}

.stats-tier-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.stats-tier-count {
  width: 24px;
  text-align: right;
  color: #e6edf3;
  font-weight: 500;
}

/* Share History */
.share-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 0;
}

.history-emoji {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.history-repo {
  flex: 1;
  color: #e6edf3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-tier {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.history-time {
  font-size: 10px;
  color: #8b949e;
  width: 24px;
  text-align: right;
}

/* Terminal Bridge */
.bridge-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bridge-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.bridge-checking {
  background: #21262d;
  color: #8b949e;
}

.bridge-connected {
  background: #0d2818;
  color: #3fb950;
}

.bridge-disconnected {
  background: #2d1b00;
  color: #d29922;
}

.hint code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  background: #21262d;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Usage Stats */
.usage-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

.usage-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: #21262d;
  border-radius: 8px;
}

.usage-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #8b5cf6;
}

.usage-stat-label {
  font-size: 10px;
  color: #8b949e;
  margin-top: 2px;
}

.footer-text {
  font-size: 12px;
  color: #484f58;
  text-align: center;
}

/* Custom Tools */
.custom-tools-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.add-tool-btn {
  background: #8b5cf6;
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.add-tool-btn:hover {
  background: #7c3aed;
}

.custom-tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #21262d;
  font-size: 13px;
}

.custom-tool-row:last-child {
  border-bottom: none;
}

.custom-tool-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.custom-tool-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-tool-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tool-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  color: #8b949e;
  border-radius: 4px;
}

.tool-action-btn:hover {
  background: #21262d;
  color: #e6edf3;
}

.tool-action-btn.delete:hover {
  color: #d1242f;
}

/* Tool Modal */
.tool-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-modal-content {
  background: #161b22;
  border-radius: 12px;
  padding: 20px;
  width: 260px;
}

.tool-modal-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #e6edf3;
}

.tool-field {
  margin-bottom: 10px;
}

.tool-field .label {
  margin-bottom: 4px;
}

.tool-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.tool-modal-actions .about-close-btn {
  flex: 1;
}

.tool-cancel-btn {
  flex: 1;
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.tool-cancel-btn:hover {
  background: #30363d;
}

.custom-tools-empty {
  font-size: 12px;
  color: #484f58;
  padding: 4px 0;
}
