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

:root {
  --bg: #09090e;
  --surface: #10101a;
  --surface2: #141420;
  --border: #1c1c2e;
  --border2: #252538;
  --text: #ddddf0;
  --muted: #5a5a7a;
  --dim: #2e2e48;
  --accent: #7c6af7;
  --accent-dim: #1e1a3e;
  --accent-hover: #6a58e6;
  --green: #4ade80;
  --green-dim: #0a1f14;
  --red: #f87272;
  --red-dim: #1f0a0a;
  --amber: #fbbf24;
  --amber-dim: #1f1605;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  min-height: 100vh;
  font-size: 13px;
}

button {
  font-family: 'Space Mono', monospace;
  cursor: pointer;
}

input, select, textarea {
  font-family: 'Space Mono', monospace;
}

a {
  text-decoration: none;
}

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #1a1235 0%, var(--bg) 60%);
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

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

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-name {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-name span {
  color: var(--accent);
}

.logo-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.6;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  margin-top: 24px;
}

.auth-step {
  display: none;
}

.auth-step.active {
  display: block;
}

.auth-step-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-step-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

.device-code-box {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
}

.device-code {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--accent);
  margin-bottom: 8px;
}

.device-url {
  font-size: 11px;
  color: var(--muted);
}

.device-url a {
  color: var(--accent);
}

.poll-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 20px;
  justify-content: center;
}

.poll-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  letter-spacing: 0.04em;
  transition: background 0.2s;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--accent);
}

.btn-github {
  width: 100%;
  padding: 12px 14px;
  background: #24292f;
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s;
}

.btn-github:hover {
  background: #2f3740;
}

.btn-github-icon {
  flex-shrink: 0;
}

.btn-ghost {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover {
  border-color: var(--muted);
  color: var(--text);
}

.auth-note {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.7;
  margin-top: 16px;
}

.auth-note code {
  color: var(--accent);
}

.auth-error {
  color: var(--red);
  font-size: 11px;
  margin-bottom: 14px;
  display: none;
}

.client-id-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.client-id-input:focus {
  border-color: var(--accent);
}

.setup-hint {
  background: var(--accent-dim);
  border: 1px solid #3a2f7a;
  border-radius: 9px;
  padding: 14px 16px;
  margin-top: 16px;
}

.setup-hint p {
  font-size: 11px;
  color: #9d8ff5;
  line-height: 1.8;
}

.setup-hint code {
  color: #c4b8ff;
}

#app-screen {
  display: none;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(9, 9, 14, 0.85);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo-name {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 800;
}

.header-logo-name span {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}

#avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border2);
}

#username {
  font-size: 11px;
  color: var(--muted);
}

.btn-signout {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  padding: 5px 11px;
  transition: all 0.2s;
}

.btn-signout:hover {
  border-color: var(--muted);
  color: var(--text);
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.stat-val {
  font-size: 26px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
}

.stat-val.pub {
  color: var(--green);
}

.stat-val.priv {
  color: var(--accent);
}

.stat-lbl {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

#search {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}

#search:focus {
  border-color: var(--accent);
}

.filter-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.filter-btn {
  padding: 9px 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
}

.sort-wrap span {
  font-size: 11px;
  color: var(--muted);
}

#sort {
  background: transparent;
  border: none;
  color: #999;
  font-size: 11px;
  outline: none;
}

#error-app {
  background: var(--red-dim);
  border: 1px solid #3d1515;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: var(--red);
  font-size: 12px;
  display: none;
}

#loading {
  text-align: center;
  padding: 60px;
  color: var(--muted);
  font-size: 12px;
  display: none;
}

#repo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#empty {
  text-align: center;
  padding: 60px;
  color: var(--dim);
  font-size: 12px;
  display: none;
}

.repo-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.repo-row:hover {
  border-color: var(--border2);
}

.repo-row.expanded {
  border-color: var(--accent);
}

.repo-row.archived .repo-main {
  opacity: 0.6;
}

.repo-main {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  white-space: nowrap;
  min-width: 60px;
  justify-content: center;
  flex-shrink: 0;
}

.badge.private {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge.public {
  background: var(--green-dim);
  color: var(--green);
}

.badge.archived-badge {
  background: var(--amber-dim);
  color: var(--amber);
}

.repo-info {
  flex: 1;
  min-width: 0;
}

.repo-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.repo-name {
  color: #c8c8e8;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
}

.repo-name:hover {
  color: var(--accent);
}

.repo-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fork-tag {
  font-size: 10px;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  flex-shrink: 0;
}

.archived-tag {
  font-size: 10px;
  color: var(--amber);
  padding: 2px 6px;
  border: 1px solid #3d2a10;
  border-radius: 4px;
  flex-shrink: 0;
}

.repo-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.lang-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.repo-date {
  font-size: 10px;
  color: var(--dim);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.expand-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  flex-shrink: 0;
}

.expand-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.expand-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
}

.repo-row.expanded .expand-arrow {
  transform: rotate(180deg);
}

.repo-panel {
  display: none;
  border-top: 1px solid var(--border);
  padding: 16px 18px;
  background: var(--surface2);
  flex-direction: column;
  gap: 14px;
}

.repo-row.expanded .repo-panel {
  display: flex;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.panel-input:focus {
  border-color: var(--accent);
}

.panel-input.textarea-input {
  resize: none;
  height: 56px;
  line-height: 1.5;
}

.btn-save {
  padding: 8px 14px;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-save:hover {
  background: var(--accent-hover);
}

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

.panel-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.feature-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.feature-name {
  font-size: 11px;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: var(--border2);
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(14px);
  background: #fff;
}

.danger-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-danger-soft {
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 11px;
  border: 1px solid;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Space Mono', monospace;
  cursor: pointer;
}

.btn-archive {
  background: var(--amber-dim);
  border-color: #4a3010;
  color: var(--amber);
}

.btn-archive:hover {
  border-color: var(--amber);
}

.btn-unarchive {
  background: var(--green-dim);
  border-color: #0a3020;
  color: var(--green);
}

.btn-unarchive:hover {
  border-color: var(--green);
}

.btn-vis {
  background: var(--accent-dim);
  border-color: #3a2f7a;
  color: #a898f8;
}

.btn-vis:hover {
  border-color: var(--accent);
}

.btn-delete {
  background: var(--red-dim);
  border-color: #3d1515;
  color: var(--red);
}

.btn-delete:hover {
  border-color: var(--red);
}

.btn-danger-soft:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 28px;
  max-width: 380px;
  width: 100%;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--red);
}

.modal-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 20px;
}

.modal-desc code {
  color: var(--text);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  margin-bottom: 14px;
}

.modal-input:focus {
  border-color: var(--red);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-modal-cancel {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-family: 'Space Mono', monospace;
}

.btn-modal-delete {
  flex: 1;
  padding: 10px;
  background: var(--red);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
}

.btn-modal-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
