:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-subtle: #f8f9fd;
  --text: #1c2333;
  --muted: #5c6784;
  --border: #e1e6f1;
  --primary: #3b5bdb;
  --primary-hover: #2f4bc0;
  --primary-contrast: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f6ec;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --dead: #9a3412;
  --dead-bg: #ffeadf;
  --error: #a61b3b;
  --error-bg: #ffe4ea;
  --skip: #5c6784;
  --skip-bg: #eef1f7;
  --shadow: 0 10px 30px rgb(28 35 51 / 8%);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --surface: #1a1f2b;
    --surface-subtle: #202636;
    --text: #e8ecf6;
    --muted: #9aa6c0;
    --border: #2c3446;
    --primary: #7c96ff;
    --primary-hover: #94a9ff;
    --primary-contrast: #11131a;
    --ok: #6ee7a8;
    --ok-bg: #123326;
    --warn: #ffd27a;
    --warn-bg: #3a2c0d;
    --dead: #ffb08a;
    --dead-bg: #3b1d10;
    --error: #ff9db3;
    --error-bg: #3c1420;
    --skip: #9aa6c0;
    --skip-bg: #262d3d;
    --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgb(59 91 219 / 10%), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN',
    'Hiragino Sans', 'Noto Sans JP', Meiryo, sans-serif;
  line-height: 1.6;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.1rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.logo {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7a5cff);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-privacy {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-privacy.is-deployed {
  background: var(--warn-bg);
  color: var(--warn);
}

.layout {
  display: grid;
  gap: 1.1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 1.1rem;
}

.step {
  display: inline-grid;
  width: 1.6rem;
  height: 1.6rem;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 0.8rem;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

/* Upload */

.dropzone {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 2.4rem 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-subtle);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  outline: none;
  transform: translateY(-1px);
}

.dropzone-icon {
  display: inline-grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  margin-top: 1rem;
}

.paste-panel {
  flex: 1 1 320px;
}

.paste-panel summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
}

.paste-panel textarea {
  width: 100%;
  margin: 0.6rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

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

.btn-secondary {
  border-color: var(--border);
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--primary);
}

/* Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
  padding: 0.75rem 0.9rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.3;
}

.stat-value.is-ok {
  color: var(--ok);
}
.stat-value.is-warn {
  color: var(--warn);
}
.stat-value.is-dead {
  color: var(--dead);
}
.stat-value.is-error {
  color: var(--error);
}
.stat-value.is-skip {
  color: var(--skip);
}

/* Tables */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.table-wrap-results {
  max-height: 65vh;
}

.result-table {
  min-width: 1050px;
}

.result-table .url-column,
.result-table .url-cell {
  width: 32%;
  min-width: 280px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.www-ok {
  color: var(--ok);
  font-weight: 600;
}

.numeric {
  text-align: right !important;
}

.url-cell {
  overflow-wrap: anywhere;
}

.url-cell code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.url-cell .url-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.url-cell .url-link:hover,
.url-cell .url-link:focus-visible {
  color: var(--primary);
  text-decoration-color: currentColor;
}

/* Sub panels */

.sub-panel {
  margin-top: 1rem;
}

.sub-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.sub-panel[open] summary {
  margin-bottom: 0.6rem;
}

.issue-list {
  display: grid;
  gap: 0.45rem;
}

.issue {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 0.84rem;
}

.issue .tag {
  flex: none;
}

.issue .line {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Options */

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  align-items: end;
}

.options-note {
  margin: 0.7rem 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
}

.select-field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.select-field select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.1rem;
}

/* Progress */

.progress {
  margin-top: 1.1rem;
}

.progress progress {
  width: 100%;
  height: 12px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-subtle);
  appearance: none;
}

.progress progress::-webkit-progress-bar {
  background: var(--surface-subtle);
  border-radius: 999px;
}

.progress progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--primary), #7a5cff);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--primary), #7a5cff);
  border-radius: 999px;
}

.progress p {
  margin-top: 0.45rem;
}

/* Results toolbar */

.result-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.2rem 0 0.8rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-contrast);
}

.search {
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 340px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}

.search:focus,
.paste-panel textarea:focus,
.select-field select:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 1px;
}

/* Cleanup selection */

.cleanup-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 0.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.cleanup-actions,
.cleanup-export {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.cleanup-panel .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.selection-count {
  font-size: 0.78rem;
  white-space: nowrap;
}

.copy-status {
  min-width: 6.5rem;
  font-size: 0.78rem;
}

.copy-status.is-error {
  color: var(--error);
}

.select-col {
  width: 44px;
  text-align: center;
}

.select-cell {
  text-align: center;
}

.select-col input,
.select-cell input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.result-table tr.is-selected td {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.result-table tr.is-focused {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.copy-fallback {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
}

/* Status pills */

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.status-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.status-dead {
  background: var(--dead-bg);
  color: var(--dead);
}
.status-error {
  background: var(--error-bg);
  color: var(--error);
}
.status-skipped,
.status-pending {
  background: var(--skip-bg);
  color: var(--skip);
}

.dup-mark {
  display: inline-block;
  margin-left: 0.35rem;
  border-radius: 4px;
  background: var(--warn-bg);
  color: var(--warn);
  padding: 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: 1px;
}

.results-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.downloads .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* Issues */

.issues-content {
  display: grid;
  gap: 1rem;
}

.issue-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 0.8rem 0.9rem;
}

.issue-group h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

.issue-group ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.84rem;
}

.issue-group li + li {
  margin-top: 0.25rem;
}

.tag {
  display: inline-block;
  border-radius: 5px;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-error {
  background: var(--error-bg);
  color: var(--error);
}

.tag-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.tag-info {
  background: var(--skip-bg);
  color: var(--skip);
}

/* Alert */

.alert {
  border: 1px solid var(--error);
  border-radius: 10px;
  background: var(--error-bg);
  color: var(--error);
  padding: 0.75rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.alert.is-info {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary);
}

/* Footer */

.site-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .card {
    padding: 1rem;
  }

  h1 {
    font-size: 1.1rem;
  }

  .result-toolbar {
    align-items: stretch;
  }

  .search {
    max-width: none;
  }
}
