@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --ink: #0f172a;
  --slate: #1f2937;
  --muted: #64748b;
  --accent: #6d5bd0;
  --accent-dark: #2f2f8f;
  --accent-soft: rgba(109, 91, 208, 0.16);
  --accent-cool: #21c4c0;
  --surface: rgba(255, 255, 255, 0.86);
  --line: rgba(15, 23, 42, 0.12);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--slate);
  background: radial-gradient(circle at 5% 10%, #dbeafe, transparent 45%),
    radial-gradient(circle at 20% 20%, #dbeafe, transparent 35%),
    radial-gradient(circle at 85% 20%, #d8b4fe, transparent 40%),
    radial-gradient(circle at 85% 85%, #99f6e4, transparent 35%),
    #f8fafc;
  min-height: 100vh;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeIn 0.6s ease;
}

.permission-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}

.permission-banner.is-admin {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
}

.permission-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.permission-banner.is-admin .permission-dot {
  background: #22c55e;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, #5a9cf8, #6d5bd0, #8b4ec6);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 20px;
  color: var(--ink);
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.user-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid rgba(109, 91, 208, 0.2);
  background: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

.auth-status {
  color: var(--muted);
  min-width: 110px;
}

.auth-status.is-on {
  color: #166534;
  font-weight: 600;
}

.user-controls input,
.user-controls select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  min-width: 140px;
}

.app-switcher {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 6px;
}

.app-switcher select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--accent-dark);
}

.ghost-button:hover {
  border-color: rgba(109, 91, 208, 0.4);
  background: rgba(109, 91, 208, 0.08);
}

.ghost-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-cool));
  color: #fff;
  border-color: transparent;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.auth-form button {
  border-radius: 12px;
  padding: 10px 12px;
  border: none;
  background: var(--accent-dark);
  color: #fff;
  cursor: pointer;
}

.auth-oauth {
  margin: 10px 0 16px;
}

.oauth-button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #0f172a, #111827);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.oauth-button:hover {
  opacity: 0.92;
}

.auth-mfa {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.auth-mfa-title {
  font-weight: 600;
  color: var(--ink);
}

.security-grid {
  display: grid;
  gap: 18px;
  margin-top: 12px;
}

.security-grid h4 {
  margin: 0 0 10px;
  color: var(--ink);
}

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

.totp-setup {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
}

.totp-secret {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  letter-spacing: 1px;
}

.recovery-codes {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.security-list {
  display: grid;
  gap: 10px;
}

.security-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.feedback-repo-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-dark);
  background: rgba(109, 91, 208, 0.12);
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.token-output {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(15, 23, 42, 0.04);
  font-size: 12px;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: stretch;
}

.app-frame {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 70vh;
  animation: slideUp 0.6s ease;
}

.frame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.frame-header h2 {
  margin: 0;
  font-size: 22px;
  color: var(--ink);
}

.frame-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.env-indicator {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(109, 91, 208, 0.2);
  background: rgba(255, 255, 255, 0.7);
  min-width: 180px;
}

.env-indicator a {
  color: var(--accent-dark);
  text-decoration: none;
}

.env-indicator a:hover {
  text-decoration: underline;
}

.env-indicator span {
  font-weight: 600;
  color: var(--ink);
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #065f46;
  font-size: 12px;
}

.iframe-wrap {
  flex: 1;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.app-create-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.repo-browser {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(109, 91, 208, 0.2);
  background: rgba(109, 91, 208, 0.05);
}

.repo-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.repo-browser input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.repo-owner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.repo-owner select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.repo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.repo-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(109, 91, 208, 0.18);
  font-size: 13px;
  cursor: pointer;
}

.repo-item:hover {
  border-color: rgba(109, 91, 208, 0.35);
  background: rgba(109, 91, 208, 0.08);
}

.app-create-form input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.app-create-form button {
  grid-column: span 2;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-cool));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  grid-column: span 2;
}

.repo-visibility {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  grid-column: span 2;
}

.repo-visibility select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
}


.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(640px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(109, 91, 208, 0.2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--ink);
}

.modal-header p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.github-connect {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(109, 91, 208, 0.2);
  background: rgba(109, 91, 208, 0.06);
}

.github-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.github-label {
  font-weight: 600;
  color: var(--ink);
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.assistant {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: slideUp 0.6s ease;
  position: relative;
  overflow: hidden;
}

.assistant::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, rgba(109, 91, 208, 0.35), rgba(33, 196, 192, 0.3));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(109, 91, 208, 0.2);
}

.side-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.side-title {
  font-weight: 600;
  color: var(--ink);
}

.side-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.assistant-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--ink);
}

.assistant-meta {
  font-size: 12px;
  color: var(--muted);
}

.assistant-config {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.assistant-role {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.assistant-role select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
}

.assistant-profile {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  color: var(--muted);
}

.assistant-profile.editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-profile.editor label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.assistant-profile.editor input,
.assistant-profile.editor textarea {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-family: inherit;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-cool));
  color: #fff;
  border-color: transparent;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(109, 91, 208, 0.1);
  border: 1px solid rgba(109, 91, 208, 0.22);
}

.chat-message.user .chat-bubble {
  background: rgba(33, 196, 192, 0.12);
  border-color: rgba(33, 196, 192, 0.25);
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.upload {
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}

.upload input {
  display: none;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.attachment-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.feedback-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.feedback-repo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.feedback-repo select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  background: #fff;
}

.feedback-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-quick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-note {
  font-size: 12px;
  color: var(--muted);
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: inherit;
}

.chat-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-cool));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.notice {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(109, 91, 208, 0.1);
  border: 1px solid rgba(109, 91, 208, 0.25);
  color: var(--accent-dark);
  font-size: 13px;
}

.notice.warning {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
  color: #166534;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-header h4 {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.review-count {
  font-size: 12px;
  color: var(--muted);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.suggestion-card {
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.4s ease;
  position: relative;
  overflow: hidden;
}

.suggestion-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(109, 91, 208, 0.25), rgba(33, 196, 192, 0.25));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.suggestion-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.suggestion-title {
  font-weight: 600;
  color: var(--ink);
}

.suggestion-actions {
  display: flex;
  gap: 8px;
}

.override-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  resize: vertical;
}

.feedback-card {
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.4s ease;
  border: 1px solid var(--line);
}

.feedback-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.label-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  background: #fff;
}

.label-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-cool));
  color: #fff;
  border: none;
}

.suggestion-actions button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.suggestion-actions .apply {
  background: linear-gradient(135deg, #22c55e, #10b981);
  color: #fff;
  border: none;
}

.suggestion-actions .reject {
  background: #fee2e2;
  color: #991b1b;
  border: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .page {
    padding: 20px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .permission-banner {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .user-controls {
    width: 100%;
    justify-content: space-between;
  }
}
