:root {
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --paper: rgba(16, 23, 42, 0.6);
  --soft: rgba(30, 41, 59, 0.4);
  --blue: #00f0ff;
  --blue-dark: #0ea5e9;
  --blue-soft: rgba(0, 240, 255, 0.1);
  --panel: rgba(16, 23, 42, 0.75);
  --danger: #ef4444;
  --sky: #7000ff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --gradient-neon: linear-gradient(135deg, var(--blue), var(--sky));
  --border-radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: 
    radial-gradient(circle at 10% 20%, rgba(112, 0, 255, 0.08), transparent 35rem),
    radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.08), transparent 35rem),
    #060913;
  font-family: Inter, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  content: "";
}

a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  transition: all 200ms ease;
}

a:hover {
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.admin-login {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
}

.login-panel,
.notice,
.editor-section {
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.login-panel {
  width: min(100%, 460px);
  padding: 40px;
}

.login-panel h1,
.admin-header h1,
.editor-section h2 {
  margin: 0;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-panel h1 {
  background: var(--gradient-neon);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.login-panel p,
.admin-header p,
.help,
.notice {
  color: var(--muted);
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 32px;
  padding: 28px 22px;
  border-right: 1px solid var(--line-strong);
  color: #fff;
  background: #0b0f1a;
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6);
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 80px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius);
  padding: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.admin-sidebar nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.admin-sidebar nav a,
.sidebar-actions a {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 200ms ease;
}

.admin-sidebar nav a span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: all 300ms ease;
  box-shadow: 0 0 0 rgba(0,240,255,0);
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.is-active,
.sidebar-actions a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  transform: translateX(4px);
}

.admin-sidebar nav a:hover span,
.admin-sidebar nav a.is-active span {
  background: var(--blue);
  box-shadow: 0 0 12px var(--blue);
  transform: scale(1.4);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.admin-header {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  padding: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.admin-header p {
  color: var(--blue);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.header-meta strong {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  backdrop-filter: blur(8px);
}

.header-meta strong:first-child {
  color: #fff;
  border-color: transparent;
  background: var(--gradient-neon);
  box-shadow: 0 0 16px rgba(112, 0, 255, 0.3);
}

body.has-unsaved-changes [data-save-state] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #fb923c, #f97316);
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.4);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.admin-main {
  display: grid;
  gap: 24px;
  width: min(1200px, calc(100% - 48px));
  margin: 32px auto 80px;
}

.notice {
  padding: 20px 24px;
  border-left: 4px solid var(--blue);
}

.notice.error {
  border-left-color: var(--danger);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
}

.editor-section {
  position: relative;
  overflow: hidden;
  padding: 40px;
}

.editor-section::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-neon);
  content: "";
}

.section-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.field-full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.2);
  font: inherit;
  font-weight: 500;
  transition: all 250ms ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  outline: none;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), inset 0 0 10px rgba(0, 240, 255, 0.05);
}

input[type="file"] {
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--line-strong);
}

input[type="file"]:hover {
  border-color: var(--blue);
}

.repeat-list {
  display: grid;
  gap: 24px;
  counter-reset: admin-row;
}

.repeat-row {
  position: relative;
  display: grid;
  gap: 24px;
  counter-increment: admin-row;
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  padding: 32px 24px 24px;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02), 0 8px 24px rgba(0,0,0,0.2);
  transition: all 300ms ease;
}

.repeat-row:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 12px 32px rgba(0,0,0,0.3);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.03);
}

.repeat-row::before {
  position: absolute;
  top: -12px;
  left: 24px;
  display: inline-grid;
  width: 36px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: #fff;
  background: var(--blue-dark);
  content: counter(admin-row, decimal-leading-zero);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 240, 255, 0.2);
}

.add-row,
.remove-row {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
}

.add-row {
  width: 100%;
  margin-top: 24px;
  border: 1px dashed var(--line-strong);
}

.add-row:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--blue);
  color: var(--blue);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.remove-row {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  min-height: 36px;
  color: var(--danger);
  border-color: transparent;
  background: rgba(239, 68, 68, 0.1);
}

.remove-row:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--border-radius);
  padding: 0 24px;
  color: #fff;
  background: var(--gradient-neon);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(112, 0, 255, 0.25);
  transition: all 250ms ease;
}

.button:hover {
  box-shadow: 0 12px 32px rgba(112, 0, 255, 0.4);
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}

.button.light {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.button.light:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--blue);
}

.form-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  z-index: 4;
  padding: 24px 0 0;
  background: linear-gradient(rgba(6, 9, 19, 0), rgba(6, 9, 19, 0.8) 30%, rgba(6, 9, 19, 1));
}

.form-footer .button {
  min-width: 220px;
}

.admin-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-nav-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  position: relative;
  cursor: pointer;
}

.admin-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--blue);
  transition: all 0.3s;
  position: absolute;
  left: 11px;
}

.admin-nav-toggle span:nth-child(1) { top: 16px; }
.admin-nav-toggle span:nth-child(2) { top: 26px; }

.admin-nav-toggle.is-open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.admin-nav-toggle.is-open span:nth-child(2) { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 960px) {
  .admin-mobile-header {
    display: flex;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
    background: #0b0f1a;
    box-shadow: 10px 0 50px rgba(0,0,0,0.8);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-brand {
    margin-top: 60px;
  }
}

@media (max-width: 760px) {
  .section-top { display: grid; }
  .field-grid { grid-template-columns: 1fr; }
  .login-panel, .editor-section { padding: 20px; }
  .admin-sidebar nav { grid-template-columns: 1fr; }
}
