:root {
  color-scheme: light;
  font-family:
    "SF Pro Display",
    "SF Pro Text",
    "PingFang SC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #18181b;
  background: #f7f7f6;
  font-synthesis: none;
  --background: #f7f7f6;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --sidebar-width: 15rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button,
input,
.provider-card {
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:focus-visible,
input:focus-visible,
pre:focus-visible,
a:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  text-wrap: balance;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  border-radius: 0.45rem;
  padding: 0.55rem 0.8rem;
  color: #fff;
  background: var(--accent);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.brand-mark {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 0.7rem;
  color: #fff;
  background: #18181b;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.08em;
}

.brand-mark--small {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

.auth-shell {
  display: grid;
  width: min(100% - 2rem, 29rem);
  min-height: 100dvh;
  margin: 0 auto;
  grid-template-rows: auto 1fr auto;
  gap: 2rem;
  align-items: center;
  padding: 2rem 0;
}

.auth-brand,
.sidebar-brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.auth-brand > span:last-child,
.sidebar-brand > span:last-child,
.operator-badge > span:last-child,
.sidebar-status > span:last-child {
  display: grid;
  gap: 0.05rem;
}

.auth-brand strong,
.sidebar-brand strong {
  font-size: 0.94rem;
  letter-spacing: -0.02em;
}

.auth-brand small,
.sidebar-brand small,
.operator-badge small,
.sidebar-status small {
  color: var(--muted);
  font-size: 0.7rem;
}

.login-panel {
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: clamp(1.5rem, 6vw, 2.5rem);
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem rgb(24 24 27 / 8%);
}

.section-kicker {
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-copy h1,
.page-heading h1 {
  margin-bottom: 0.55rem;
  color: var(--text);
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.login-copy > p:last-child,
.page-heading > div > p:last-child,
.install-card__heading p {
  max-width: 65ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.login-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 2rem;
}

.login-form label,
.credential-form label {
  display: block;
  margin-top: 0.55rem;
  margin-bottom: 0.35rem;
  color: #3f3f46;
  font-size: 0.76rem;
  font-weight: 620;
}

input {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.55rem;
  padding: 0 0.75rem;
  color: var(--text);
  background: #fff;
}

input:hover,
input:focus {
  border-color: #a1a1aa;
  box-shadow: 0 0 0 3px rgb(24 24 27 / 5%);
}

.primary-button,
.quiet-button,
.danger-button,
.manage-button,
.sidebar-logout,
.nav-item {
  min-height: 2.35rem;
  border-radius: 0.5rem;
  padding: 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 620;
}

.primary-button {
  border: 1px solid #09090b;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgb(24 24 27 / 14%);
}

.primary-button:hover:not(:disabled) {
  background: #27272a;
}

.login-submit {
  width: 100%;
  min-height: 2.7rem;
  margin-top: 1rem;
}

.quiet-button,
.manage-button {
  border: 1px solid var(--border-strong);
  color: #3f3f46;
  background: #fff;
}

.quiet-button:hover:not(:disabled),
.manage-button:hover:not(:disabled) {
  border-color: #a1a1aa;
  color: #09090b;
  background: #fafafa;
}

.danger-button {
  border: 1px solid #fecaca;
  color: #991b1b;
  background: #fff;
}

.danger-button:hover:not(:disabled) {
  background: #fef2f2;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
}

.app-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100dvh;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 1rem 0.8rem;
  background: #fbfbfa;
}

.sidebar-brand {
  padding: 0.15rem 0.35rem 1.75rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.25rem;
}

.sidebar-nav > p {
  margin: 0 0 0.4rem;
  padding: 0 0.65rem;
  color: #a1a1aa;
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.65rem;
  border: 0;
  color: #52525b;
  background: transparent;
  text-align: left;
}

.nav-item:hover {
  color: var(--text);
  background: #f0f0ef;
}

.nav-item--active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgb(24 24 27 / 12%);
}

.nav-item--active:hover {
  color: #fff;
  background: #27272a;
}

.nav-icon {
  display: inline-grid;
  width: 1rem;
  place-items: center;
  font-size: 0.95rem;
}

.sidebar-status {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.75rem;
  background: #fff;
}

.sidebar-status strong {
  font-size: 0.75rem;
}

.sidebar-status__dot,
.endpoint-dot {
  width: 0.48rem;
  height: 0.48rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgb(21 128 61 / 12%);
}

.sidebar-logout {
  margin-top: 0.65rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.sidebar-logout:hover {
  color: var(--text);
  background: #f0f0ef;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  background: rgb(255 255 255 / 82%);
  backdrop-filter: blur(0.8rem);
}

.topbar-brand {
  display: none;
}

.operator-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.operator-badge > span:first-child {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 0.55rem;
  color: #3f3f46;
  background: #eeeeec;
  font-size: 0.65rem;
  font-weight: 720;
}

.operator-badge strong {
  font-size: 0.75rem;
}

.workspace-body {
  width: min(100% - 3rem, 74rem);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4.5rem) 0 2rem;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.list-card,
.endpoint-card,
.install-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(24 24 27 / 3%);
}

.list-card__header,
.provider-overview {
  display: grid;
  grid-template-columns: minmax(10rem, 1.1fr) minmax(12rem, 1.35fr) minmax(
      7rem,
      0.65fr
    ) 5rem;
  gap: 1rem;
  align-items: center;
}

.list-card__header {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.2rem;
  color: #a1a1aa;
  background: var(--surface-subtle);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.provider-card + .provider-card {
  border-top: 1px solid var(--border);
}

.provider-overview {
  min-height: 5rem;
  padding: 0.85rem 1.2rem;
}

.provider-card:hover:not(.provider-card--expanded) {
  background: #fdfdfc;
}

.provider-card--expanded {
  background: var(--surface-subtle);
}

.provider-identity,
.session-state {
  display: flex;
  align-items: center;
}

.provider-identity {
  min-width: 0;
  gap: 0.75rem;
}

.provider-logo {
  display: inline-grid;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.65rem;
  color: #fff;
  background: #1e293b;
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: -0.04em;
}

.provider-logo--xiaoman {
  color: #9a3412;
  background: #ffedd5;
}

.provider-logo--tungee {
  color: #166534;
  background: #dcfce7;
}

.provider-identity h3 {
  margin-bottom: 0.1rem;
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-type,
.mobile-column-label {
  color: #a1a1aa;
  font-size: 0.67rem;
}

.provider-account,
.provider-session {
  min-width: 0;
}

.provider-note {
  margin: 0;
  overflow: hidden;
  color: #52525b;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-column-label {
  display: none;
}

.session-state {
  gap: 0.55rem;
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #71717a;
  box-shadow: 0 0 0 3px rgb(113 113 122 / 10%);
}

.status-dot--authenticated {
  background: var(--success);
  box-shadow: 0 0 0 3px rgb(21 128 61 / 10%);
}

.status-dot--checking {
  animation: status-pulse 1.4s ease-in-out infinite;
}

.status-dot--authentication_required {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgb(180 83 9 / 10%);
}

.status-dot--unavailable {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgb(185 28 28 / 10%);
}

.status-pill {
  color: #52525b;
  font-size: 0.72rem;
  font-weight: 580;
  white-space: nowrap;
}

.manage-button {
  justify-self: end;
}

.provider-controls {
  display: none;
  border-top: 1px solid var(--border);
  padding: 1.15rem 1.2rem 1.3rem calc(1.2rem + 3.1rem);
  background: #fafafa;
}

.provider-card--expanded .provider-controls {
  display: block;
  animation: reveal-panel 180ms ease-out both;
}

.management-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.management-heading strong {
  font-size: 0.78rem;
}

.management-heading span {
  color: var(--muted);
  font-size: 0.69rem;
}

.credential-form {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(10rem, 1fr) auto;
  gap: 0.7rem;
  align-items: end;
}

.provider-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.provider-message {
  min-height: 1.1rem;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.provider-message[data-tone="progress"] {
  color: #1d4ed8;
}

.provider-message[data-tone="success"],
.copy-status[data-tone="success"] {
  color: var(--success);
}

.provider-message[data-tone="warning"] {
  color: var(--warning);
}

.provider-message[data-tone="error"],
.copy-status[data-tone="error"] {
  color: var(--danger);
}

.provider-card--skeleton {
  display: grid;
  min-height: 5rem;
  grid-template-columns: minmax(10rem, 1.1fr) minmax(12rem, 1.35fr) minmax(
      7rem,
      0.65fr
    ) 5rem;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.2rem;
}

.skeleton-block {
  height: 1rem;
  border-radius: 0.35rem;
  background: linear-gradient(100deg, #efefed 25%, #fafafa 42%, #efefed 58%);
  background-size: 220% 100%;
  animation: skeleton-shift 1.5s ease-in-out infinite;
}

.skeleton-block--identity {
  width: 8rem;
  height: 2.2rem;
}

.skeleton-block--account {
  width: min(100%, 13rem);
}

.skeleton-block--status {
  width: 4.5rem;
}

.skeleton-block--action {
  width: 3.8rem;
  height: 2.2rem;
}

.endpoint-card {
  display: grid;
  margin-bottom: 1rem;
}

.endpoint-card > div {
  display: grid;
  grid-template-columns: auto minmax(5.5rem, 0.35fr) minmax(15rem, 1fr);
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem 1.1rem;
}

.endpoint-card > div + div {
  border-top: 1px solid var(--border);
}

.endpoint-card strong {
  font-size: 0.78rem;
}

.endpoint-card code {
  overflow: hidden;
  color: #52525b;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-card {
  padding: clamp(1.2rem, 3vw, 1.7rem);
}

.install-card__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.install-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.55rem;
}

.install-card h2 {
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}

.install-steps {
  display: grid;
  gap: 0.5rem;
  margin: 1.4rem 0;
  padding-left: 1.2rem;
  color: #52525b;
  font-size: 0.78rem;
  line-height: 1.55;
}

.install-steps code {
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  padding: 0.08rem 0.3rem;
  color: #3f3f46;
  background: #f4f4f5;
  font-size: 0.7rem;
}

.config-block {
  max-height: 23rem;
  margin: 0;
  overflow: auto;
  border: 1px solid #27272a;
  border-radius: 0.65rem;
  padding: 1rem;
  color: #e4e4e7;
  background: #18181b;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%);
  font-size: 0.69rem;
  line-height: 1.65;
  tab-size: 2;
}

.copy-status {
  min-height: 1.1rem;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.feedback {
  min-height: 1.25rem;
  margin: 0.9rem 0 0;
  color: var(--danger);
  font-size: 0.75rem;
}

.feedback[data-tone="success"] {
  color: var(--success);
}

footer {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
}

@keyframes status-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

@keyframes skeleton-shift {
  to {
    background-position-x: -220%;
  }
}

@keyframes reveal-panel {
  from {
    opacity: 0;
    transform: translateY(-0.35rem);
  }
}

@media (max-width: 860px) {
  :root {
    --sidebar-width: 12.5rem;
  }

  .workspace-body {
    width: min(100% - 2rem, 74rem);
  }

  .list-card__header,
  .provider-overview,
  .provider-card--skeleton {
    grid-template-columns: minmax(8rem, 1fr) minmax(10rem, 1.1fr) minmax(
        6rem,
        0.7fr
      ) 4.5rem;
    gap: 0.7rem;
  }

  .provider-controls {
    padding-left: 1.2rem;
  }
}

@media (max-width: 680px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1rem;
  }

  .sidebar-brand,
  .sidebar-status {
    display: none;
  }

  .sidebar-nav {
    display: flex;
  }

  .sidebar-nav > p {
    display: none;
  }

  .nav-item {
    width: auto;
  }

  .sidebar-logout {
    position: absolute;
    top: 0.65rem;
    right: 1rem;
    margin: 0;
  }

  .topbar {
    justify-content: space-between;
    padding: 0 1rem;
  }

  .topbar-brand {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
  }

  .operator-badge > span:last-child {
    display: none;
  }

  .workspace-body {
    width: min(100% - 1.5rem, 74rem);
    padding-top: 2rem;
  }

  .page-heading {
    align-items: flex-start;
  }

  .list-card__header {
    display: none;
  }

  .provider-overview {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "identity manage"
      "account account"
      "session session";
    row-gap: 0.65rem;
    padding: 1rem;
  }

  .provider-identity {
    grid-area: identity;
  }

  .provider-account {
    grid-area: account;
  }

  .provider-session {
    grid-area: session;
  }

  .manage-button {
    grid-area: manage;
  }

  .mobile-column-label {
    display: block;
    margin-bottom: 0.2rem;
  }

  .provider-note {
    white-space: normal;
  }

  .provider-controls {
    padding: 1rem;
  }

  .provider-card--skeleton {
    grid-template-columns: 1fr auto;
  }

  .skeleton-block--account,
  .skeleton-block--status {
    display: none;
  }

  .credential-form {
    grid-template-columns: 1fr;
  }

  .endpoint-card > div {
    grid-template-columns: auto 1fr;
  }

  .endpoint-card code {
    grid-column: 2;
  }
}

@media (max-width: 480px) {
  .auth-shell {
    width: min(100% - 1.25rem, 29rem);
  }

  .page-heading,
  .install-card__heading,
  .management-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 0.9rem;
  }

  .page-heading .quiet-button,
  .install-card__heading .quiet-button {
    align-self: flex-start;
  }

  .nav-icon {
    display: none;
  }

  .nav-item {
    padding-inline: 0.7rem;
  }

  .sidebar-logout {
    padding-inline: 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
