:root {
  --page-bg: #fff8dd;
  --action-upload: #c85737;
  --action-variant: #4c6d45;
  --action-stories: #e4a7c6;
  --action-feed: #fc3f40;
  --action-accent: #bf6a43;
  --text: #2c2419;
  --text-muted: #6b5d4f;
  --surface: rgba(255, 255, 255, 0.78);
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-soft: 0 12px 40px rgba(76, 54, 30, 0.08);
  --font: 'DM Sans', system-ui, sans-serif;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 440px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.canvas-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: min(72vh, 640px);
  margin: 0 auto;
  background: var(--page-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(191, 106, 67, 0.18);
  overflow: hidden;
  touch-action: none;
}

/* Ve Feed náhledu oříznout fotku na stejný obdélník jako overlay (contain), ať v „prazdích“ prosvítá jen pozadí. */
.user-photo-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.user-photo-wrap .user-photo {
  pointer-events: auto;
}

.user-photo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto;
  height: auto;
  max-width: 92%;
  max-height: 92%;
  transform: translate(-50%, -50%);
  cursor: move;
  user-select: none;
  display: none;
  object-fit: contain;
  border: 2px dashed transparent;
  transition: border-color 0.2s;
  touch-action: none;
  z-index: 1;
}

.user-photo:hover {
  border-color: rgba(255, 255, 255, 0.85);
}

.user-photo::before,
.user-photo::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid rgba(76, 109, 69, 0.45);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.user-photo:hover::before,
.user-photo:hover::after {
  opacity: 1;
}

.user-photo::before {
  top: -14px;
  left: -14px;
}

.user-photo::after {
  bottom: -14px;
  right: -14px;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
  z-index: 3;
}

/* Stories: vyplní 9:16, bez bílých pruhů po stranách */
#overlay {
  object-fit: cover;
  object-position: center center;
  z-index: 3;
}

/* Feed: stejná pozice/layout jako v souboru — bez roztažení; „letterbox“ = barva pozadí */
#overlayFeed {
  object-fit: contain;
  object-position: center center;
  z-index: 3;
}

#userPhoto {
  z-index: 1;
}

.image-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.image-controls.visible {
  opacity: 1;
  pointer-events: all;
}

.floating-toolbar {
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(44, 36, 25, 0.12), 0 0 0 1px rgba(191, 106, 67, 0.15);
  backdrop-filter: blur(12px);
}

.toolbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 52px;
  min-height: 52px;
  padding: 6px 4px;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #3d342a;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toolbar-btn:hover {
  background: rgba(76, 109, 69, 0.1);
  color: var(--action-variant);
}

.toolbar-btn:active {
  background: rgba(76, 109, 69, 0.16);
}

.toolbar-btn + .toolbar-btn {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.toolbar-btn__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.toolbar-btn__label {
  opacity: 0.9;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.15rem;
}

.preview-switch__hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.preview-switch__track {
  display: flex;
  flex: 1;
  max-width: 280px;
  margin-left: auto;
  padding: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: inset 0 1px 3px rgba(44, 36, 25, 0.06);
  border: 1px solid rgba(191, 106, 67, 0.2);
}

.preview-switch__btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.preview-switch__btn.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(44, 36, 25, 0.1);
}

.preview-switch__btn[data-mode="stories"].is-active {
  color: #6b3d52;
  box-shadow: 0 2px 8px rgba(228, 167, 198, 0.45);
}

.preview-switch__btn[data-mode="feed"].is-active {
  color: #c41e24;
  box-shadow: 0 2px 8px rgba(252, 63, 64, 0.25);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(191, 106, 67, 0.2);
  backdrop-filter: blur(12px);
}

.upload-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border: 2px dashed rgba(200, 87, 55, 0.45);
  border-radius: var(--radius-md);
  background: rgba(255, 248, 221, 0.5);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-field:hover {
  border-color: var(--action-accent);
  background: #fff;
}

.upload-field:focus-within {
  outline: 2px solid var(--action-variant);
  outline-offset: 2px;
}

.upload-field__icon {
  color: var(--action-upload);
  flex-shrink: 0;
}

.upload-field__text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

.controls-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  flex-wrap: wrap;
}

.controls-row--downloads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.panel .btn-action {
  width: 100%;
  padding: 0.85rem 1rem;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}

.panel .btn-action:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.panel .btn-action:active {
  transform: translateY(0);
}

.btn-action-variant {
  background: var(--action-variant);
  color: #fff;
  box-shadow: 0 4px 14px rgba(76, 109, 69, 0.3);
}

.btn-action-stories {
  background: var(--action-stories);
  color: #2a1f24;
  box-shadow: 0 4px 14px rgba(228, 167, 198, 0.45);
}

.btn-action-feed {
  background: var(--action-feed);
  color: #fff;
  box-shadow: 0 4px 14px rgba(252, 63, 64, 0.28);
}

input,
select,
textarea {
  font-size: 16px !important;
  transform-origin: left top;
}

@media (min-width: 769px) {
  .app-shell {
    padding-top: 2rem;
  }

  .canvas-wrapper {
    max-height: min(75vh, 680px);
  }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    padding: 0.75rem 0.65rem 1rem;
    max-width: 100%;
    min-height: 100dvh;
  }

  .canvas-wrapper {
    max-height: none;
    flex: 1;
    min-height: 0;
  }

  .canvas-column {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .toolbar-btn {
    width: 48px;
    min-height: 48px;
    padding: 4px 2px;
  }

  .toolbar-btn__label {
    font-size: 0.5625rem;
  }

  .preview-switch {
    flex-wrap: wrap;
  }

  .preview-switch__track {
    max-width: none;
    width: 100%;
  }

  .controls-row--downloads {
    grid-template-columns: 1fr;
  }
}

@media (hover: none) {
  .toolbar-btn:hover {
    background: transparent;
    color: #3d342a;
  }

  .user-photo:hover {
    border-color: transparent;
  }
}

.seo-page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  min-height: 100vh;
}

.seo-page__back {
  display: inline-block;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--action-accent);
  text-decoration: none;
}

.seo-page__back:hover {
  text-decoration: underline;
}

.seo-page h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  line-height: 1.25;
}

.seo-page .lead {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1.25rem;
}

.seo-page h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.seo-page p {
  margin: 0 0 0.85rem;
  line-height: 1.55;
  font-size: 0.9375rem;
}

.seo-page ul {
  margin: 0 0 1rem 1.1rem;
  padding: 0;
  line-height: 1.55;
  font-size: 0.9375rem;
}

.seo-page li {
  margin-bottom: 0.35rem;
}
