:root {
  --bg: rgb(241, 241, 241);
  --panel: #ffffff;
  --stroke: #d8e2f2;
  --ink: #0f172a;
  --muted: #5c6474;
  --accent: #3b82f6;
  --accent-strong: #1e3a8a;
  --danger: #dc2626;
  --note: #0f172a0a;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --font: "Inter var", "Inter", system-ui, -apple-system, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg) url("/img/pattern_05.png") repeat;
  color: var(--ink);
  font-family: var(--font);
  padding: 90px 22px 28px;
}

.background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.appbar {
  height: 65px;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background-color: #3b82f6;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 18px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.2);
}

.appbar-actions {
  margin-left: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
}

.logo-img {
  height: 80px;
  width: auto;
}

.brand-name {
  font-size: 18px;
  font-weight: bold;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.view {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.view.active {
  display: flex;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.card h1,
.card h2,
h1,
h2 {
  margin: 0;
  color: var(--ink);
}

h1 {
  letter-spacing: -0.4px;
}

h2 {
  font-size: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stack {
  display: flex;
  flex-direction: column;
}

.inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.gap-xs {
  gap: 4px;
}

.gap-s {
  gap: 8px;
}

.gap-m {
  gap: 12px;
}

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

.field input,
.field select {
  background: #f8fbff;
  border: 1px solid var(--stroke);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.grow {
  flex: 1;
}

button {
  align-items: center;
  appearance: auto;
  background-color: #3b82f6;
  background-image: none;
  background-repeat: repeat;
  background-position: 0% 0%;
  background-size: auto;
  background-origin: padding-box;
  background-clip: border-box;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  box-sizing: border-box;
  color: #fff;
  color-scheme: light;
  cursor: pointer;
  display: inline-flex;
  font-family: "Inter var", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  height: 46px;
  letter-spacing: normal;
  line-height: normal;
  margin: 0;
  overflow: hidden;
  padding: 12px 20px;
  position: relative;
  text-align: center;
  text-rendering: auto;
  text-shadow: none;
  text-transform: none;
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: 0.2s;
  transition-timing-function: ease;
  user-select: none;
  vertical-align: bottom;
}

button:hover {
  filter: brightness(0.95);
}

button:active {
  opacity: 0.85;
}

.primary {
  border-color: #3b82f6;
  background-color: #3b82f6;
  color: #fff;
}

.ghost {
  color: var(--muted);
  background: #f8fafc;
  border-color: var(--stroke);
}

.back-btn {
  background: #f8fafc;
  color: var(--muted);
  border-color: var(--stroke);
  font-weight: 600;
  justify-content: center;
  padding: 4px 8px;
  height: auto 20px;
  min-height: 0;
  min-width: 0;
  width: fit-content;
  align-self: flex-start;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.back-btn::before {
  content: none;
}

.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  font-size: 22px;
}

.menu {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  z-index: 10;
}

.menu.open .menu-dropdown {
  display: flex;
}

.menu-item {
  justify-content: flex-start;
  height: auto;
  padding: 10px 12px;
  font-size: 14px;
}

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

.list .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #f9fbff;
  gap: 12px;
}

.list .item strong {
  letter-spacing: -0.2px;
}

.pill {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid var(--stroke);
  color: var(--muted);
  background: #fff;
}

.slug-pill {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-strong);
  border-color: rgba(59, 130, 246, 0.2);
}

.user-tag {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.08);
}

.note {
  font-size: 12px;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--stroke);
  background: var(--note);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stat {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #f8fbff;
}

.stat strong {
  display: block;
  font-size: 20px;
  margin-top: 2px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
}

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

.create-form {
  background: #f8fbff;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  padding: 12px;
}

.slug-preview {
  padding: 10px 12px;
  border-radius: 8px;
  background: #0f172a0a;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--stroke);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fragment {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbff;
}

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

.fragment-body {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--stroke);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
}

.fragment-body.hidden {
  display: none;
}

.info-rail {
  max-width: 380px;
}

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #0b0c10;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 120;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 200;
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.loading-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  text-align: center;
}

.loading-text {
  font-weight: 600;
}

.spinner {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 4px solid #e5edff;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 900px) {
  body {
    padding: 90px 14px 22px;
  }

  .view-head {
    flex-direction: column;
  }

  .info-rail {
    width: 100%;
  }

  .actions {
    width: 100%;
  }

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