:root {
  --color-bg: #fafafa;
  --color-text: #222;
  --color-muted: #888;
  --color-border: #e0e0e0;
  --color-accent: #2563eb;
  --color-like: #e11d48;
  --color-dislike: #2563eb;
  --color-error: #dc2626;
  --max-width: 880px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.55;
}

.hidden { display: none !important; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--color-accent);
  text-decoration: none;
}

.search-form {
  flex: 1;
  display: flex;
  gap: 6px;
}

.search-form input[type="search"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.95rem;
}

.search-form button {
  padding: 6px 14px;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}

.ghost {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text);
}

.ad-slot {
  min-height: 90px;
  margin: 16px auto;
  max-width: var(--max-width);
  background: repeating-linear-gradient(45deg, #f0f0f0 0 8px, #f7f7f7 8px 16px);
  border: 1px dashed var(--color-border);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.ad-slot::before {
  content: "広告枠";
}

.status {
  margin: 12px 0;
  padding: 8px 12px;
  background: #fffbe6;
  border: 1px solid #f1d870;
  border-radius: 4px;
  font-size: 0.9rem;
}

.status[data-kind="error"] {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--color-error);
}

.install-hint {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 16px;
  margin: 16px 0;
}

.search-results h2,
.person-header h2 {
  margin: 16px 0 8px;
  font-size: 1.2rem;
}

.search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results li {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.search-results a {
  color: var(--color-accent);
  text-decoration: none;
}

.search-results a:hover {
  text-decoration: underline;
}

.person-header {
  margin: 16px 0;
}

.person-stats {
  font-size: 0.9rem;
  color: var(--color-muted);
  display: flex;
  gap: 16px;
}

.person-controls {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.9rem;
}

.person-controls input[type="search"] {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  flex: 1;
  min-width: 160px;
}

.person-controls select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

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

.comments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment {
  background: #fff;
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  border-radius: 4px;
  padding: 10px 14px;
  margin: 8px 0;
}

.comment.side-like { border-left-color: var(--color-like); }
.comment.side-dislike { border-left-color: var(--color-dislike); }
.comment.side-unknown { border-left-color: var(--color-muted); }

.comment-meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.comment-meta .number {
  font-weight: 600;
  color: var(--color-muted);
}

.comment .side-badge {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: #f0f0f0;
}

.comment.side-like .side-badge { background: #fee2e2; color: #b91c1c; }
.comment.side-dislike .side-badge { background: #dbeafe; color: #1e40af; }

.comment-body {
  white-space: pre-wrap;
  word-break: break-word;
}

dialog#settings-dialog {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  min-width: min(420px, 90vw);
}

dialog#settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
}

dialog#settings-dialog h2 {
  margin: 0 0 12px;
}

dialog#settings-dialog label {
  display: block;
  margin: 12px 0;
}

dialog#settings-dialog input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: monospace;
  margin-top: 4px;
}

dialog#settings-dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 16px 0 0;
}

dialog#settings-dialog menu button {
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
}

dialog#settings-dialog menu button#settings-save {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.site-footer {
  margin-top: 32px;
  padding: 16px 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  text-align: center;
}

/* タップターゲット & スマホ調整 (Phase 1 は PC 限定だが、表示は崩れない範囲で) */
@media (max-width: 640px) {
  :root { --max-width: 100%; }

  .site-header .container {
    gap: 8px;
  }

  .brand {
    width: 100%;
    text-align: left;
  }

  .search-form {
    order: 2;
    flex-basis: 100%;
  }

  #settings-btn {
    margin-left: auto;
  }

  .search-form input[type="search"],
  .search-form button,
  .ghost,
  .person-controls input[type="search"],
  .person-controls select {
    font-size: 16px; /* iOS のズーム抑制 */
    min-height: 40px;
  }

  .person-controls {
    gap: 8px;
  }

  .person-controls label {
    flex: 0 0 auto;
    padding: 8px 4px;
  }

  .person-controls input[type="search"] {
    flex-basis: 100%;
  }

  .comment {
    padding: 8px 10px;
  }

  .comment-meta {
    flex-wrap: wrap;
  }

  .ad-slot {
    margin: 12px 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f1115;
    --color-text: #e5e7eb;
    --color-muted: #9ca3af;
    --color-border: #2a2f3a;
    --color-accent: #60a5fa;
    --color-like: #fb7185;
    --color-dislike: #60a5fa;
  }
  .site-header { background: #161a22; }
  .comment { background: #161a22; }
  dialog#settings-dialog { background: #161a22; }
  dialog#settings-dialog menu button { background: #161a22; color: var(--color-text); }
  .status { background: #2a2410; border-color: #5a4a1a; color: var(--color-text); }
  .install-hint { background: #0e1f2c; border-color: #1e3a52; }
  .comment .side-badge { background: #1e2230; color: var(--color-muted); }
  .comment.side-like .side-badge { background: #3b1419; color: #fecaca; }
  .comment.side-dislike .side-badge { background: #102237; color: #bfdbfe; }
  .ad-slot {
    background: repeating-linear-gradient(45deg, #1a1d24 0 8px, #14171c 8px 16px);
  }
}

