:root {
  --bg: #1c1511;
  --card: rgba(250, 239, 230, 0.08);
  --card-strong: rgba(250, 239, 230, 0.12);
  --line: rgba(255, 232, 214, 0.18);
  --text: #f8eee5;
  --muted: #d0b6a0;
  --accent: #ff8a3d;
  --accent-strong: #ffb067;
  --accent-ink: #25160c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 138, 61, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(201, 89, 33, 0.2), transparent 24%),
    linear-gradient(180deg, #140f0c 0%, #1d1510 48%, #120d0a 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent 80%);
}

body.lightbox-open {
  overflow: hidden;
}

.page-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.link-box {
  display: grid;
  gap: 8px;
  padding: 0;
}

.link-box span {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.link-box strong {
  font-size: 15px;
  line-height: 1.5;
  word-break: break-all;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.8fr);
  gap: 24px;
  min-width: 0;
}

.viewer-panel,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.viewer-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.panel-top,
.card-heading,
.stage-meta,
.viewer-toolbar,
.history-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-top h2,
.card-heading h3 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.15;
}

.counter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 176, 103, 0.25);
  background: rgba(255, 176, 103, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
}

.viewer-toolbar {
  margin-top: 18px;
  flex-wrap: wrap;
}

.save-strip {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.save-inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.stage-frame {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(520px, 76vh, 920px);
  margin-top: 20px;
  padding: 60px 28px;
  border-radius: calc(var(--radius) - 2px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.18)),
    rgba(9, 7, 5, 0.45);
  overflow: hidden;
  cursor: zoom-in;
  touch-action: pan-y;
}

#menuImage {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  animation: image-enter 0.36s ease;
}

@keyframes image-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.swipe-hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.nav-button,
.primary-button,
.secondary-button,
.lightbox-close {
  border: 0;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease;
}

.nav-button:hover,
.primary-button:hover,
.secondary-button:hover,
.lightbox-close:hover {
  transform: translateY(-1px);
}

.nav-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.nav-button {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 248, 242, 0.12);
  color: var(--text);
  font-size: 34px;
  line-height: 1;
}

.nav-left {
  left: 16px;
}

.nav-right {
  right: 16px;
}

.stage-meta {
  margin-top: 20px;
  flex-wrap: wrap;
}

.meta-card {
  flex: 1 1 240px;
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card-strong);
}

.meta-card span {
  color: var(--muted);
  font-size: 13px;
}

.meta-card strong {
  font-size: 19px;
  line-height: 1.45;
  word-break: break-word;
}

.details-panel {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.card {
  padding: 24px;
}

.compact-card {
  padding: 20px 24px;
}

.save-inline-form input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid rgba(255, 232, 214, 0.2);
  border-radius: 16px;
  background: rgba(13, 10, 8, 0.58);
  color: var(--text);
  font-size: 16px;
}

.save-inline-form input:focus {
  outline: 2px solid rgba(255, 176, 103, 0.65);
  border-color: transparent;
}

.primary-button,
.secondary-button,
.lightbox-close {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #ffb067);
  color: var(--accent-ink);
}

.secondary-button,
.lightbox-close {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.status-message {
  min-height: 24px;
  margin: 10px 2px 0;
  color: var(--muted);
}

.status-message.error {
  color: #ffb4b4;
}

.history-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.history-name {
  font-size: 17px;
  line-height: 1.3;
}

.history-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 176, 103, 0.16);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 72px 20px 20px;
  background: rgba(10, 7, 5, 0.92);
  backdrop-filter: blur(12px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: min(96vw, 1800px);
  max-height: calc(100vh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

@media (max-width: 1080px) {
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: calc(100% - 12px);
    padding-top: 8px;
    padding-bottom: 24px;
  }

  .viewer-panel,
  .card {
    padding: 14px;
  }

  .panel-label {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .panel-top {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .card-heading,
  .history-main {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-top h2,
  .card-heading h3 {
    font-size: 22px;
    line-height: 1.15;
  }

  .viewer-toolbar {
    order: 6;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
  }

  .save-strip {
    margin-top: 10px;
    padding: 10px;
  }

  .counter-pill {
    align-self: flex-start;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .stage-frame {
    order: 3;
    height: min(56vh, 420px);
    min-height: 280px;
    margin-top: 10px;
    padding: 26px 8px 54px;
  }

  .swipe-hint {
    order: 4;
    margin-top: 8px;
    font-size: 12px;
  }

  .stage-meta {
    order: 5;
    margin-top: 10px;
  }

  .save-inline-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .save-inline-form input,
  .primary-button,
  .secondary-button {
    width: 100%;
    min-width: 0;
  }

  .nav-button {
    top: auto;
    bottom: 8px;
    width: 46px;
    height: 46px;
    font-size: 26px;
  }

  .nav-left {
    left: calc(50% - 54px);
  }

  .nav-right {
    right: calc(50% - 54px);
  }

  .meta-card {
    min-width: 0;
    padding: 14px;
  }

  .meta-card strong,
  .history-name,
  .history-meta,
  .link-box strong {
    overflow-wrap: anywhere;
  }

  .lightbox {
    padding: 70px 10px 12px;
  }

  .lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 92px);
    border-radius: 14px;
  }

  .lightbox-close {
    top: 10px;
    right: 10px;
    min-height: 46px;
    padding: 0 14px;
  }
}
