:root {
  --original-width: 1080px;
  --original-height: 1350px;
  --scale-factor: 0.45;

  /* ELK-WUE Hausfarbe (nur als Vollton, keine Abstufungen!) */
  --elk-violett: #8d197c;

  /* ELK-WUE Grundfarben (Abstufungen 10-100% erlaubt) */
  --elk-dunkelviolett: #591855;
  --elk-dunkelgrau: #474f60;

  /* ELK-WUE Schmuckfarben - Blautöne */
  --elk-dunkelblau: #29447b;
  --elk-taubenblau: #707aa0;
  --elk-hellblau: #5eb3d2;
  --elk-graublau: #6290b1;

  /* ELK-WUE Schmuckfarben - Violett & Grüntöne */
  --elk-pastellviolett: #988fa0;
  --elk-gelbgruen: #c9d229;
  --elk-hellgruen: #a3b37a;
  --elk-dunkelgruen: #518471;

  /* ELK-WUE Schmuckfarben - Türkis & Blaugrün */
  --elk-blaugruen: #318294;
  --elk-tuerkis: #298fa5;

  /* ELK-WUE Schmuckfarben - Warme Töne */
  --elk-gelb: #f5d403;
  --elk-orange: #dc9018;
  --elk-apricot: #cb957d;

  /* ELK-WUE Schmuckfarben - Rottöne */
  --elk-rot: #b61231;
  --elk-dunkelrot: #9c2049;
}

/* --- Sarabun Fonts (ELK-WUE Corporate Font) --- */
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Thin.ttf") format("truetype");
  font-weight: 100;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-ThinItalic.ttf") format("truetype");
  font-weight: 100;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-ExtraLight.ttf") format("truetype");
  font-weight: 200;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-ExtraLightItalic.ttf") format("truetype");
  font-weight: 200;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-LightItalic.ttf") format("truetype");
  font-weight: 300;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-MediumItalic.ttf") format("truetype");
  font-weight: 500;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-SemiBoldItalic.ttf") format("truetype");
  font-weight: 600;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
}
@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-ExtraBoldItalic.ttf") format("truetype");
  font-weight: 800;
  font-style: italic;
}

/* --- Global Styles --- */
body {
  background-color: #f6f7f9;
  margin: 0;
  font-family: "Sarabun", "Open Sans", "Inter", sans-serif;
  color: #2d3748;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: 100vh;
}

/* --- APP LAYOUT (Grid) --- */
.app-shell {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
  box-sizing: border-box;
}

.panel {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: relative;
  transition: all 0.3s ease;
}

.panel-left {
  z-index: 50;
}
.panel-right {
  z-index: 40;
}

.panel-center {
  background: transparent;
  box-shadow: none;
  border: none;
  align-items: center;
  justify-content: center; /* Center horizontally/vertically in the available space */
  /* Ensure it takes height to center the post */
  padding: 0;
  z-index: 30;
}

/* Sticky Right Panel */
.sticky-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* --- PANEL HEADERS & TYPOGRAPHY --- */
.panel-header,
.sidebar-title,
.section-title {
  color: #2d3748;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--elk-violett);
}
.panel-header {
  font-size: 1.25rem;
}

/* --- PREVIEW AREA (Simplified) --- */
.instagram-post-wrapper {
  position: relative;
  width: calc(var(--original-width) * var(--scale-factor));
  height: calc(var(--original-height) * var(--scale-factor));
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  margin: 0 auto; /* Center itself */
}

.instagram-post {
  width: var(--original-width);
  height: var(--original-height);
  background-color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(var(--scale-factor));
  transform-origin: top left;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 15px;
  padding: 20px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.preview-overlay .initial-message {
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}

/* --- SETTINGS PANEL (Details/Summary) --- */
.settings-scroll-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-group {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fcfdfe;
  overflow: hidden;
}
.settings-group summary {
  padding: 12px 15px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #2d3748;
  background: #f7fafc;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.settings-group summary::-webkit-details-marker {
  display: none;
}
.settings-group summary::after {
  content: "expand_more";
  font-family: "Material Icons";
  font-size: 1.2rem;
  transition: transform 0.2s;
}
.settings-group[open] summary::after {
  transform: rotate(180deg);
}
.settings-group[open] summary {
  border-bottom: 1px solid #e2e8f0;
}
.settings-group > div {
  padding: 8px;
}

/* --- COMPONENTS --- */
.project-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}
.slide-navigation-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 15px;
}
.nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  color: #4a5568;
  font-size: 0.9rem;
}
.slide-actions-row {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  align-items: center;
}
.separator-vertical {
  width: 1px;
  height: 20px;
  background: #cbd5e0;
  margin: 0 4px;
}

.thumbnail-container {
  display: flex;
  gap: 10px;
  padding: 4px 4px 12px 4px;
  overflow-x: auto;
  margin-bottom: 15px;
  scrollbar-width: thin;
}
.thumb-item {
  flex: 0 0 80px;
  height: 100px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s;
}
.thumb-item.active {
  border-color: var(--elk-violett);
  box-shadow: 0 0 0 3px rgba(141, 25, 124, 0.15);
  transform: translateY(-2px);
}
.thumb-item:hover:not(.active) {
  border-color: #cbd5e0;
  transform: translateY(-2px);
}
.thumb-preview-frame {
  width: 80px;
  height: 100px;
  transform-origin: top left;
  pointer-events: none;
}
.thumb-index {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

/* Post Content Styles */
.post-info {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: white;
  font-weight: bold;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 150px 60px;
}
.post-info .title {
  font-size: 90px;
  text-align: left;
  word-wrap: break-word;
  max-width: calc(100% - 20px);
  padding: 10px 15px;
  margin-bottom: 20px;
  line-height: 1.2;
  pointer-events: auto;
  outline: 1px dashed transparent;
}
.post-info .Info {
  font-size: 70px;
  word-wrap: break-word;
  margin-bottom: 20px;
  line-height: 1.3;
  pointer-events: auto;
  outline: 1px dashed transparent;
}
.post-info .Info.has-background-overlay {
  background-color: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 3px;
  display: inline-block;
}
.badge-element {
  position: absolute;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  line-height: 1.1;
  word-wrap: break-word;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* --- Side Badge Element --- */
.side-badge-element {
  position: absolute;
  z-index: 19;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  box-sizing: border-box;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  width: auto;
  height: auto;
  padding: 20px 15px;
}

.editable-text:focus {
  outline: 1px dashed #3182ce !important;
  box-shadow: 0 0 5px rgba(49, 130, 206, 0.5);
}
.image-container {
  width: 100%;
  height: 100%;
  background-color: #e2e8f0;
  overflow: hidden;
}
.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.credit {
  font-size: 20px;
  color: white;
  font-weight: normal;
  position: absolute;
  bottom: 30px;
  left: 50px;
  z-index: 10;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 3px;
  pointer-events: auto;
  outline: 1px dashed transparent;
}

/* General UI */
.btn-primary {
  background-color: #1a202c;
  color: white;
  border: 1px solid #1a202c;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-primary:hover {
  background-color: #2d3748;
}
.btn-secondary {
  background-color: #edf2f7;
  color: #2d3748;
  border: 1px solid #cbd5e0;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-group {
  margin-bottom: 12px;
}
.input-label {
  display: block;
  color: #4a5568;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.full-width-input,
.full-width-select,
.input-group input[type="text"],
.input-group input[type="number"],
.input-group select {
  width: 100%;
  padding: 8px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: white;
}
.input-group input[type="range"] {
  width: 100%;
}
.input-group input[type="color"] {
  height: 38px;
  padding: 2px;
  width: 100%;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  cursor: pointer;
}
.input-flex-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.input-flex-row .input-group {
  flex: 1;
  margin-bottom: 0;
}
.number-input-stepper input {
  text-align: center;
}
.dashed-upload-btn {
  border: 2px dashed #cbd5e0;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: #4a5568;
  cursor: pointer;
  display: block;
  transition: all 0.2s;
  background-color: #fafbfc;
  font-weight: 600;
  margin-bottom: 8px;
}
.dashed-upload-btn:hover {
  border-color: #a0aec0;
  background-color: #f1f5f9;
}

.toggles-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.toggle-item {
  display: flex;
  align-items: center;
}
.toggle-item span {
  font-size: 0.9rem;
  margin-left: 8px;
  font-weight: 500;
}
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e0;
  transition: 0.4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--elk-violett);
}
input:checked + .slider:before {
  transform: translateX(16px);
}

.text-formatting-toolbar {
  position: fixed;
  background-color: #2d3748;
  color: white;
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: flex;
  flex-direction: column;
}
.toolbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a202c;
  border-radius: 6px 6px 0 0;
  padding: 2px 5px;
}
.toolbar-drag-handle {
  color: #a0aec0;
  padding: 5px;
  cursor: move;
  flex-grow: 1;
}
.toolbar-row {
  padding: 8px;
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.text-formatting-toolbar button {
  background: #4a5568;
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.text-formatting-toolbar button:hover {
  background: #718096;
}
.text-formatting-toolbar button.active {
  background: #3182ce;
}

.message-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #48bb78;
  color: white;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.message-box.show {
  opacity: 1;
  visibility: visible;
  top: 30px;
}
.message-box.error {
  background: #f56565;
}

.nav-btn {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  border-radius: 4px;
}
.nav-btn:hover {
  color: #2d3748;
  background: #edf2f7;
}
.action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: transform 0.1s;
}
.action-btn.add {
  background-color: var(--elk-violett);
  color: white;
}
.action-btn.duplicate {
  background: white;
  border: 1px solid #cbd5e0;
  color: #4a5568;
}
.action-btn.delete {
  background: none;
  color: #a0aec0;
}
.action-btn.delete:hover {
  color: #e53e3e;
  background: #fff5f5;
}

/* Responsive Scale Adjustments */
@media (max-width: 1600px) {
  :root {
    --scale-factor: 0.4;
  }
}
@media (max-width: 1400px) {
  :root {
    --scale-factor: 0.35;
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas: "left center" "left right";
  }
  .panel-left {
    grid-area: left;
  }
  .panel-center {
    grid-area: center;
    min-height: 60vh;
  }
  .panel-right {
    grid-area: right;
    position: static;
    max-height: none;
    overflow: visible;
  }

  :root {
    --scale-factor: 0.45;
  } /* Bigger again as it takes full width of right side */
}

@media (max-width: 900px) {
  .app-shell {
    display: flex;
    flex-direction: column;
  }
  .panel-center {
    order: 1;
    min-height: 50vh;
  }
  .panel-left {
    order: 2;
  }
  .panel-right {
    order: 3;
  }
  :root {
    --scale-factor: 0.3;
  }
}

.hidden-by-request {
  display: none !important;
}

/* --- Shape Classes (New Implementation) --- */
.shape-skew {
  background-color: transparent !important; /* Ensure contenteditable bg doesn't override */
  position: relative;
  z-index: 10;
}
.shape-skew::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -20px; /* Slight overflow to prevent gaps */
  right: -20px;
  background-color: var(--shape-bg, #ffffff);
  transform: skewX(-12deg);
  z-index: -1;
  transform-origin: left center;
}
