:root {
  --accent-start: #FF9A56;
  --accent-end: #FF6B6B;
  --fg: #1A1A1A;
  --muted: #6C757D;
  --border: #E9ECEF;
  --input-bg: #FAFBFC;
  --valid: #10B981;
  --error: #DC3545;

  --unique: #10B981;
  --similar: #F59E0B;
  --duplicate: #F97316;
  --verbatim: #DC2626;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--sans);
  min-height: 100vh;
  background: linear-gradient(135deg, #FFF5E6 0%, #FFE4CC 25%, #FFD4B3 50%, #FFC299 75%, #FFB380 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  color: var(--fg);
  line-height: 1.5;
}

.main-container {
  width: 100%;
  max-width: 760px;
}

.form-card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end), var(--accent-start));
  background-size: 200% 100%;
  animation: shimmer 3s infinite;
}

@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.lang-switcher {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  gap: 4px;
  background: #F1F5F9;
  border-radius: 999px;
  padding: 3px;
  z-index: 1;
}
.lang-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.lang-button.active {
  background: white;
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--fg);
  text-align: center;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 14px;
}

.form-step { margin-bottom: 20px; }
.step-indicator { display: flex; align-items: center; margin-bottom: 10px; }
.step-number {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  margin-right: 12px;
  flex-shrink: 0;
}
.step-label { font-weight: 600; color: #495057; font-size: 14px; }

.input-wrapper { position: relative; }
input[type="url"] {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--mono);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  background: var(--input-bg);
}
input[type="url"]:focus {
  outline: none;
  border-color: var(--accent-start);
  background: white;
  box-shadow: 0 0 0 4px rgba(255, 154, 86, 0.1);
}
input[type="url"].valid { border-color: var(--valid); background: #F0FDF4; }
input[type="url"].error { border-color: var(--error); background: #FFF5F5; }

.error-message {
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s, max-height 0.25s;
}
.error-message.show { opacity: 1; max-height: 50px; }

.submit-button {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: white;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
  margin-top: 16px;
}
.submit-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(255, 154, 86, 0.3);
}
.submit-button:active:not(:disabled) { transform: translateY(0); }
.submit-button:disabled {
  background: #E5E7EB;
  color: #9CA3AF;
  cursor: not-allowed;
}

.secondary-button {
  padding: 10px 18px;
  background: white;
  color: var(--fg);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.secondary-button:hover { border-color: var(--accent-start); color: var(--accent-start); }

.error-banner {
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s, max-height 0.3s, margin-bottom 0.3s;
  pointer-events: none;
}
.error-banner.show { opacity: 1; max-height: 200px; pointer-events: auto; }
.error-icon { width: 20px; height: 20px; fill: #DC2626; flex-shrink: 0; margin-right: 12px; margin-top: 2px; }
.error-content { flex: 1; }
.error-title { color: #991B1B; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.error-text { color: #7F1D1D; font-size: 13px; line-height: 1.5; }

/* Results */
.result {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.score-hero {
  display: flex;
  gap: 32px;
  align-items: center;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, #FFF9F5, #FFF5ED);
  border: 1px solid #FFE4D6;
  margin-bottom: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.gauge {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}
.gauge-svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}
.gauge-track {
  fill: none;
  stroke: #F1F5F9;
  stroke-width: 14;
}
.gauge-value {
  fill: none;
  stroke: var(--accent-start);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 439.823;
  stroke-dashoffset: 439.823;
  transition: stroke-dashoffset 0.9s ease-out, stroke 0.4s;
}
.score-hero[data-verdict="unique"]    .gauge-value { stroke: var(--unique); }
.score-hero[data-verdict="similar"]   .gauge-value { stroke: var(--similar); }
.score-hero[data-verdict="duplicate"] .gauge-value { stroke: var(--duplicate); }
.score-hero[data-verdict="verbatim"]  .gauge-value { stroke: var(--verbatim); }

.gauge-center {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge-number {
  font-size: 36px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}
.gauge-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 600;
}

.verdict-column {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.verdict-pill {
  display: inline-block;
  align-self: flex-start;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  background: #E5E7EB;
  color: #374151;
}
.score-hero[data-verdict="unique"]    .verdict-pill { background: #D1FAE5; color: #065F46; }
.score-hero[data-verdict="similar"]   .verdict-pill { background: #FEF3C7; color: #92400E; }
.score-hero[data-verdict="duplicate"] .verdict-pill { background: #FED7AA; color: #9A3412; }
.score-hero[data-verdict="verbatim"]  .verdict-pill { background: #FECACA; color: #991B1B; }

.verdict-explanation {
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (min-width: 640px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
.metric {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
}
.metric-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
}
.metric-bar {
  width: 100%;
  height: 8px;
  background: #F1F5F9;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.metric-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  border-radius: 999px;
  transition: width 0.8s ease-out, background 0.3s;
}
.metric-bar-fill[data-level="unique"]    { background: var(--unique); }
.metric-bar-fill[data-level="similar"]   { background: var(--similar); }
.metric-bar-fill[data-level="duplicate"] { background: var(--duplicate); }
.metric-bar-fill[data-level="verbatim"]  { background: var(--verbatim); }
.metric-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
}
.stat-number {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.urls {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 20px;
  background: #F8F9FA;
  border-radius: 8px;
  padding: 12px 14px;
}
.urls > div { margin: 3px 0; }
.urls strong { color: var(--fg); margin-right: 4px; }

.matches-section { margin-bottom: 20px; }
.matches-section h2 {
  font-size: 15px;
  font-weight: 600;
  color: #495057;
  margin-bottom: 12px;
}
.matches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.matches li {
  background: #FFFBEB;
  border: 1px solid #FEF3C7;
  border-radius: 10px;
  padding: 12px 14px;
}
.match-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.match-quote {
  margin: 0;
  padding: 0;
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
  border: 0;
  background: transparent;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.muted { color: var(--muted); font-size: 13px; }

.info-section {
  margin-top: 32px;
  padding: 20px;
  background: linear-gradient(135deg, #FFF9F5, #FFF5ED);
  border-radius: 12px;
  border: 1px solid #FFE4D6;
}
.info-title {
  font-weight: 600;
  margin-bottom: 12px;
  color: #495057;
  font-size: 14px;
  display: flex;
  align-items: center;
}
.info-icon { width: 18px; height: 18px; margin-right: 8px; fill: var(--accent-start); }
.info-list { list-style: none; font-size: 13px; color: var(--muted); line-height: 1.8; }
.info-list li { padding-left: 20px; position: relative; }
.info-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--valid);
  font-weight: bold;
}

.footnote {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
}
.footnote p { margin: 0 0 6px; }
.footnote-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.footnote-links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  padding-bottom: 1px;
}
.footnote-links a:hover { color: var(--accent-start); border-bottom-color: var(--accent-start); }

/* Legal pages */
.legal-card {
  padding-top: 56px;
}
.breadcrumb {
  margin-bottom: 16px;
  font-size: 13px;
}
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--accent-start); }
.legal-card h1 {
  text-align: left;
  font-size: 24px;
  margin-bottom: 4px;
}
.legal-card .subtitle {
  text-align: left;
  margin-bottom: 24px;
}
.legal-body h2 {
  font-size: 16px;
  font-weight: 700;
  color: #1A1A1A;
  margin: 24px 0 8px;
}
.legal-body p {
  color: #374151;
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 10px;
}
.legal-body ul {
  margin: 0 0 10px 20px;
  padding: 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.65;
}
.legal-body li {
  margin-bottom: 4px;
}
.legal-body code {
  font-family: var(--mono);
  background: #F1F5F9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}
.legal-body a {
  color: var(--accent-end);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.legal-body a:hover { color: var(--accent-start); }

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s;
}
.loading-overlay.show { display: flex; opacity: 1; }
.loading-card {
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 320px;
  transform: scale(0.95);
  transition: transform 0.25s;
}
.loading-overlay.show .loading-card { transform: scale(1); }
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--accent-start);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}
.loading-text { color: #495057; font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.loading-subtext { color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  .form-card { padding: 24px 20px; }
  h1 { font-size: 22px; }
  .lang-switcher { top: 16px; right: 16px; }
  .score-hero { flex-direction: column; gap: 18px; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat:last-child { grid-column: 1 / -1; }
}
