@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

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

:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --border: #d0d7de;
  --border-muted: #e8ecf0;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-light: #8c959f;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --success: #1a7f37;
  --success-bg: #dafbe1;
  --danger: #cf222e;
  --danger-bg: #fff0ee;
  --warning: #9a6700;
  --warning-bg: #fff8c5;
  --merge: #8250df;
  --merge-bg: #fbefff;
  --added: #e6ffec;
  --added-border: #b7f0c0;
  --removed: #ffebe9;
  --removed-border: #ffc1ba;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: 'Noto Sans JP', -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===== TOP BAR ===== */
.topbar {
  background: #24292f;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.5px;
}
.topbar-logo span { color: #58a6ff; }
.topbar-repo {
  font-size: 12px;
  color: #8b949e;
  margin-left: 4px;
}
.topbar-badge {
  margin-left: auto;
  background: #388bfd26;
  color: #58a6ff;
  border: 1px solid #388bfd4d;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-family: 'Space Mono', monospace;
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== PR HEADER ===== */
.pr-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.pr-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.pr-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
}
.pr-number {
  color: var(--text-muted);
  font-weight: 400;
}
.pr-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-open { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3b8; }
.badge-merged { background: var(--merge-bg); color: var(--merge); border: 1px solid #d8b4fe; }
.badge-closed { background: #f6f8fa; color: var(--text-muted); border: 1px solid var(--border); }
.pr-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.pr-meta strong { color: var(--text); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
  flex-shrink: 0;
  position: sticky;
  top: 45px;
  z-index: 90;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: #fd8c73;
  font-weight: 600;
}
.tab-count {
  background: var(--surface);
  border-radius: 20px;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.tab-btn.active .tab-count {
  background: #e8ecf0;
  color: var(--text);
}

/* ===== CONTENT ===== */
.tab-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== CONVERSATION ===== */
.timeline-item {
  display: flex;
  gap: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.av-blue { background: #0969da; }
.av-green { background: #1a7f37; }
.av-orange { background: #bc4c00; }
.av-purple { background: #8250df; }

.comment-box {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.comment-header {
  background: var(--surface);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}
.comment-author {
  font-weight: 600;
  font-size: 13px;
}
.comment-time {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: auto;
}
.comment-body {
  padding: 12px;
  line-height: 1.6;
  font-size: 13px;
}
.comment-body code {
  font-family: 'Space Mono', monospace;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.event-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 4px;
}

/* ===== REVIEW ACTION AREA ===== */
.review-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.review-panel-header {
  background: var(--surface);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.review-panel-body {
  padding: 14px;
}
.review-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 80px;
  transition: border-color 0.15s;
}
.review-textarea:focus { border-color: var(--accent); }
.review-textarea::placeholder { color: var(--text-light); }
.review-options {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.radio-option:hover { background: var(--surface); }
.radio-option.selected { border-color: var(--accent); background: #f0f6ff; }
.radio-option input { margin-top: 2px; accent-color: var(--accent); }
.radio-label { font-size: 13px; font-weight: 600; }
.radio-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.review-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:active { opacity: 0.85; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn-success:hover { opacity: 0.9; }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-merge {
  background: var(--merge);
  border-color: var(--merge);
  color: #fff;
}
.btn-default {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FILES CHANGED ===== */
.file-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.file-header {
  background: var(--surface);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.file-name {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  flex: 1;
}
.file-stats {
  font-size: 12px;
  display: flex;
  gap: 6px;
}
.stat-add { color: var(--success); font-weight: 700; font-family: 'Space Mono', monospace; }
.stat-del { color: var(--danger); font-weight: 700; font-family: 'Space Mono', monospace; }
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
}
.diff-table tr.added td { background: var(--added); }
.diff-table tr.removed td { background: var(--removed); }
.diff-table tr.context td { background: var(--bg); }
.diff-table td {
  padding: 2px 8px;
  line-height: 1.5;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-all;
}
.diff-table td.ln {
  color: var(--text-light);
  text-align: right;
  min-width: 28px;
  user-select: none;
  border-right: 1px solid var(--border-muted);
  padding: 2px 6px;
  font-size: 11px;
}
.diff-table td.sign {
  width: 14px;
  padding: 2px 4px;
  user-select: none;
  font-weight: 700;
}
.diff-table tr.added td.sign { color: var(--success); }
.diff-table tr.removed td.sign { color: var(--danger); }
.diff-table tr.hunk td {
  background: #e8f3ff;
  color: var(--accent);
  padding: 3px 8px;
}

/* ===== INLINE COMMENT ===== */
.inline-comment-row td {
  padding: 0 !important;
  background: #f0f6ff !important;
}
.inline-comment-container {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.inline-comment-input {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.inline-textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: inherit;
  font-size: 12px;
  resize: none;
  min-height: 60px;
  outline: none;
  background: var(--bg);
}
.inline-textarea:focus { border-color: var(--accent); }
.add-comment-btn {
  background: none;
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}
.add-comment-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }

/* ===== MERGE PANEL ===== */
.merge-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.merge-panel.ready { border-color: var(--success); background: var(--success-bg); }
.merge-panel.needs-review { border-color: var(--warning); background: var(--warning-bg); }
.merge-panel.merged { border-color: var(--merge); background: var(--merge-bg); }
.merge-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.merge-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

/* ===== CHECKLIST ===== */
.checklist { list-style: none; text-align: left; margin-bottom: 14px; }
.checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.check-icon { font-size: 15px; }

/* ===== STEP PROGRESS ===== */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.progress-bar::-webkit-scrollbar { display: none; }
.step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}
.step.active { color: var(--accent); font-weight: 600; }
.step.done { color: var(--success); }
.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.step.active .step-num { background: var(--accent); color: #fff; }
.step.done .step-num { background: var(--success); color: #fff; }
.step-arrow {
  color: var(--border);
  margin: 0 4px;
  font-size: 12px;
}

/* ===== INLINE COMMENT DISPLAY ===== */
.inline-comments-list {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inline-comment-item {
  display: flex;
  gap: 8px;
  background: #f0f6ff;
  border-radius: var(--radius);
  padding: 8px;
  border: 1px solid #cce0ff;
}
.inline-comment-text {
  font-size: 12px;
  line-height: 1.5;
  flex: 1;
}
.inline-comment-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== SUCCESS ANIMATION ===== */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.anim-in { animation: slideIn 0.25s ease; }

.merged-banner {
  background: var(--merge-bg);
  border: 1px solid #d8b4fe;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  animation: slideIn 0.3s ease;
}
.merged-banner .icon { font-size: 32px; margin-bottom: 8px; }
.merged-banner h3 { color: var(--merge); font-size: 16px; margin-bottom: 4px; }
.merged-banner p { font-size: 13px; color: var(--text-muted); }

/* ===== TOOLTIP ===== */
.hint-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: #92400e;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.5;
}
.hint-box .hint-icon { flex-shrink: 0; font-size: 14px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-sheet {
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 16px;
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title { font-weight: 700; font-size: 16px; margin-bottom: 14px; }