:root {
  --ink: #15202b;
  --ink-soft: #4a5a68;
  --paper: #eef2f5;
  --paper-deep: #dde5ec;
  --leaf: #0f766e;
  --leaf-deep: #115e59;
  --line: rgba(21, 32, 43, 0.12);
  --shadow: 0 18px 50px rgba(21, 32, 43, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 8% -12%, rgba(15, 118, 110, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 40% at 92% 8%, rgba(37, 99, 235, 0.1), transparent 50%),
    linear-gradient(165deg, #f4f7fa 0%, #e8eef3 48%, #dfe7ee 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(238, 242, 245, 0.78);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.top-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

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

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--leaf);
  color: #f0fdfa;
}

.btn.primary:not(:disabled):hover {
  background: var(--leaf-deep);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.block {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}

.block h2 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.field input,
.field select {
  font: inherit;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 1px;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.drop {
  display: grid;
  place-items: center;
  gap: 0.25rem;
  min-height: 110px;
  padding: 1rem;
  border: 1.5px dashed rgba(15, 118, 110, 0.45);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.07), rgba(255, 255, 255, 0.45));
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.drop:hover,
.drop.dragover {
  border-color: var(--leaf);
  background: rgba(15, 118, 110, 0.1);
  transform: scale(1.01);
}

.drop-title {
  font-weight: 550;
}

.drop-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.slot-preview {
  margin-top: 0.75rem;
}

.slot-card {
  position: relative;
  aspect-ratio: 8.5 / 11;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.slot-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.slot-card .remove {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
}

.workspace {
  min-width: 0;
}

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

.workspace-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 600;
}

.workspace-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.45);
}

.empty[hidden],
.slot-preview[hidden] {
  display: none;
}

.pages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.page-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(21, 32, 43, 0.08);
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  animation: rise 0.35s ease both;
}

.page-card:active {
  cursor: grabbing;
}

.page-card.dragging {
  opacity: 0.45;
  transform: scale(0.97);
}

.page-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(21, 32, 43, 0.12);
}

.page-sheet {
  aspect-ratio: 8.5 / 11;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.page-sheet img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.page-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 550;
  color: var(--leaf-deep);
}

.remove {
  appearance: none;
  border: none;
  background: rgba(21, 32, 43, 0.72);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.page-card .remove {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.page-card:hover .remove,
.page-card:focus-within .remove {
  opacity: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f0fdfa;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 40;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

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