:root {
  --app-bg: linear-gradient(135deg, #f5efe7 0%, #f4f8f3 45%, #eef4fa 100%);
  --app-surface: rgba(255, 255, 255, 0.82);
  --app-border: rgba(28, 46, 32, 0.16);
  --app-text: #243127;
  --app-muted: #54635a;
  --preview-highlight: #e4f2e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--app-text);
  background: var(--app-bg);
}

h1,
h2,
h3,
p {
  margin: 0;
}

main {
  padding: 0 1.5rem 1.5rem;
}

.app-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--app-muted);
}

.app-header h1 {
  font-size: 2rem;
  letter-spacing: 0.01em;
}

wa-tab-group {
  --track-color: rgba(255, 255, 255, 0.35);
}

wa-card::part(base) {
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  backdrop-filter: blur(8px);
}

wa-tab-panel {
  padding: 1rem 0;
}

.menu-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(360px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.stack-column,
.editor-layout {
  display: grid;
  gap: 1rem;
}

.editor-layout {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.preview-pane {
  position: sticky;
  top: 1rem;
}

.field-grid {
  display: grid;
  gap: 0.85rem;
}

.compact-grid {
  grid-template-columns: 2fr 1fr;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.top-gap {
  margin-top: 0.6rem;
}

.mini-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-muted);
  margin-bottom: 0.45rem;
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-option {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.7);
}

.status-message {
  min-height: 1.15rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: #375447;
}

.status-message.error {
  color: #9a2929;
}

.hint {
  color: var(--app-muted);
  font-size: 0.85rem;
}

.item-grid {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.item-card {
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.86);
}

.item-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.item-card h3 {
  font-size: 1rem;
}

.meta {
  margin-top: 0.2rem;
  color: var(--app-muted);
  font-size: 0.82rem;
}

.item-card img,
.preview-image {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 0.55rem;
  margin-top: 0.6rem;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.item-tag {
  display: inline-flex;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #eef4e7;
  color: #395743;
  border: 1px solid rgba(57, 87, 67, 0.2);
}

.item-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.selected-list {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.selected-item {
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 255, 255, 0.88);
  cursor: grab;
}

.selected-item.drag-over {
  outline: 2px solid rgba(61, 114, 77, 0.45);
}

.selected-item.dragging {
  opacity: 0.45;
}

.selected-item.active {
  border-color: #3f7246;
  background: var(--preview-highlight);
}

.drag-handle {
  color: var(--app-muted);
  font-size: 1rem;
}

.selected-item-text {
  display: grid;
  gap: 0.1rem;
}

.selected-item-name {
  font-weight: 600;
}

.selected-item-meta {
  color: var(--app-muted);
  font-size: 0.8rem;
}

.pdf-page {
  width: min(100%, 540px);
  min-height: 760px;
  margin: 0 auto;
  padding: 2.2rem;
  border-radius: 0.9rem;
  background: white;
  border: 1px solid rgba(31, 53, 36, 0.2);
  box-shadow: 0 20px 28px rgba(25, 39, 29, 0.12);
}

.pdf-title {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.pdf-subtitle {
  font-size: 0.9rem;
  color: #4d5a51;
  margin-bottom: 1rem;
}

.pdf-section {
  margin-top: 0.9rem;
}

.pdf-label {
  display: block;
  font-size: 0.78rem;
  color: #637265;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.pdf-copy {
  font-size: 0.96rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.preview-items {
  display: grid;
  gap: 0.65rem;
}

.preview-item {
  border: 1px solid rgba(39, 58, 43, 0.18);
  border-radius: 0.65rem;
  padding: 0.55rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.preview-item.highlight {
  background: var(--preview-highlight);
  border-color: #447051;
}

.preview-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.preview-item-name {
  font-weight: 600;
}

.preview-item-price {
  font-weight: 600;
  font-size: 0.9rem;
  color: #2e4737;
}

.preview-item-description {
  margin-top: 0.28rem;
  color: #4d5b52;
  font-size: 0.86rem;
}

.empty-state {
  border: 1px dashed rgba(65, 91, 73, 0.32);
  border-radius: 0.6rem;
  padding: 1rem;
  color: #56695b;
  text-align: center;
}

input[type="file"] {
  width: 100%;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  padding: 0.55rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
}

code {
  background: rgba(19, 44, 31, 0.08);
  padding: 0.1rem 0.3rem;
  border-radius: 0.35rem;
}

@media (max-width: 980px) {
  main {
    padding: 0 0.8rem 0.8rem;
  }

  .app-header {
    padding: 0.9rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .menu-layout {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    position: static;
  }

  .compact-grid {
    grid-template-columns: 1fr;
  }

  .pdf-page {
    width: 100%;
    min-height: 620px;
    padding: 1.4rem;
  }
}
