* {
  box-sizing: border-box;
}

:root {
  --admin-dark: #050b18;
  --admin-navy: #163c7a;
  --admin-blue: #1f6feb;
  --admin-blue-hover: #1757b7;
  --admin-red: #ff3b3b;
  --admin-red-hover: #c62828;
  --admin-cyan: #60d8ff;
  --admin-gold: #ffe45c;
  --admin-text: #182033;
  --admin-muted: #64748b;
  --admin-panel: rgba(255, 255, 255, 0.96);
  --admin-border: rgba(255, 255, 255, 0.45);
  --admin-success: #138a4b;
  --admin-error: #c62828;

  --dark: #050b18;
  --navy: #07152e;
  --blue: #1f6feb;
  --red: #ff3b3b;
  --cyan: #60d8ff;
  --gold: #ffe45c;
  --text: #102f5f;
  --muted: #64748b;
  --glass: rgba(255, 255, 255, 0.12);
  --panel: rgba(255, 255, 255, 0.92);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 59, 59, 0.28), transparent 28%),
    radial-gradient(circle at 90% 5%, rgba(31, 111, 235, 0.38), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(96, 216, 255, 0.18), transparent 35%),
    linear-gradient(145deg, var(--dark), var(--navy) 55%, #020611);
  color: var(--text);
}

/* =========================
   LOGIN
========================= */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 450px;
  padding: 2.4rem;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(235,245,255,0.94));
  border: 3px solid rgba(255,255,255,0.45);
  box-shadow:
    0 30px 90px rgba(0,0,0,0.5),
    0 0 40px rgba(31,111,235,0.22),
    inset 0 0 30px rgba(255,255,255,0.7);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-logo img {
  max-width: 180px;
  height: auto;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,0.25));
}

.login-card h1 {
  margin: 0 0 0.5rem;
  text-align: center;
  color: var(--text);
  font-size: 2rem;
}

.login-card p {
  text-align: center;
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 1rem;
}

.login-card input {
  padding: 1rem;
  border-radius: 16px;
  border: 2px solid #c7d8f5;
  font: inherit;
}

.login-card button {
  padding: 1rem;
  border: none;
  border-radius: 18px;
  background: linear-gradient(90deg, var(--red), var(--blue));
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 9px 0 rgba(0,0,0,0.28);
}

.login-error {
  color: #d62828;
  font-weight: 900;
}

/* =========================
   HEADER
========================= */

.editor-header {
  position: relative;
  overflow: hidden;
  padding: 1.5rem 2rem;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;

  background:
    linear-gradient(90deg, rgba(255,59,59,0.22), transparent 30%),
    linear-gradient(270deg, rgba(31,111,235,0.35), transparent 35%),
    linear-gradient(145deg, #06101f, #102f5f);
  border-bottom: 3px solid rgba(255,255,255,0.16);
  box-shadow: 0 18px 55px rgba(0,0,0,0.45);
}

.editor-header::after {
  content: "ADMIN CONTROL PANEL";
  position: absolute;
  right: 1.5rem;
  bottom: 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.18);
  font-weight: 900;
}

.editor-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  text-shadow:
    0 0 14px rgba(31,111,235,0.9),
    0 0 30px rgba(255,59,59,0.55);
}

.editor-header p {
  margin: 0.35rem 0 0;
  color: #dceaff;
  font-weight: 700;
}

.editor-header .login-logo img {
  max-height: 120px;
}

/* =========================
   BUTTONS
========================= */

.logout-btn,
.editor-actions button,
.video-input-box button {
  padding: 0.9rem 1.15rem;
  border: none;
  border-radius: 16px;
  background:
    linear-gradient(90deg, var(--red), #ffffff 50%, var(--blue));
  color: #06101f;
  font-weight: 1000;
  cursor: pointer;
  box-shadow:
    0 8px 0 rgba(0,0,0,0.35),
    0 0 22px rgba(31,111,235,0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.logout-btn:hover,
.editor-actions button:hover,
.video-input-box button:hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
}

.logout-btn:active,
.editor-actions button:active,
.video-input-box button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}

/* =========================
   LAYOUT
========================= */
/* Soft glow around panels */
.editor-panel,
.preview-panel {
  box-shadow:
    0 20px 60px rgba(0,0,0,0.25),
    0 0 25px rgba(31,111,235,0.15);
}

/* Slight glass effect */
.editor-panel,
.preview-panel {
  backdrop-filter: blur(6px);
}

/* Smooth hover lift */
.editor-panel:hover,
.preview-panel:hover {
  transform: translateY(-2px);
  transition: transform 0.2s ease;
}

.editor-wrapper {
  max-width: 1450px;
  margin: 2.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(350px, 0.9fr);
  gap: 1.8rem;
  align-items: start;
}

.editor-panel,
.preview-panel {
  position: relative;
  overflow: hidden;
  padding: 1.8rem;
  border-radius: 34px;
  background:
    radial-gradient(circle at top left, rgba(31,111,235,0.14), transparent 35%),
    radial-gradient(circle at bottom right, rgba(255,59,59,0.1), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,0.97), rgba(238,245,255,0.94));
  border: 3px solid rgba(255,255,255,0.45);
  box-shadow:
    0 25px 75px rgba(0,0,0,0.35),
    inset 0 0 35px rgba(255,255,255,0.55);
}

.editor-panel::before,
.preview-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(31,111,235,0.035) 0,
      rgba(31,111,235,0.035) 2px,
      transparent 2px,
      transparent 14px
    );
  pointer-events: none;
}

.editor-panel > *,
.preview-panel > * {
  position: relative;
  z-index: 1;
}

.preview-panel {
  position: sticky;
  top: 1rem;
}

.preview-panel h2 {
  margin-top: 0;
  color: var(--text);
}

/* =========================
   INPUTS
========================= */

.fields {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.title-input,
.subtitle-input,
#font-size-control,
#font-family-control,
#text-color-control,
.video-input-box input {
  width: 100%;
  padding: 1rem;
  border: 2px solid #bfd4f4;
  border-radius: 18px;
  background: white;
  color: var(--text);
  font: inherit;
  box-shadow:
    inset 0 0 14px rgba(31,111,235,0.07),
    0 8px 18px rgba(0,0,0,0.06);
}

.title-input {
  font-size: 1.3rem;
  font-weight: 1000;
}

.title-input:focus,
.subtitle-input:focus,
.video-input-box input:focus,
#font-size-control:focus,
#font-family-control:focus,
#text-color-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow:
    0 0 0 5px rgba(31,111,235,0.16),
    inset 0 0 14px rgba(31,111,235,0.1);
}

/* =========================
   TOOLBAR
========================= */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.2rem 0;
  padding: 0.8rem;
  border-radius: 20px;
  background: linear-gradient(135deg, #07152e, #123f83);
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.toolbar button {
  min-height: 42px;
  padding: 0.65rem 0.95rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;

  white-space: nowrap;
  line-height: 1;
}

.toolbar button:hover {
  background: #1f6feb;
  transform: translateY(-2px);
}

.toolbar button:active,
#btn-add-gif:active {
  transform: translateY(2px);
}

#font-size-control,
#font-family-control,
#text-color-control {
  margin-bottom: 0.8rem;
}

#text-color-control {
  height: 52px;
  padding: 0.35rem;
}

/* =========================
   MEDIA INPUT BOXES
========================= */

.video-input-box {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  border-radius: 20px;
  background: rgba(7,21,46,0.08);
  border: 2px dashed rgba(31,111,235,0.25);
}

.video-input-box[hidden],
.emoji-picker[hidden] {
  display: none;
}

.emoji-picker {
  margin-bottom: 1rem;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 45px rgba(0,0,0,0.22);
}

/* =========================
   EDITOR
========================= */

.editor {
  min-height: 460px;
  padding: 1.3rem;
  border: 3px solid #bfd4f4;
  border-radius: 24px;
  background: white;
  line-height: 1.75;
  outline: none;
  box-shadow:
    inset 0 0 22px rgba(31,111,235,0.08),
    0 14px 34px rgba(0,0,0,0.1);
}

.editor:focus {
  border-color: var(--blue);
  box-shadow:
    0 0 0 6px rgba(31,111,235,0.16),
    inset 0 0 22px rgba(31,111,235,0.08);
}

.editor img,
.story-preview img {
  max-width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  display: block;
  margin: 1rem auto;
  border-radius: 16px;
}

.editor iframe,
.story-preview iframe {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  display: block;
  margin: 1rem auto;
  border: none;
  border-radius: 16px;
}

.resizable-image {
  display: inline-block;
  resize: horizontal;
  overflow: hidden;
  max-width: 100%;
  min-width: 120px;
  border: 2px dashed transparent;
  border-radius: 16px;
  padding: 4px;
  margin: 1rem auto;
  transition: border 0.2s ease, transform 0.2s ease;
}

.resizable-image.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(31,111,235,0.15);
}

.resizable-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

/* =========================
   ACTIONS / PREVIEW
========================= */

.editor-actions {
  margin-top: 1.3rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#previewContent {
  margin-top: 1rem;
  line-height: 1.75;
}

.story-preview {
  padding: 1.1rem;
  border-radius: 22px;
  background: white;
  border: 2px solid #dceaff;
  color: var(--text);
}

.story-preview h1 {
  color: var(--text);
}

.story-category {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--blue);
  font-weight: 900;
  font-size: 0.8rem;
}

.editor-actions button,
.logout-btn {
  background: linear-gradient(135deg, #1f6feb, #174ea6);
  color: var(--gold);
}

.editor-actions button:hover {
  box-shadow: 0 10px 25px rgba(31,111,235,0.4);
}

.back-btn {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.12);
  color: white;
  font-weight: 800;
  cursor: pointer;

  transition: all 0.2s ease;
}

.back-btn:hover {
  background: #1f6feb;
  transform: translateY(-2px);
}

.logout-btn {
  color: white !important;
  text-decoration: none;
  background:
    linear-gradient(
      145deg,
      var(--admin-red),
      var(--admin-red-hover)
    );
}

.back-btn:hover,
.logout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
/* =========================
   RESPONSIVE
========================= */

@media (max-width: 950px) {
  .editor-wrapper {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  .editor-header {
    flex-direction: column;
    text-align: center;
  }

  .video-input-box {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .editor-panel,
  .preview-panel {
    padding: 1.1rem;
    border-radius: 24px;
  }

  .toolbar {
    justify-content: center;
  }

  .editor {
    min-height: 330px;
  }

  .toolbar button,
  #btn-add-gif {
    width: 42px;
    height: 42px;
  }
}