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

:root {
  --pk-primary: #E30613;
  --pk-secondary: #111111;
  --pk-accent: #111111;
  --pk-bg: #F5F5F5;
  --pk-surface: #FFFFFF;
  --pk-fg: #111111;
  --pk-muted: #E5E5E5;
  --pk-border: #D4D4D4;
  --pk-destructive: #E30613;
  --pk-success: #0A7A3E;
  --pk-warning: #C47A00;
  --pk-radius: 0px;
  --pk-shadow: none;
  --pk-pad: 1.25rem;
  --pk-gap: 1.25rem;
  --pk-font-heading: "Space Grotesk", system-ui, sans-serif;
  --pk-font-body: Inter, system-ui, sans-serif;

  --bg: var(--pk-bg);
  --bg-elevated: var(--pk-muted);
  --surface: var(--pk-surface);
  --surface-solid: var(--pk-surface);
  --surface-hover: var(--pk-muted);
  --border: var(--pk-border);
  --border-hover: var(--pk-secondary);
  --text: var(--pk-fg);
  --text-muted: #525252;
  --text-faint: #737373;
  --accent: var(--pk-primary);
  --accent-2: var(--pk-secondary);
  --accent-glow: transparent;
  --error: var(--pk-destructive);
  --error-bg: #FCE8E9;
  --success: var(--pk-success);
  --radius: var(--pk-radius);
  --radius-sm: var(--pk-radius);
  --shadow: var(--pk-shadow);
  --transition: 0.15s ease;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--pk-font-body);
  background: var(--pk-bg);
  color: var(--pk-fg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  display: none;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.page--center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.container--narrow {
  max-width: 440px;
}

.card {
  background: var(--pk-surface);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: var(--pk-pad);
  box-shadow: var(--pk-shadow);
}

.card--login {
  padding: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.75rem;
}

.brand--compact {
  margin-bottom: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--pk-radius);
  background: var(--pk-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.brand-text h1 {
  font-family: var(--pk-font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--pk-fg);
}

.brand-text p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-family: var(--pk-font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--pk-radius);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--pk-muted);
  color: var(--pk-fg);
  border: 1px solid var(--pk-border);
}

.badge--guest {
  background: var(--pk-surface);
  color: var(--pk-fg);
  border-color: var(--pk-border);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  font-family: var(--pk-font-heading);
  text-transform: uppercase;
}

.input-wrap {
  position: relative;
  margin-bottom: 1rem;
}

input[type="password"],
input[type="text"],
input[type="url"],
.login-input,
.search-input,
.vlog-code-input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--pk-surface);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  color: var(--pk-fg);
  font-family: var(--pk-font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="password"],
input.login-input[type="password"] {
  padding-right: 3rem;
}

input[type="password"]:focus,
input[type="text"]:focus,
input[type="url"]:focus,
.login-input:focus,
.search-input:focus,
.vlog-code-input:focus {
  border-color: var(--pk-primary);
  box-shadow: none;
}

.login-input::placeholder,
.search-input::placeholder,
.vlog-code-input::placeholder {
  color: var(--text-faint);
}

.toggle-password {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--pk-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.toggle-password:hover {
  color: var(--pk-fg);
  background: var(--pk-muted);
}

.toggle-password svg {
  width: 18px;
  height: 18px;
}

button,
.btn,
a.btn-primary,
a.btn-secondary {
  cursor: pointer;
  font-family: var(--pk-font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--pk-radius);
  padding: 0.8rem 1.25rem;
  line-height: 1.2;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  box-sizing: border-box;
}

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

.btn-primary {
  width: 100%;
  background: var(--pk-primary);
  color: #fff;
  box-shadow: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-primary:hover:not(:disabled) {
  background: #c10510;
}

.btn-primary:active:not(:disabled) {
  background: #a0040e;
}

.btn-secondary {
  width: auto;
  background: var(--pk-surface);
  color: var(--pk-fg);
  border: 1px solid var(--pk-border);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

a.btn-secondary {
  color: var(--pk-fg);
}

.btn-secondary:hover {
  border-color: var(--pk-secondary);
  background: var(--pk-muted);
  color: var(--pk-fg);
}

.btn-secondary svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.topbar-actions .btn-secondary {
  min-height: 42px;
}

.error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--pk-destructive);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--error-bg);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
}

.error svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--pk-border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.welcome-name {
  color: var(--pk-fg);
  font-weight: 600;
}

.search-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-wrap svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  padding-left: 2.75rem !important;
  margin-bottom: 0 !important;
}

.buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--pk-gap);
}

.button-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.15rem 1.25rem;
  background: var(--pk-surface);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  color: var(--pk-fg);
  text-decoration: none;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
}

.button-card::before {
  display: none;
}

.button-card:hover {
  border-color: var(--pk-primary);
  background: var(--pk-surface);
}

.button-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.button-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--pk-radius);
  background: var(--pk-muted);
  border: 1px solid var(--pk-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pk-font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--pk-primary);
  flex-shrink: 0;
}

.button-card-arrow {
  width: 28px;
  height: 28px;
  border-radius: var(--pk-radius);
  background: var(--pk-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.button-card:hover .button-card-arrow {
  background: var(--pk-primary);
  color: #fff;
}

.button-card-arrow svg {
  width: 14px;
  height: 14px;
}

.button-card-label {
  font-family: var(--pk-font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  position: relative;
  z-index: 1;
  word-break: break-word;
}

.button-card-domain {
  font-size: 0.75rem;
  color: var(--text-faint);
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: var(--pk-radius);
  background: var(--pk-muted);
  border: 1px solid var(--pk-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  font-family: var(--pk-font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 280px;
  margin: 0 auto;
}

.login-back {
  width: 100%;
  margin-bottom: 1rem;
  justify-content: center;
}

.guest-section {
  margin-top: 1.75rem;
}

.site-routes-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--pk-border);
}

.site-routes-title {
  font-family: var(--pk-font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.site-routes-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
}

.site-routes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-route-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  background: var(--pk-surface);
  color: var(--pk-fg);
  font-family: var(--pk-font-body);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}

.site-route-chip strong {
  font-family: var(--pk-font-heading);
  font-size: 0.85rem;
}

.site-route-chip span {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.site-route-chip:hover {
  border-color: var(--pk-primary);
  background: var(--pk-muted);
  color: var(--pk-fg);
}

.vercel-block .section-header {
  margin-bottom: 0.5rem;
}

.vercel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.vercel-chip {
  cursor: pointer;
  user-select: none;
}

.vercel-chip input {
  margin-right: 0.35rem;
}

.vercel-chip--added {
  opacity: 0.55;
}

.vercel-chip--missing {
  border-color: var(--pk-warning);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--pk-border);
}

.divider span {
  color: var(--text-faint);
  font-size: 0.8rem;
  font-weight: 500;
}

.btn-guest {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--pk-surface);
  color: var(--pk-fg);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: 0.8rem 1.25rem;
  font-family: var(--pk-font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.btn-guest:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-guest:hover {
  border-color: var(--pk-secondary);
  background: var(--pk-muted);
}

.btn-guest svg {
  width: 18px;
  height: 18px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--pk-border);
  border-top-color: var(--pk-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.no-results {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 0;
}

.admin-section {
  margin-bottom: 1.25rem;
}

.admin-section:last-child {
  margin-bottom: 0;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--pk-surface);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
}

.admin-item--active {
  border-color: var(--pk-primary);
  background: var(--pk-surface);
  box-shadow: inset 3px 0 0 var(--pk-primary);
}

.admin-item-main {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.admin-item-main--static {
  cursor: default;
}

.admin-item-main strong {
  display: block;
  font-family: var(--pk-font-heading);
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.admin-item-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.admin-btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.admin-btn-danger:hover {
  border-color: var(--pk-destructive);
  color: var(--pk-destructive);
}

.admin-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: 0;
  background: var(--pk-surface);
  color: var(--pk-fg);
  max-width: 420px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  height: fit-content;
  box-shadow: var(--pk-shadow);
}

.admin-dialog[open] {
  display: block;
}

.admin-dialog::backdrop {
  background: rgba(17, 17, 17, 0.45);
}

.admin-dialog-inner {
  padding: 1.5rem;
}

.admin-dialog-inner h3 {
  font-family: var(--pk-font-heading);
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.admin-dialog-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.admin-dialog-actions .btn-primary,
.admin-dialog-actions .btn-secondary {
  flex: 1;
  justify-content: center;
}

@media (max-width: 640px) {
  .container {
    padding: 1.25rem 1rem 2rem;
  }

  .card,
  .card--login {
    padding: 1.5rem;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn-secondary {
    flex: 1;
    justify-content: center;
  }

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

  .admin-item {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-item-actions {
    width: 100%;
  }

  .admin-item-actions .btn-secondary {
    flex: 1;
    justify-content: center;
  }
}
