:root {
  --bg: #0c0e12;
  --surface: #141820;
  --surface-hover: #1a2030;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e8eaef;
  --text-muted: #8b92a8;
  --accent: #f59e42;
  --accent-dim: rgba(245, 158, 66, 0.15);
  --accent-glow: rgba(245, 158, 66, 0.35);
  --success: #34d399;
  --danger: #f87171;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  max-width: 900px;
  height: 50vh;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.header,
.layout,
.footer {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
  padding-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-avatar {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid rgba(245, 158, 66, 0.25);
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.header-avatar:hover {
  border-color: rgba(245, 158, 66, 0.5);
  transform: scale(1.04);
}

.header-avatar.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.view-toolbar {
  margin-bottom: 1rem;
}

.auth-screen {
  position: relative;
  z-index: 1;
  max-width: 400px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

.auth-card {
  padding: 1.5rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

.auth-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(245, 158, 66, 0.35);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-form[hidden],
.app-screen[hidden],
#btn-profile-avatar[hidden],
[hidden] {
  display: none !important;
}

html.has-session #auth-screen {
  display: none !important;
}

html.has-session #app-screen {
  display: flex !important;
}

html.has-session #btn-profile-avatar {
  display: inline-flex !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-form input,
.auth-form select,
.profile-form input {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
}

.app-screen {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-screen:has(.dashboard:not([hidden])) {
  max-width: 1120px;
}

.projects-bar .projects-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.projects-bar label {
  flex: 1;
  min-width: 160px;
}

.projects-bar .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.projects-bar select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
}

.inline-form input {
  width: 140px;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.user-line {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.app-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.app-nav-tab {
  flex: 1;
  max-width: 160px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.app-nav-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.app-nav-tab.active {
  background: var(--accent-dim);
  border-color: rgba(245, 158, 66, 0.35);
  color: var(--accent);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  padding-right: 2.75rem;
}

.password-wrap input::-ms-reveal,
.password-wrap input::-ms-clear {
  display: none;
}

.password-wrap input::-webkit-credentials-auto-fill-button,
.password-wrap input::-webkit-strong-password-auto-fill-button {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

.password-wrap-inline input {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.pw-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  z-index: 2;
  transition: color 0.15s;
}

.pw-toggle:hover {
  color: var(--accent);
}

.pw-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pw-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.pw-icon-hide {
  display: none;
}

.pw-toggle.is-visible .pw-icon-show {
  display: none;
}

.pw-toggle.is-visible .pw-icon-hide {
  display: block;
}

.profile-details {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.profile-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.75rem;
  align-items: center;
}

.profile-row dt {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-row dd {
  font-size: 0.95rem;
  word-break: break-word;
}

.profile-password-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  font-family: inherit;
}

.profile-password-input[readonly] {
  cursor: default;
}

.profile-hint {
  margin-top: 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.profile-password-card {
  margin-top: 1rem;
}

.view-profile {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 14px;
  font-size: 1.25rem;
  border: 1px solid rgba(245, 158, 66, 0.25);
}

.logo h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.status.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}

.status.error .status-dot {
  background: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding-bottom: 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card h2,
.card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 6px;
}

.add-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.add-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.add-form input::placeholder {
  color: var(--text-muted);
}

.add-form input:focus {
  border-color: rgba(245, 158, 66, 0.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #f59e42, #e07a24);
  color: #0c0e12;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-ghost:hover {
  color: var(--danger);
}

.project-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.2s, border-color 0.2s;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.project-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.btn-back {
  align-self: flex-start;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-back:hover {
  color: var(--accent);
}

.project-toolbar-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.project-slug-line {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.view-projects,
.view-project,
.view-profile,
.view-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.view-project[hidden],
.view-projects[hidden],
.view-profile[hidden],
.view-settings[hidden] {
  display: none !important;
}

.dashboard {
  flex-direction: row;
  align-items: flex-start;
  gap: 1.25rem;
}

.dashboard-sidebar {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 1rem;
}

.sidebar-back {
  margin-bottom: 0.25rem;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-slug {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.dashboard-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dash-tab {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.dash-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.dash-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(245, 158, 66, 0.3);
}

.dashboard-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-empty-banner {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px dashed rgba(245, 158, 66, 0.45);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
  text-align: center;
}

.dash-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.btn-settings {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-settings:hover {
  color: var(--accent);
  border-color: rgba(245, 158, 66, 0.35);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-form select,
.settings-form input[type="tel"] {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.field-check input {
  width: auto;
}

.btn-logout-settings {
  margin-top: 1.5rem;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
}

.btn-logout-settings:hover {
  background: rgba(248, 113, 113, 0.1);
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow-y: auto;
}

.log-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.5rem 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.82rem;
}

.log-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.log-level {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 600;
}

.log-info .log-level {
  color: var(--success);
}

.log-warn .log-level {
  color: var(--accent);
}

.log-error .log-level {
  color: var(--danger);
}

.auth-tabs-inner {
  margin-bottom: 0.25rem;
}

.view-toolbar {
  margin-bottom: 0.25rem;
}

@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }

  .dashboard-sidebar {
    width: 100%;
    position: static;
  }

  .dashboard-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.schema-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project-item:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.08);
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.project-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.project-slug {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.project-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.project-item.active {
  border-color: rgba(245, 158, 66, 0.45);
  background: var(--accent-dim);
}

.schema-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.schema-project-title {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}

.schema-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.schema-block h3 {
  font-size: 0.95rem;
}

.schema-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.schema-form input,
.schema-form select,
.fn-row input,
.fn-row select {
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.fn-row {
  display: flex;
  gap: 0.5rem;
}

.fn-row input {
  flex: 1;
}

.field-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field-row input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.field-row select {
  padding: 0.55rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  align-self: flex-start;
}

.schema-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.schema-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.schema-fields {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.schema-fields code {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.75rem;
}

.schema-paths {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.schema-paths code {
  font-size: 0.72rem;
}

.schema-hint {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.schema-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.data-select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.data-rows {
  list-style: none;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.data-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.data-row-id {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.data-row-body {
  flex: 1;
  color: var(--text);
}

.data-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.kind-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-right: 0.35rem;
}

.kind-query {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.kind-mutation {
  background: var(--accent-dim);
  color: var(--accent);
}

.project-empty,
.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem 0;
  text-align: center;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-card h3,
.fn-card h3 {
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.api-list,
.fn-list {
  list-style: none;
  font-size: 0.85rem;
}

.api-list li,
.fn-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.api-list li:last-child,
.fn-list li:last-child {
  border-bottom: none;
}

code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.fn-list .kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.4rem;
  text-transform: uppercase;
}

.fn-list .kind-query {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.fn-list .kind-mutation {
  background: var(--accent-dim);
  color: var(--accent);
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}
