* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #141414;
  color: #fff;
  min-height: 100vh;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.app-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #444;
  margin-bottom: 1rem;
}

.status {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.status-pill {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #2a2a2a;
  color: #555;
}

.status.live  .status-pill { background: #0a2e18; color: #00c850; }
.status.error .status-pill { background: #2e0a0a; color: #f44336; }
.status.warn  .status-pill { background: #2e1f00; color: #ffaa00; }

.content {
  width: 100%;
  max-width: 480px;
}

@media (min-width: 520px) {
  .content { max-width: 640px; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 0;
  color: #555;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (min-width: 520px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: #1e1e1e;
  border-radius: 14px;
  padding: 1.5rem 0.75rem 0;
  cursor: pointer;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.card.active      { border-color: #00c850; }
.card.unreachable { border-color: #f5a623; }

.card-warning {
  font-size: 0.6rem;
  color: #f5a623;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}
.card:active { opacity: 0.6; }

.card.placeholder {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.card-thumb {
  display: none;
  width: calc(100% + 1.5rem);
  margin: -1.5rem -0.75rem 0.75rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.card-number {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
}

.card-name {
  font-size: 0.65rem;
  color: #999;
  text-align: center;
  margin-top: 0.4rem;
  margin-bottom: 1.25rem;
  word-break: break-word;
  padding: 0 0.25rem;
}

.color-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 7px;
}

.nav {
  display: flex;
  gap: 1rem;
  margin-top: 1.25rem;
}

.nav-btn {
  flex: 1;
  padding: 0.9rem 2rem;
  background: #1e1e1e;
  color: #fff;
  border: 2px solid #333;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: opacity 0.1s;
}

.nav-btn:active { opacity: 0.6; }

.color-bar.active   { background: #00c850; }
.color-bar.loaded   { background: #505050; }
.color-bar.conflict { background: #f44336; }

.settings-toggle {
  flex: 0 0 3.2rem;
  padding: 0.9rem 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-toggle.active {
  border-color: #00c850;
  color: #00c850;
}

.settings-panel {
  margin-top: 1rem;
  background: #1e1e1e;
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-label {
  font-size: 0.8rem;
  color: #aaa;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  height: 0.9rem;
  color: #555;
  cursor: help;
  flex-shrink: 0;
  user-select: none;
  transition: color 0.15s;
}

.help-icon:hover { color: #aaa; }

.help-icon svg {
  width: 100%;
  height: 100%;
}

.number-input {
  display: flex;
  align-items: center;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden;
}

.number-input input[type=number]::-webkit-inner-spin-button,
.number-input input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
.number-input input[type=number] { -moz-appearance: textfield; }

.num-btn {
  padding: 0.4rem 0.65rem;
  background: transparent;
  border: none;
  color: #777;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.num-btn:active { background: #333; color: #fff; }

.settings-input {
  width: 3.5rem;
  background: transparent;
  border: none;
  color: #fff;
  padding: 0.4rem 0.25rem;
  font-size: 0.9rem;
  text-align: center;
}

.settings-row.vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.settings-segmented {
  display: flex;
  width: 100%;
  background: #2a2a2a;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #666;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn.active {
  background: #1e1e1e;
  color: #00c850;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  display: block;
  width: 2.75rem;
  height: 1.5rem;
  background: #333;
  border-radius: 999px;
  transition: background 0.2s;
  position: relative;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1.125rem;
  height: 1.125rem;
  background: #888;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: #0a2e18;
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  background: #00c850;
  transform: translateX(1.25rem);
}

.settings-save {
  flex: unset;
  align-self: flex-end;
  padding: 0.6rem 1.5rem;
  font-size: 0.85rem;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: #141414;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.25rem;
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  max-width: 280px;
}

.auth-input {
  width: 100%;
  background: #1e1e1e;
  border: 2px solid #333;
  border-radius: 12px;
  color: #fff;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  text-align: center;
  outline: none;
  font-family: inherit;
}

.auth-input:focus { border-color: #555; }

.auth-error-text {
  text-align: center;
  font-size: 0.75rem;
  color: #f44336;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.auth-shake { animation: auth-shake 0.35s ease-in-out; }

.settings-secret-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.settings-secret-input {
  flex: 1;
  width: auto;
  text-align: left;
}

.settings-generate {
  flex: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.settings-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #2a2a2a;
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  font-family: monospace;
  resize: vertical;
  min-height: 4.5rem;
}

.comp-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #2a2a2a;
}

.comp-section-label:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.comp-slot-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #999;
  margin-top: 0.9rem;
  letter-spacing: 0.04em;
}

.comp-copy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.comp-action-label {
  font-size: 0.7rem;
  color: #666;
  width: 3.25rem;
  flex-shrink: 0;
}

.comp-value {
  flex: 1;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  font-size: 0.7rem;
  color: #ccc;
  background: #2a2a2a;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.comp-hint {
  font-size: 0.65rem;
  color: #555;
  line-height: 1.4;
}
