* {
  box-sizing: border-box;
}

:root {
  --bg: #0a0d12;
  --surface: #121722;
  --surface-2: #171d29;
  --surface-3: #1e2634;
  --border: #293244;
  --text: #f4f7fb;
  --muted: #8f9bad;
  --accent: #6c7cff;
  --accent-2: #8390ff;
  --danger: #ff5e76;
  --shadow: 0 20px 60px rgba(0, 0, 0, .28);
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(108,124,255,.16), transparent 28rem),
    linear-gradient(180deg, #0c1016 0%, var(--bg) 100%);
  color: var(--text);
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  max-width: 1450px;
  margin: 0 auto 22px;
  padding: 22px 24px;
  background: rgba(18, 23, 34, .82);
  border: 1px solid var(--border);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.layout {
  max-width: 1450px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.panel, .workspace {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(18, 23, 34, .88);
  box-shadow: var(--shadow);
}

.controls-panel {
  padding: 18px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}

.control-section {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.045);
  margin-bottom: 14px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pill {
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
}

.drop-zone {
  min-height: 150px;
  border: 1.5px dashed #3d4960;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  text-align: center;
  padding: 20px;
  color: var(--muted);
  transition: .18s ease;
  outline: none;
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone span {
  font-size: 13px;
}

.drop-zone:hover,
.drop-zone.dragover,
.drop-zone:focus {
  background: rgba(108,124,255,.08);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.drop-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(108,124,255,.15);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
}

.button {
  border: 0;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 12px;
  font-weight: 750;
  color: var(--text);
  transition: .16s ease;
}

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

.button-primary {
  background: linear-gradient(135deg, var(--accent), #5a68e7);
}

.button-secondary {
  background: var(--surface-3);
  border: 1px solid #364158;
}

.button-ghost {
  background: transparent;
  border: 1px solid #364158;
}

.button-danger {
  color: #ffd6dc;
  background: rgba(255,94,118,.12);
  border: 1px solid rgba(255,94,118,.3);
}

.full {
  width: 100%;
}

.grow {
  flex: 1;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.subpanel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

.muted-disabled {
  opacity: .48;
  pointer-events: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 11px;
}

.field > span {
  color: #c6cfdd;
  font-size: 12px;
  font-weight: 700;
}

textarea,
select,
input[type="number"] {
  width: 100%;
  color: var(--text);
  background: #0f141e;
  border: 1px solid #303a4e;
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

textarea:focus,
select:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,124,255,.12);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 9px;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  padding: 4px;
  background: #0f141e;
  border: 1px solid #303a4e;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row output {
  min-width: 48px;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
}

.format-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.format-btn {
  height: 38px;
  border-radius: 10px;
  color: var(--text);
  background: #0f141e;
  border: 1px solid #303a4e;
}

.format-btn.active {
  border-color: var(--accent);
  background: rgba(108,124,255,.14);
  color: #dbe0ff;
}

.hint-card {
  padding: 15px 16px;
  border-radius: 16px;
  color: var(--muted);
  border: 1px solid rgba(108,124,255,.18);
  background: rgba(108,124,255,.07);
}

.hint-card strong {
  color: #dce1ff;
}

.hint-card p {
  margin: 6px 0 0;
  line-height: 1.5;
  font-size: 13px;
}

.workspace {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
  padding: 36px;
  overflow: hidden;
}

.empty-state {
  width: min(520px, 100%);
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  font-size: 23px;
  margin-top: 24px;
  margin-bottom: 10px;
}

.empty-state p {
  line-height: 1.6;
}

.empty-visual {
  height: 230px;
  position: relative;
  margin: 0 auto;
  width: 250px;
}

.placeholder-card {
  position: absolute;
  width: 210px;
  height: 210px;
  left: 18px;
  top: 6px;
  border-radius: 22px;
  border: 1px solid #344056;
  background:
    linear-gradient(135deg, rgba(108,124,255,.22), rgba(255,255,255,.02)),
    var(--surface-2);
  box-shadow: 0 20px 45px rgba(0,0,0,.22);
  transform: rotate(-5deg);
}

.placeholder-card.offset {
  left: 34px;
  top: 19px;
  transform: rotate(6deg);
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.12), transparent 32%),
    linear-gradient(135deg, rgba(108,124,255,.25), rgba(255,255,255,.03)),
    var(--surface-3);
}

.editor-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 15px;
}

.canvas-shell {
  width: min(512px, 100%);
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.38);
  background: #111;
  border: 1px solid #3a465b;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

.canvas-meta {
  width: min(512px, 100%);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 950px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    max-height: none;
  }

  .workspace {
    min-height: 650px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    padding: 18px;
    min-height: 560px;
  }

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

  .canvas-meta {
    flex-direction: column;
  }
}


/* Mehrbild-Erweiterung */

.mini-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  color: #c6cfdd;
  font-size: 12px;
  font-weight: 700;
}

.mini-muted {
  color: var(--muted);
  font-weight: 600;
}

.image-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.image-item {
  width: 100%;
  min-width: 0;
  padding: 7px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 30px;
  gap: 9px;
  align-items: center;
  text-align: left;
  border: 1px solid #303a4e;
  border-radius: 12px;
  color: var(--text);
  background: #0f141e;
  transition: .15s ease;
}

.image-item:hover {
  border-color: #46536c;
  background: #121926;
}

.image-item.active {
  border-color: var(--accent);
  background: rgba(108,124,255,.12);
  box-shadow: 0 0 0 2px rgba(108,124,255,.08);
}

.image-thumb {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  background-size: cover;
  background-position: center;
  background-color: #1a2130;
  border: 1px solid rgba(255,255,255,.07);
}

.image-item-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.image-item-info strong {
  font-size: 12px;
}

.image-item-info span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 11px;
}

.image-remove {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffbdc7;
  background: rgba(255,94,118,.08);
  font-size: 20px;
  line-height: 1;
}

.image-remove:hover {
  background: rgba(255,94,118,.16);
}

.control-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}


/* Freihand-Editor */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mode-btn {
  min-height: 40px;
  border-radius: 11px;
  border: 1px solid #303a4e;
  background: #0f141e;
  color: var(--text);
  font-weight: 750;
}

.mode-btn.active {
  border-color: var(--accent);
  background: rgba(108,124,255,.15);
  color: #e0e4ff;
}

.canvas-shell {
  position: relative;
}

canvas {
  user-select: none;
}

#freeformControls.muted-disabled {
  opacity: .4;
  pointer-events: none;
}

/* --- Sharing / server version --- */

.privacy-card {
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid rgba(108,124,255,.22);
  background: rgba(108,124,255,.075);
  margin-bottom: 14px;
}

.privacy-card strong {
  color: #dce1ff;
}

.privacy-card p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.privacy-card .privacy-small {
  font-size: 11px;
  opacity: .82;
}

.share-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 35px 100px rgba(0,0,0,.55);
}

.share-dialog::backdrop {
  background: rgba(2, 5, 10, .76);
  backdrop-filter: blur(5px);
}

.share-dialog-inner {
  position: relative;
  padding: 28px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 23px;
  line-height: 1;
}

.share-icon {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: rgba(108,124,255,.14);
  color: var(--accent-2);
  font-size: 25px;
  margin-bottom: 18px;
}

.share-dialog h2 {
  font-size: 22px;
  margin-bottom: 7px;
}

.share-copy {
  color: var(--muted);
  margin-bottom: 18px;
}

.share-link-row {
  display: flex;
  gap: 9px;
  margin-bottom: 9px;
}

.share-link-row input {
  min-width: 0;
  flex: 1;
  color: var(--text);
  background: #0f141e;
  border: 1px solid #303a4e;
  border-radius: 12px;
  padding: 11px 12px;
}

.share-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.dialog-disclaimer {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.shared-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.shared-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.shared-brand {
  margin-bottom: 13px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.shared-card {
  display: grid;
  grid-template-columns: minmax(280px, 512px) minmax(250px, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(18, 23, 34, .92);
  box-shadow: var(--shadow);
}

.shared-meme {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  background: #fff;
}

.shared-info {
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.shared-info h1,
.expired-card h1 {
  font-size: clamp(25px, 4vw, 38px);
  margin-bottom: 12px;
}

.shared-info > p:not(.dialog-disclaimer),
.expired-card > p {
  color: var(--muted);
  line-height: 1.6;
}

.shared-button {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 9px;
}

.expired-card {
  padding: 48px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(18, 23, 34, .92);
  box-shadow: var(--shadow);
  text-align: center;
}

.expired-code {
  display: inline-grid;
  place-items: center;
  min-width: 80px;
  min-height: 46px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,94,118,.3);
  border-radius: 999px;
  background: rgba(255,94,118,.1);
  color: #ffc6cf;
  font-weight: 900;
  letter-spacing: .08em;
}

@media (max-width: 760px) {
  .shared-card {
    grid-template-columns: 1fr;
  }

  .shared-info {
    padding: 24px;
  }

  .share-link-row {
    flex-direction: column;
  }
}


/* --- Fokus-Ansicht fuer geteilte Memes --- */
.shared-page-focus {
  display: block;
  min-height: 100vh;
  padding: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(108,124,255,.10), transparent 34rem),
    #090d13;
}

.shared-focus-shell {
  width: min(940px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 44px;
  display: flex;
  flex-direction: column;
}

.shared-focus-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.shared-focus-header .shared-brand {
  margin: 0;
}

.shared-create-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  transition: color .15s ease;
}

.shared-create-link:hover {
  color: var(--text);
}

.shared-focus-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.shared-focus-meme {
  display: block;
  width: min(760px, 82vw, calc(100vh - 155px));
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 34px 95px rgba(0,0,0,.48),
    0 0 0 1px rgba(255,255,255,.05);
}

.shared-expiry {
  margin-top: 15px;
  color: #7f8a9d;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 680px) {
  .shared-focus-shell {
    width: min(100% - 20px, 940px);
    padding-top: 14px;
    padding-bottom: 24px;
  }

  .shared-focus-header {
    margin-bottom: 12px;
  }

  .shared-focus-meme {
    width: min(100%, calc(100vh - 125px));
    border-radius: 14px;
  }

  .shared-create-link {
    font-size: 11px;
  }
}
