/* Crab Cake — likely human content UI */

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

:root {
  --primary: #FF6B4A;
  --primary-dark: #D64A33;
  --secondary: #4CAF50;
  --background: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1f2b47;
  --text: #eee;
  --text-muted: #aaa;
  --error: #f44336;
  --warning: #FFC107;
  --border-radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Navigation */
.main-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface-light);
}

/* Footer */
.main-footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--surface-light);
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin: 1rem 0 0.5rem;
}

.hero .description {
  max-width: 500px;
  margin: 1rem auto 0;
  color: var(--text-muted);
}

/* API Warning */
.api-warning {
  background: var(--error);
  color: white;
  padding: 1rem;
  border-radius: var(--border-radius);
  text-align: center;
  margin-bottom: 2rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
}

/* Content Editor */
.content-editor {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 2rem;
}

.editor-header h2 {
  margin-bottom: 0.5rem;
}

.editor-header p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.editor-container textarea {
  width: 100%;
  background: var(--surface-light);
  border: 1px solid #333;
  border-radius: var(--border-radius);
  padding: 1rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 200px;
}

.editor-container textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.editor-container textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.editor-stats {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.editor-stats .divider {
  opacity: 0.5;
}

.editor-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.editor-error-msg {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.75rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

/* CAPTCHA */
.captcha-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0;
}

.captcha-step h2 {
  margin-bottom: 0.5rem;
}

.captcha-step > p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.captcha-container {
  background: var(--surface-light);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  max-width: 350px;
  margin: 0 auto 1.5rem;
  overflow: hidden;
}

.circle-captcha {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.circle-captcha__label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.circle-captcha__canvas {
  border-radius: var(--border-radius);
  cursor: crosshair;
  max-width: 100%;
  border: 1px solid #2a3a5a;
  display: block;
}

.circle-captcha__message {
  font-size: 0.85rem;
  color: var(--error);
  font-weight: 500;
}

.circle-captcha--verified {
  flex-direction: row;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid var(--secondary);
  border-radius: var(--border-radius);
  color: var(--secondary);
  font-weight: 600;
  font-size: 1rem;
}

.circle-captcha__check {
  font-size: 1.2rem;
}

.captcha-actions {
  margin-top: 1.5rem;
}

.captcha-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.captcha-icon {
  font-size: 1.5rem;
}

.captcha-question {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--border-radius);
}

.captcha-input-row {
  display: flex;
  gap: 0.5rem;
}

.captcha-input-row input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #333;
  border-radius: var(--border-radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.25rem;
  text-align: center;
}

.captcha-input-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.captcha-input-row button {
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  border: none;
  border-radius: var(--border-radius);
  color: white;
  cursor: pointer;
}

.captcha-input-row button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.captcha-input-row button:disabled {
  opacity: 0.5;
}

.captcha-refresh {
  margin-top: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
}

.captcha-refresh:hover {
  color: var(--text);
}

.captcha-error {
  color: var(--error);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.captcha-loading {
  color: var(--text-muted);
  padding: 2rem;
}

.captcha-verified {
  color: var(--secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.captcha-verified .checkmark {
  font-size: 1.25rem;
}

.captcha-success {
  color: var(--secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.check-icon {
  font-size: 1.5rem;
}

/* Circle CAPTCHA v2 */
.circle-captcha {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface-light);
  border-radius: var(--border-radius);
  border: 1px solid rgba(0, 188, 212, 0.2);
}

.circle-captcha-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
}

.captcha-label-error {
  color: var(--error);
}

/* Reference image row */
.captcha-ref-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.captcha-ref-item {
  position: relative;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: border-color 0.2s;
}

.captcha-ref-item.captcha-ref-done {
  border-color: var(--secondary);
  opacity: 0.6;
}

.captcha-ref-img {
  display: block;
  width: 90px;
  height: 90px;
  object-fit: cover;
  user-select: none;
  draggable: false;
}

.captcha-ref-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--secondary);
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Challenge image */
.captcha-challenge-img {
  display: block;
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  cursor: crosshair;
  user-select: none;
  border: 1px solid rgba(0, 188, 212, 0.3);
  transition: opacity 0.15s;
}

.captcha-challenge-img:hover {
  opacity: 0.93;
}

/* Keep old class used by parent */
.circle-captcha-img {
  display: block;
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  cursor: crosshair;
  user-select: none;
  border: 1px solid rgba(0, 188, 212, 0.3);
  transition: opacity 0.15s;
}

.circle-captcha-img:hover {
  opacity: 0.93;
}

.circle-captcha-img.circle-captcha-missed {
  opacity: 0.4;
  cursor: not-allowed;
}

.captcha-locked {
  color: var(--error);
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

.captcha-challenge-wrap {
  position: relative;
  max-width: 500px;
  width: 100%;
}

/* Prep phase: same footprint as 600×300 challenge image, no challenge preview */
.captcha-prep-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  aspect-ratio: 600 / 300;
  max-height: 70vh;
  border-radius: 4px;
  border: 1px solid rgba(0, 188, 212, 0.25);
  background: var(--surface);
  box-sizing: border-box;
}

.captcha-prep-num {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.captcha-prep-hint {
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.captcha-wait-page {
  text-align: center;
  padding: 1.5rem 1rem;
  max-width: 420px;
  margin: 0 auto;
}

.captcha-wait-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.captcha-wait-text {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.captcha-wait-timer {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  line-height: 1.2;
}

.captcha-wait-sub {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Success State */
.editor-success {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--secondary);
  color: white;
  font-size: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.shortcode-display {
  background: var(--surface-light);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.shortcode-display label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.shortcode {
  font-size: clamp(0.95rem, 2.5vw, 1.25rem);
  font-weight: 600;
  font-family: monospace;
  color: var(--primary);
  margin-bottom: 1rem;
  word-break: break-all;
  line-height: 1.4;
  max-width: 100%;
}

.copy-btn {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: var(--border-radius);
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--primary);
  color: white;
}

.result-details {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-item .label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.result-item .value {
  font-weight: 600;
}

.pattern-typed {
  color: var(--secondary);
}

.pattern-mixed {
  color: var(--warning);
}

.pattern-pasted {
  color: var(--text-muted);
}

.certificate-block {
  text-align: center;
  margin: 2rem 0;
  padding: 1.5rem 0;
  border-top: 1px solid var(--surface-light);
  border-bottom: 1px solid var(--surface-light);
}

.certificate-heading {
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.certificate-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.certificate-preview {
  max-width: 334px;
  margin: 0 auto 1rem;
}

.certificate-preview img {
  width: 100%;
  height: auto;
  max-width: 334px;
  border-radius: var(--border-radius);
  display: block;
}

.certificate-image-link {
  display: inline-block;
  text-decoration: none;
}

.certificate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 0;
}

.embed-snippet {
  margin-top: 1.5rem;
}

.success-hint {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Error State */
.editor-error {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
}

.error-icon {
  width: 80px;
  height: 80px;
  background: var(--error);
  color: white;
  font-size: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.error-message {
  color: var(--error);
  margin-bottom: 1.5rem;
}

/* Submitting State */
.editor-submitting {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 3rem;
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Verify Page */
.verify-content {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 2rem;
}

.verify-header {
  text-align: center;
  margin-bottom: 2rem;
}

.verify-header h2 {
  margin-bottom: 0.5rem;
}

.verify-header p {
  color: var(--text-muted);
}

.verify-form {
  max-width: 500px;
  margin: 0 auto 2rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #333;
  border-radius: var(--border-radius);
  background: var(--surface-light);
  color: var(--text);
  font-size: 1rem;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.input-group button {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  border: none;
  border-radius: var(--border-radius);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.input-group button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.input-group button:disabled {
  opacity: 0.5;
}

.verify-error {
  text-align: center;
  color: var(--error);
  margin-bottom: 1rem;
}

/* Verify Result */
.verify-result {
  background: var(--surface-light);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.verify-result.verified {
  border: 2px solid var(--secondary);
}

.verify-result.not-found {
  border: 2px solid var(--error);
}

.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.badge {
  background: var(--surface);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-card {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
}

.card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.confidence-bar {
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.content-preview-section {
  border-top: 1px solid var(--surface);
  padding-top: 1rem;
}

.content-preview-section h4 {
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.content-preview {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.content-meta {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.not-found-message {
  text-align: center;
  padding: 2rem;
}

.not-found-icon {
  display: block;
  font-size: 3rem;
  color: var(--error);
  margin-bottom: 1rem;
}

/* Verify Snippet */
.verify-snippet {
  background: var(--surface-light);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.verify-snippet label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.snippet-box {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.snippet-box code {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--primary);
  word-break: break-all;
}

.snippet-box code.snippet-multiline {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

/* Responsive */
@media (max-width: 600px) {
  .main-content {
    padding: 1rem;
  }

  .main-nav {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .result-details {
    flex-direction: column;
    gap: 1rem;
  }

  .input-group {
    flex-direction: column;
  }

  .input-group button {
    width: 100%;
  }
}
