:root {
  color-scheme: light;
  --bg: #f9fafb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1f2937;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --grade-a: #10b981;
  --grade-b: #22c55e;
  --grade-c: #f59e0b;
  --grade-d: #f97316;
  --grade-f: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Noto Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 18px 30px -40px rgba(15, 23, 42, 0.35);
}

.title {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.subtitle {
  margin: 0 0 24px 0;
  color: var(--muted);
  font-size: 15px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

input[type="text"] {
  flex: 1 1 420px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
}

button {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  background: #374151;
  border-color: #374151;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.muted-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.muted-link:hover {
  color: var(--text);
}

.section {
  margin-top: 24px;
}

.section h2 {
  font-size: 18px;
  margin: 0 0 12px 0;
}

.section h3 {
  font-size: 16px;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

.meta-label {
  color: var(--muted);
}

.url-text {
  word-break: break-all;
}

/* Dashboard */
.dashboard {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-top: 16px;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 4px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.score-circle.grade-a { border-color: var(--grade-a); }
.score-circle.grade-b { border-color: var(--grade-b); }
.score-circle.grade-c { border-color: var(--grade-c); }
.score-circle.grade-d { border-color: var(--grade-d); }
.score-circle.grade-f { border-color: var(--grade-f); }

.score-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.score-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.dashboard-info {
  flex: 1;
}

.grade-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
}

.grade-badge.grade-a { background: var(--grade-a); }
.grade-badge.grade-b { background: var(--grade-b); }
.grade-badge.grade-c { background: var(--grade-c); }
.grade-badge.grade-d { background: var(--grade-d); }
.grade-badge.grade-f { background: var(--grade-f); }

.grade-label {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}

.summary-text {
  color: var(--muted);
  font-size: 14px;
}

/* Score Breakdown */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.breakdown-item {
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.breakdown-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Info Tip (CSS tooltip using data-tip attribute) */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 10px;
  cursor: help;
  transition: all 0.2s ease;
}

.info-tip:hover {
  background: var(--accent);
  color: white;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.info-tip:hover::after {
  opacity: 1;
  visibility: visible;
}

.breakdown-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #475569);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.breakdown-value {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* Issue Groups */
.issue-group {
  margin-bottom: 16px;
  border-radius: 10px;
  padding: 16px;
}

.issue-critical {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
}

.issue-warning {
  background: var(--warning-bg);
  border: 1px solid #fed7aa;
}

.issue-good {
  background: var(--success-bg);
  border: 1px solid #a7f3d0;
}

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

.issue-icon {
  font-size: 16px;
}

.issue-title {
  font-weight: 600;
  font-size: 14px;
}

.issue-critical .issue-title { color: var(--danger); }
.issue-warning .issue-title { color: var(--warning); }
.issue-good .issue-title { color: var(--success); }

.issue-list {
  margin: 0;
  padding-left: 24px;
  font-size: 14px;
}

.issue-list li {
  margin-bottom: 4px;
}

/* Crawler Grid */
.crawler-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.crawler-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.crawler-name {
  font-size: 14px;
  font-weight: 500;
}

.crawler-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.status-allow {
  background: var(--success-bg);
  color: var(--success);
}

.status-disallow {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-unspecified {
  background: #f1f5f9;
  color: var(--muted);
}

/* Schema.org */
.schema-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.schema-badge {
  padding: 6px 12px;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #5b21b6;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.schema-feature {
  margin-top: 12px;
  font-size: 14px;
  color: var(--success);
}

.feature-icon {
  margin-right: 6px;
}

/* Readability */
.readability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.readability-item {
  text-align: center;
  padding: 20px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.readability-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.readability-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.readability-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

/* Quotable Sentences */
.quotable-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quotable-item {
  padding: 16px;
  background: linear-gradient(135deg, #fef3c7, #fef9c3);
  border: 1px solid #fcd34d;
  border-radius: 10px;
}

.quotable-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  margin-bottom: 6px;
}

.quotable-text {
  font-size: 14px;
  font-style: italic;
  color: var(--text);
}

/* Success text */
.success-text {
  color: var(--success);
}

.surface-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.surface-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
}

.score {
  font-size: 32px;
  font-weight: 600;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}

.tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tooltip:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tooltip-content {
  display: none;
  position: absolute;
  left: 22px;
  top: -6px;
  width: 280px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 12px 24px -18px rgba(15, 23, 42, 0.5);
  z-index: 10;
}

.tooltip:hover + .tooltip-content,
.tooltip:focus + .tooltip-content {
  display: grid;
  gap: 6px;
}

.example {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
}

.example-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.loading {
  display: none;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.loading.active {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.loading-overlay.active {
  display: flex;
}

.loading-card {
  width: min(520px, 92vw);
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: 0 28px 40px -30px rgba(15, 23, 42, 0.55);
}

.loading-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.loading-bar {
  height: 10px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.loading-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #111827, #334155);
  transition: width 0.2s ease-out;
}

.loading-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}

.loading-message {
  text-align: right;
}

.loading-disclaimer {
  margin-top: 18px;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  transition: color 0.2s ease;
}

details summary:hover {
  color: var(--text);
}

details[open] summary {
  margin-bottom: 12px;
}

/* Home Page (Google-style) */
.home-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  padding-top: 12vh;
}

.home-hero {
  margin-bottom: 12px;
  width: 100%;
  max-width: 720px;
}

.hero-image {
  max-width: 720px;
  width: 100%;
  height: auto;
  display: block;
  mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%),
              linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
  mask-composite: intersect;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%),
                      linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
  -webkit-mask-composite: source-in;
}

.home-card {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.home-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.home-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 28px 0;
}

.home-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 720px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 720px;
}

.search-input {
  flex: 1;
  padding: 18px 24px;
  border-radius: 28px;
  border: 1px solid #dfe1e5;
  font-size: 17px;
  color: var(--text);
  background: var(--panel);
  box-shadow: none;
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.search-input:invalid,
.search-input:required {
  box-shadow: none;
  border-color: #dfe1e5;
  outline: none;
}

.search-input:hover {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  border-color: rgba(223, 225, 229, 0);
}

.search-input:focus {
  outline: none;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  border-color: rgba(223, 225, 229, 0);
}

.search-buttons {
  display: flex;
  gap: 12px;
}

.search-btn {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background: #374151;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.search-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.search-btn svg {
  width: 26px;
  height: 26px;
}

.home-links {
  margin-top: 28px;
}

/* Section Intro */
.section-intro {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Issue Guide (Collapsible) */
.issue-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.issue-text {
  font-size: 14px;
}

.issue-guide {
  margin-top: 8px;
  margin-left: 0;
}

.issue-guide summary {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  display: inline-block;
}

.issue-guide summary:hover {
  text-decoration: underline;
  background: rgba(255, 255, 255, 0.9);
}

.guide-content {
  margin-top: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.guide-content p {
  margin: 0 0 10px 0;
}

.guide-content p:last-child {
  margin-bottom: 0;
}

.guide-solution {
  font-weight: 500;
  color: var(--accent);
}

.guide-code {
  margin: 10px 0;
  padding: 12px 14px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
}

.guide-tips {
  white-space: pre-line;
  color: var(--muted);
}

/* Crawler Info (with company name) */
.crawler-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crawler-company {
  font-size: 11px;
  color: var(--muted);
}

.status-icon {
  margin-right: 4px;
}

/* Readability Description */
.readability-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* Result Page Navigation */
.result-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-back {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
}

.nav-back:hover {
  background: var(--bg);
  border-color: var(--accent);
}

/* Health Grid (Content Health section) */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.health-item {
  background: #f8fafc;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.health-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.health-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* Section Details (collapsible) */
.section-details {
  margin-top: 8px;
}

.section-details summary {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.section-details summary:hover {
  color: var(--text);
}

.details-content {
  margin-top: 12px;
}

/* Optimization List */
.optimization-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.optimization-item {
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 10px;
  padding: 14px 16px;
}

.optimization-action {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.optimization-reason {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.optimization-tag {
  background: #fef9c3;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

/* Responsive */
@media (max-width: 640px) {
  .dashboard {
    flex-direction: column;
    text-align: center;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-label {
    font-weight: 500;
    margin-top: 8px;
  }

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .crawler-grid {
    grid-template-columns: 1fr;
  }

  .readability-grid {
    grid-template-columns: 1fr;
  }

  .guide-code {
    font-size: 11px;
    padding: 10px 12px;
  }

  .home-container {
    padding-top: 5vh;
  }

  .home-hero {
    max-width: 100%;
  }

  .hero-image {
    max-width: 100%;
  }

  .search-box {
    max-width: 100%;
    gap: 10px;
  }

  .search-input {
    padding: 14px 18px;
    font-size: 16px;
    border-radius: 24px;
  }

  .search-btn {
    width: 48px;
    height: 48px;
  }

  .search-btn svg {
    width: 22px;
    height: 22px;
  }
}
