:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f242c;
  --border: #2a313c;
  --border-strong: #3a414d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #5b8cff;
  --accent-hover: #7aa3ff;
  --accent-text: #ffffff;
  --danger: #f85149;
  --success: #3fb950;
  --warn: #d29922;
  --radius: 8px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --surface-2: #ffffff;
    --border: #d0d7de;
    --border-strong: #afb8c1;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #2f6feb;
    --accent-hover: #1c5ce6;
    --shadow: 0 6px 24px rgba(140, 149, 159, 0.2);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0 0 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1em;
}

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

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}
.user-chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.05s ease;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
}
.btn-lg {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
}
.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

/* Inputs */
.input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.2);
}
.input-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  width: auto;
}

/* Layout */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.loading {
  text-align: center;
  color: var(--muted);
  padding: 4rem 0;
}

/* Hero */
.hero {
  max-width: 640px;
  margin: 4rem auto;
  text-align: center;
}
.hero h1 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.hero .lede {
  color: var(--muted);
  font-size: 1.0625rem;
  margin-bottom: 2rem;
}
.bullets {
  list-style: none;
  padding: 0;
  margin: 2.5rem 0 0;
  text-align: left;
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
}
.bullets li {
  position: relative;
  padding-left: 1.25rem;
}
.bullets li::before {
  content: "✓";
  color: var(--success);
  position: absolute;
  left: 0;
}

/* Empty state */
.empty {
  max-width: 520px;
  margin: 4rem auto;
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Dashboard */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 720px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  position: sticky;
  top: 80px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem 0.5rem;
}
.sidebar-head h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
}
.repo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 2px;
}
.repo-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.repo-list button:hover {
  background: var(--surface-2);
}
.repo-list button.active {
  background: var(--surface-2);
  font-weight: 600;
}
.repo-list .owner {
  color: var(--muted);
  font-size: 0.8125rem;
}

.content {
  min-width: 0;
}
.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.content-head h2 {
  margin: 0;
  font-size: 1.25rem;
}
.content-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Issue list */
.issue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.issue-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.issue-main {
  min-width: 0;
  flex: 1;
}
.issue-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot[data-status="OPEN"] {
  background: var(--success);
}
.status-dot[data-status="IN_PROGRESS"] {
  background: var(--warn);
}
.status-dot[data-status="CLOSED"] {
  background: var(--muted);
}
.issue-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.issue-desc {
  color: var(--muted);
  margin: 0.5rem 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.issue-desc:empty {
  display: none;
}
.issue-meta {
  margin: 0.25rem 0 0;
}
.issue-actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  align-items: stretch;
  flex-shrink: 0;
}

.empty-issues {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.issue-title a {
  color: inherit;
  text-decoration: none;
}
.issue-title a:hover {
  text-decoration: underline;
}

/* Issue detail */
.issue-detail {
  max-width: 820px;
  margin: 0 auto;
}
.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}
.back-link:hover {
  color: var(--text);
}
.issue-detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.issue-detail-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}
.issue-detail-title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.issue-detail-meta {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}
.issue-detail-meta a {
  color: var(--accent);
  text-decoration: none;
}
.issue-detail-meta a:hover {
  text-decoration: underline;
}
.issue-detail-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
  margin-bottom: 1.5rem;
  min-height: 1.5em;
}
.issue-detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal[hidden] {
  display: none;
}
[hidden] {
  display: none !important;
}
.modal-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
}
#issue-form {
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}
#issue-form label {
  display: grid;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted);
}
#issue-form .input {
  font-size: 0.9375rem;
  color: var(--text);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 360px;
}
.toast.error {
  border-color: var(--danger);
}
