/* MAD Gen product polish — intentionally layered over the original brand CSS. */
:root {
  --ease-product: cubic-bezier(0.22, 1, 0.36, 1);
  --surface-raised: #fffdfb;
  --line-strong: rgba(48, 77, 2, 0.28);
  --shadow-control: 0 2px 6px rgba(48, 77, 2, 0.09);
  --shadow-float: 0 8px 24px rgba(32, 52, 1, 0.14);
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  text-wrap: balance;
}

p, .login-copy, .export-help, .field-path {
  text-wrap: pretty;
}

.section-label {
  letter-spacing: 0.045em;
  text-transform: none;
  font-size: 0.78rem;
}

input,
select,
textarea {
  min-height: 2.75rem;
  border-color: var(--line);
  background: var(--surface-raised);
  transition:
    border-color 160ms var(--ease-product),
    box-shadow 160ms var(--ease-product),
    background-color 160ms var(--ease-product);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-bright);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(189, 55, 23, 0.14);
}

.button,
.icon-button,
.nav-item,
.calendar-post-open,
.calendar-drag-handle,
.calendar-delete-button,
.back-button,
.danger-button {
  transition:
    transform 160ms var(--ease-product),
    background-color 160ms var(--ease-product),
    color 160ms var(--ease-product),
    opacity 160ms var(--ease-product),
    box-shadow 160ms var(--ease-product);
}

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

.button:not(:disabled):active {
  transform: translateY(0) scale(0.985);
}

button:disabled {
  opacity: 0.52;
  filter: saturate(0.55);
}

.button-primary {
  box-shadow: var(--shadow-control);
}

.app-header {
  min-height: 4.25rem;
  padding-inline: clamp(1rem, 2.5vw, 2rem);
  background: rgba(252, 247, 243, 0.9);
  backdrop-filter: blur(14px) saturate(1.15);
}

.brand-lockup img {
  width: 7rem;
}

.main-nav {
  border: 1px solid rgba(48, 77, 2, 0.08);
}

.nav-item.is-active {
  box-shadow: 0 2px 6px rgba(48, 77, 2, 0.1);
}

.sync-state {
  white-space: nowrap;
}

.sync-state i {
  box-shadow: 0 0 0 4px rgba(189, 55, 23, 0.1);
}

.view {
  padding: clamp(1.25rem, 2.7vw, 2.5rem);
}

.view.is-active {
  animation: mad-view-in 240ms var(--ease-product) both;
}

@keyframes mad-view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-heading {
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.status-strip {
  gap: clamp(1rem, 3vw, 2rem);
  scrollbar-width: none;
}

.status-metric {
  white-space: nowrap;
}

.calendar-wrap {
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--line);
  border: 0;
}

.calendar-day {
  min-height: min(31rem, calc(100vh - 17rem));
  content-visibility: auto;
  contain-intrinsic-size: 9rem 31rem;
}

.calendar-post {
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(48, 77, 2, 0.05);
}

.calendar-post:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 7px rgba(48, 77, 2, 0.12);
}

.calendar-post-open:focus-visible,
.calendar-drag-handle:focus-visible,
.calendar-delete-button:focus-visible {
  position: relative;
  z-index: 1;
}

.calendar-empty {
  opacity: 0.72;
}

.import-layout {
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--line);
  border-top: 0;
}

#jsonInput {
  tab-size: 2;
  white-space: pre;
}

.review-empty {
  padding: 2rem;
}

.review-list {
  overscroll-behavior: contain;
}

.editor-topbar {
  position: sticky;
  top: 4.25rem;
  z-index: 15;
  background: rgba(252, 247, 243, 0.94);
  backdrop-filter: blur(12px);
}

.editor-layout {
  grid-template-columns: 21rem minmax(34rem, 1fr) 19rem;
  height: calc(100dvh - 8.5rem);
}

.editor-panel,
.export-panel {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel-section {
  gap: 1rem;
  padding: 1.25rem;
}

.field-path {
  color: #5f6545;
  line-height: 1.35;
}

.asset-preview {
  background:
    linear-gradient(45deg, rgba(48, 77, 2, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(48, 77, 2, 0.035) 25%, transparent 25%),
    var(--mint-soft);
  background-size: 16px 16px;
}

.canvas-workspace {
  background: #203401;
  contain: layout paint;
}

.canvas-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
}

.preview-viewport {
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 240, 225, 0.1), transparent 30rem),
    #203401;
}

.preview-stage {
  filter: drop-shadow(0 14px 20px rgba(8, 17, 1, 0.22));
}

.export-panel {
  gap: 1.5rem;
  padding: 1.25rem;
}

.export-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-inline: -0.25rem;
  padding: 1rem 0.25rem 0.25rem;
  background: linear-gradient(to bottom, transparent, var(--white) 1rem);
}

.danger-button {
  border-radius: var(--radius-sm);
}

.danger-button:hover {
  background: rgba(148, 33, 5, 0.08);
  text-decoration: none;
}

.toast {
  box-shadow: var(--shadow-float);
  transition:
    opacity 200ms var(--ease-product),
    transform 200ms var(--ease-product);
}

.ios-download-dialog[open] {
  animation: mad-dialog-in 220ms var(--ease-product) both;
}

@keyframes mad-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1240px) {
  .editor-layout {
    grid-template-columns: 19rem minmax(30rem, 1fr) 17rem;
  }
}

@media (max-width: 1080px) {
  .editor-layout {
    grid-template-columns: 20rem minmax(27rem, 1fr);
    height: auto;
  }

  .export-panel {
    position: relative;
    grid-template-columns: minmax(16rem, 1fr) minmax(16rem, 1fr) auto;
  }

  .export-actions {
    position: static;
    background: none;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 4rem;
  }

  .main-nav {
    background: rgba(255, 240, 225, 0.94);
    backdrop-filter: blur(14px) saturate(1.15);
  }

  .view-heading h1 {
    font-size: 2rem;
  }

  .calendar-day {
    min-height: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    content-visibility: visible;
  }

  .calendar-wrap {
    box-shadow: none;
  }

  .calendar-post:hover {
    transform: none;
  }

  .editor-topbar {
    top: 4rem;
    min-height: 3.75rem;
  }

  .save-state {
    max-width: 8rem;
    margin-right: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .canvas-workspace {
    min-height: 30rem;
    max-height: 64dvh;
  }

  .preview-viewport {
    min-height: 27rem;
  }

  .panel-section,
  .export-panel,
  .import-input,
  .import-review {
    padding: 1rem;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(5.25rem + env(safe-area-inset-bottom));
    max-width: none;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .view.is-active,
  .ios-download-dialog[open] {
    animation: none;
  }
}
