@import url('https://fonts.googleapis.com/css2?family=Rethink+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --surface: #0b0c10;
  --surface-container: #121318;
  --surface-container-low: #17181f;
  --surface-container-lowest: #1e1f29;
  --surface-bright: #252631;
  --on-surface: #e5e7eb;
  --primary: #fcaf3b;
  --primary-container: #835400;
  --on-primary: #121318;
  --outline-variant: rgba(255, 255, 255, 0.08);
  --ambient-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  --ambient-shadow-hover: 0 20px 48px rgba(0, 0, 0, 0.6);

  /* Post Colors */
  --color-blue: #3B82FC;
  --color-blue-dark: #003683;
  --color-green: #3BFC82;
  --color-green-dark: #008336;
  --color-purple: #B03BFC;
  --color-purple-dark: #500083;
  --color-red: #FC3B3B;
  --color-red-dark: #830000;
  --color-amber: #FCAF3B;
  --color-amber-dark: #835400;
  --color-cyan: #3BFCFC;
  --color-cyan-dark: #008383;
  --color-pink: #FC3BB0;
  --color-pink-dark: #830050;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Rethink Sans', sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Typography */
h1 { font-size: 3.5rem; letter-spacing: -0.02em; font-weight: 800; }
h2 { font-size: 2rem; letter-spacing: -0.02em; font-weight: 700; }
p { font-size: 1rem; line-height: 1.6; }
.label { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

/* Layout */
.sidebar {
  width: 320px;
  background: var(--surface-container);
  border-right: 1px solid var(--outline-variant); /* Exception for structural sidebar boundary, though ghost border preferred */
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 24px;
  background: var(--surface-container-low);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px; /* 16px vertical space instead of lines */
}

.post-item {
  background: var(--surface-container-lowest);
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  border: 1px solid var(--outline-variant); /* Ghost Border */
}

.post-item:hover {
  background: var(--surface-bright);
  box-shadow: var(--ambient-shadow);
  border-left: 2px solid var(--primary);
}

.post-item.active {
  border-left: 4px solid var(--primary);
  background: var(--surface-bright);
  box-shadow: var(--ambient-shadow);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--surface);
}

.topbar {
  margin: 24px 32px 0 32px;
  height: 64px;
  padding: 0 24px;
  border-radius: 16px;
  background: rgba(30, 31, 41, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  z-index: 20;
}

.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px;
  overflow-y: auto;
}

/* Glassmorphism Upload Panel */
.upload-panel {
  background: rgba(30, 31, 41, 0.5);
  backdrop-filter: blur(24px);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--ambient-shadow);
  width: 100%;
  max-width: 600px;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--on-primary);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-family: 'Rethink Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--ambient-shadow);
  transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  padding: 12px 24px;
  font-family: 'Rethink Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--surface-container-low);
}

/* Inputs */
.input-field {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  padding: 12px 0;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 1rem;
  color: var(--on-surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.input-field:focus {
  border-bottom: 2px solid var(--primary-container);
  box-shadow: 0 4px 12px rgba(252, 175, 59, 0.1);
}

/* Custom Range Slider */
.slider-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--outline-variant);
  border-radius: 4px;
  outline: none;
  transition: opacity .2s;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s;
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Image Variations Gallery */
.variations-gallery {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  width: 100%;
  max-width: 600px;
}

.thumbnail {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
  box-shadow: var(--ambient-shadow);
}

.thumbnail:hover {
  transform: translateY(-2px);
  border-color: var(--primary-container);
}

.thumbnail.selected {
  border-color: var(--primary);
}

/* The Post Canvas */
.post-canvas-wrapper {
  box-shadow: var(--ambient-shadow);
  border-radius: 8px;
  overflow: hidden;
  transform-origin: center top;
}

.post {
  width: 600px;
  height: 600px;
  background: #0A0A0A;
  position: relative;
  font-family: 'Rethink Sans', sans-serif;
  overflow: hidden;
  flex-shrink: 0;
}

.bg-img-element {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.65;
  z-index: 0;
}

.post::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--overlay-opacity, 1);
  background:
    linear-gradient(180deg, rgba(10,10,10,0.25) 0%, rgba(10,10,10,0.45) 50%, rgba(10,10,10,0.82) 100%),
    radial-gradient(ellipse 80% 60% at 70% 30%, rgba(252,175,59,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 20% 80%, rgba(131,84,0,0.06) 0%, transparent 50%);
  z-index: 1;
  pointer-events: none;
}

.accent-bar { position: absolute; left: 0; bottom: 168px; width: 6px; height: 195px; border-radius: 0 3px 3px 0; z-index: 2; }
.top-bar { position: absolute; top: 36px; left: 55px; right: 55px; display: flex; align-items: center; justify-content: space-between; z-index: 2; }

.pill-tag { border-radius: 100px; padding: 7px 16px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.logo-box { background: #FCAF3B; border-radius: 10px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.divider { position: absolute; left: 55px; right: 55px; height: 1.5px; z-index: 2; }
.divider-top { top: 103px; }
.divider-bottom { bottom: 72px; }

.hook-block { position: absolute; top: 128px; bottom: 80px; left: 55px; right: 55px; display: flex; flex-direction: column; justify-content: flex-end; z-index: 2; }
.hook-headline { font-size: 42px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; color: #FFFFFF; margin-bottom: 14px; text-transform: uppercase; }
.subline-svg { display: block; margin-bottom: 0; }

.footer { position: absolute; bottom: 28px; left: 55px; right: 55px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,0.07); padding-top: 16px; z-index: 2; }
.footer-text { font-size: 13px; font-weight: 400; color: rgba(255,255,255,0.22); letter-spacing: 0.01em; }

/* Dynamic Post Colors */
.post.blue .accent-bar { background: linear-gradient(180deg, var(--color-blue) 0%, var(--color-blue-dark) 100%); }
.post.blue .pill-tag { background: rgba(59, 130, 252, 0.12); border-color: rgba(59, 130, 252, 0.25); color: var(--color-blue); }
.post.blue .divider { background: linear-gradient(90deg, rgba(59, 130, 252, 0.7) 0%, transparent 100%); }
.post.blue .accent-var { color: var(--color-blue); }

.post.green .accent-bar { background: linear-gradient(180deg, var(--color-green) 0%, var(--color-green-dark) 100%); }
.post.green .pill-tag { background: rgba(59, 252, 130, 0.12); border-color: rgba(59, 252, 130, 0.25); color: var(--color-green); }
.post.green .divider { background: linear-gradient(90deg, rgba(59, 252, 130, 0.7) 0%, transparent 100%); }
.post.green .accent-var { color: var(--color-green); }

.post.purple .accent-bar { background: linear-gradient(180deg, var(--color-purple) 0%, var(--color-purple-dark) 100%); }
.post.purple .pill-tag { background: rgba(176, 59, 252, 0.12); border-color: rgba(176, 59, 252, 0.25); color: var(--color-purple); }
.post.purple .divider { background: linear-gradient(90deg, rgba(176, 59, 252, 0.7) 0%, transparent 100%); }
.post.purple .accent-var { color: var(--color-purple); }

.post.red .accent-bar { background: linear-gradient(180deg, var(--color-red) 0%, var(--color-red-dark) 100%); }
.post.red .pill-tag { background: rgba(252, 59, 59, 0.12); border-color: rgba(252, 59, 59, 0.25); color: var(--color-red); }
.post.red .divider { background: linear-gradient(90deg, rgba(252, 59, 59, 0.7) 0%, transparent 100%); }
.post.red .accent-var { color: var(--color-red); }

.post.amber .accent-bar { background: linear-gradient(180deg, var(--color-amber) 0%, var(--color-amber-dark) 100%); }
.post.amber .pill-tag { background: rgba(252, 175, 59, 0.12); border-color: rgba(252, 175, 59, 0.25); color: var(--color-amber); }
.post.amber .divider { background: linear-gradient(90deg, rgba(252, 175, 59, 0.7) 0%, transparent 100%); }
.post.amber .accent-var { color: var(--color-amber); }

.post.cyan .accent-bar { background: linear-gradient(180deg, var(--color-cyan) 0%, var(--color-cyan-dark) 100%); }
.post.cyan .pill-tag { background: rgba(59, 252, 252, 0.12); border-color: rgba(59, 252, 252, 0.25); color: var(--color-cyan); }
.post.cyan .divider { background: linear-gradient(90deg, rgba(59, 252, 252, 0.7) 0%, transparent 100%); }
.post.cyan .accent-var { color: var(--color-cyan); }

.post.pink .accent-bar { background: linear-gradient(180deg, var(--color-pink) 0%, var(--color-pink-dark) 100%); }
.post.pink .pill-tag { background: rgba(252, 59, 176, 0.12); border-color: rgba(252, 59, 176, 0.25); color: var(--color-pink); }
.post.pink .divider { background: linear-gradient(90deg, rgba(252, 59, 176, 0.7) 0%, transparent 100%); }
.post.pink .accent-var { color: var(--color-pink); }

#render-stage { position: fixed; left: -9999px; top: 0; width: 600px; height: 600px; overflow: hidden; pointer-events: none; z-index: -999; }

/* Responsive Adjustments */
@media (max-width: 950px) {
  body {
    flex-direction: column;
    overflow-y: auto;
  }
  .sidebar {
    width: 100%;
    height: 350px;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--outline-variant);
  }
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 80px;
    flex-wrap: wrap;
    padding-top: 16px;
    padding-bottom: 16px;
    justify-content: center;
    gap: 12px;
  }
  .editor-area {
    padding: 24px 16px;
    justify-content: flex-start;
  }
  .post-canvas-wrapper {
    transform: scale(0.85);
    margin-bottom: -90px;
  }
  .variations-gallery {
    margin-top: 24px;
  }
}

@media (max-width: 600px) {
  .post-canvas-wrapper {
    transform: scale(0.55);
    margin-bottom: -270px;
  }
}
