/* ==========================================================================
   EVA // TITLER STUDIO — RETRO ANIME WYSIWYG TITLE CARD GENERATOR
   Design System & Styling
   ========================================================================== */

:root {
  /* Studio Tools host palette */
  --studio-bg: #101010;
  --studio-panel-bg: #171717;
  --studio-panel-border: #2b2b2b;
  --studio-border-strong: #3a3a3a;
  --studio-panel-hover: #1c1c1c;
  --studio-text-main: #eeeeee;
  --studio-text-muted: #9b9b9b;
  --studio-accent: #3a3a3a;
  --studio-accent-hover: #4a4a4a;
  --studio-accent-glow: transparent;
  --studio-cyan: #eeeeee;
  --studio-cyan-glow: transparent;
  --studio-red: #e28f8f;
  --studio-green: #9bdc9b;
  --studio-yellow: #dfc77b;
  --studio-blue: #9bb7dc;

  /* Typography */
  --font-ui: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-brand: var(--font-ui);
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Title Card Default Theme Tokens (Evangelion Indigo) */
  --card-bg-color: #535175;
  --card-text-primary: #ffffff;
  --card-text-secondary: #ffffff;
  --card-font-eng: Impact, 'Anton', 'Oswald', 'League Gothic', sans-serif;
  --card-font-jap: 'Shippori Mincho', 'Zen Old Mincho', 'Noto Serif JP', serif;
}

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

body {
  background-color: var(--studio-bg);
  color: var(--studio-text-main);
  font-family: var(--font-ui);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ==========================================================================
   1. STUDIO HEADER (TOP BAR)
   ========================================================================== */

.studio-header {
  height: 60px;
  background: var(--studio-panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--studio-panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--studio-accent), var(--studio-cyan));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 15px var(--studio-accent-glow);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text .brand {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, #a3b8cc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text .sub-brand {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--studio-text-muted);
  letter-spacing: 0.5px;
}

.header-center {
  display: flex;
  align-items: center;
}

.aspect-ratio-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  gap: 4px;
}

.ratio-btn {
  background: transparent;
  border: none;
  color: var(--studio-text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.ratio-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.ratio-btn.active {
  background: var(--studio-accent);
  color: #fff;
  box-shadow: 0 2px 10px var(--studio-accent-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--studio-text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--studio-accent), #5038a8);
  color: #fff;
  box-shadow: 0 4px 15px var(--studio-accent-glow);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--studio-accent-glow);
  background: linear-gradient(135deg, var(--studio-accent-hover), #5e43c4);
}

.export-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background: #141b2a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
}

.export-dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-menu button {
  background: transparent;
  border: none;
  color: var(--studio-text-main);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s;
}

.dropdown-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.dropdown-menu button i {
  color: var(--studio-accent);
  width: 16px;
  text-align: center;
}

.dropdown-menu .divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

/* ==========================================================================
   2. MAIN WORKSPACE & STAGE
   ========================================================================== */

.studio-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.stage-container {
  flex: 1;
  background: radial-gradient(circle at center, #182236 0%, #080c14 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

/* Grid background pattern for stage */
.stage-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.stage-controls {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.stage-controls > * {
  pointer-events: auto;
}

.hint-badge {
  background: rgba(18, 23, 35, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--studio-text-muted);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hint-badge i {
  color: var(--studio-cyan);
}

.zoom-controls {
  display: flex;
  align-items: center;
  background: rgba(18, 23, 35, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
  backdrop-filter: blur(8px);
  gap: 4px;
}

.zoom-controls button {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--studio-text-main);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.zoom-controls button:hover {
  background: rgba(255, 255, 255, 0.1);
}

#zoom-level {
  font-family: var(--font-mono);
  font-size: 12px;
  width: 48px;
  text-align: center;
  color: var(--studio-text-muted);
}

/* Floating Contextual Toolbar (Canva-style) */
.floating-toolbar {
  position: absolute;
  z-index: 200;
  background: rgba(18, 23, 35, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.floating-toolbar::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: rgba(18, 23, 35, 0.92);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(-50%) rotate(45deg);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.floating-toolbar.toolbar-below::after {
  bottom: auto;
  top: -6px;
  transform: translateX(-50%) rotate(-135deg);
}

.ft-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ft-label {
  font-size: 11px;
  color: var(--studio-text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.ft-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.floating-toolbar select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
  max-width: 140px;
}

.floating-toolbar select:focus {
  border-color: var(--studio-accent);
}

.floating-toolbar input[type="number"] {
  width: 56px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 5px 6px;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.floating-toolbar input[type="number"]::-webkit-outer-spin-button,
.floating-toolbar input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.floating-toolbar input[type="number"]:focus {
  border-color: var(--studio-accent);
}

.floating-toolbar input[type="color"] {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.floating-toolbar input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.floating-toolbar input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.ft-btn {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--studio-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s;
}

.ft-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ==========================================================================
   3. THE WYSIWYG TITLE CARD (EXPORT TARGET)
   ========================================================================== */

.title-card-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.3s ease, height 0.3s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

/* Aspect Ratios (Base width is scaled via CSS or JS zoom) */
.title-card-wrapper.ratio-16-9 { width: 960px; height: 540px; }
.title-card-wrapper.ratio-4-3  { width: 800px; height: 600px; }
.title-card-wrapper.ratio-21-9 { width: 1050px; height: 450px; }
.title-card-wrapper.ratio-1-1  { width: 620px; height: 620px; }

.title-card {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--card-bg-color);
  color: var(--card-text-primary);
  /* Ensure clean text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.card-background {
  position: absolute;
  inset: 0;
  background-color: var(--card-bg-color);
  z-index: 1;
  transition: background 0.3s ease;
}

.card-noise-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0.35;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.card-scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0.40;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 4px, 6px 100%;
}

.card-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
}

.card-scratches {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background-image: radial-gradient(#fff 1px, transparent 0), radial-gradient(#fff 1px, transparent 0);
  background-size: 550px 550px, 350px 350px;
  background-position: 0 0, 30px 60px;
  transition: opacity 0.3s ease;
}

.card-scratches.active {
  opacity: 0.15;
  animation: scratch-jump 0.5s steps(4) infinite;
}

@keyframes scratch-jump {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-10px, 15px); }
  50% { transform: translate(20px, -5px); }
  75% { transform: translate(-5px, -20px); }
  100% { transform: translate(0, 0); }
}

/* Retro Film Flicker & Gate Weave Animation */
.title-card.anim-flicker {
  animation: film-flicker 0.12s infinite;
}

@keyframes film-flicker {
  0% { opacity: 0.98; transform: translate(0, 0) scale(1); }
  25% { opacity: 1; transform: translate(-0.5px, 0.5px) scale(1.001); }
  50% { opacity: 0.97; transform: translate(0.5px, -0.5px) scale(0.999); }
  75% { opacity: 0.99; transform: translate(-0.3px, -0.2px) scale(1); }
  100% { opacity: 0.98; transform: translate(0, 0) scale(1); }
}

.title-card.anim-typewriter .text-line {
  animation: stomp-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.title-card.anim-typewriter .block-top-left .text-line:nth-child(2) { animation-delay: 0.1s; }
.title-card.anim-typewriter .block-top-left .text-line:nth-child(3) { animation-delay: 0.3s; }
.title-card.anim-typewriter .block-bottom-right .text-line:nth-child(2) { animation-delay: 0.5s; }
.title-card.anim-typewriter .block-bottom-right .text-line:nth-child(3) { animation-delay: 0.7s; }

@keyframes stomp-in {
  0% { opacity: 0; transform: scale(1.4) translateY(-10px); filter: blur(4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

/* WYSIWYG Editable Text Blocks */
.card-text-block {
  position: absolute;
  z-index: 10;
  padding: 12px;
  border-radius: 4px;
  border: 2px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
}

.card-text-block:hover:not(.is-selected):not(.is-editing) {
  border-color: rgba(0, 229, 255, 0.3);
  cursor: pointer;
}

.card-text-block.is-selected {
  border-color: var(--studio-cyan);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15);
  cursor: move;
}

.card-text-block.is-editing {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 3px var(--studio-accent-glow);
  cursor: text;
}

.card-text-block.is-editing .text-line {
  cursor: text;
}

.card-text-block.is-dragging {
  border-style: dashed;
  opacity: 0.9;
  transform: scale(1.01);
  z-index: 100 !important;
}

.snap-guide {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  display: none;
}

.snap-guide-h {
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px dashed #ff44aa;
  box-shadow: 0 0 6px rgba(255, 68, 170, 0.5);
}

.snap-guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
  border-left: 1px dashed #ff44aa;
  box-shadow: 0 0 6px rgba(255, 68, 170, 0.5);
}

/* Typography Styling for Text Lines */
.text-line {
  outline: none;
  cursor: text;
  word-break: break-word;
  line-height: 1.05;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.text-line:focus {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Top Left Block Styles (Exact Evangelion match) */
.block-top-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.english-primary {
  font-family: var(--card-font-eng);
  font-size: 88px;
  font-weight: 700;
  text-transform: none; /* In image: "No matter what choices you make" is lowercase/titlecase */
  letter-spacing: 0px;
  color: var(--card-text-primary);
}

.japanese-primary {
  font-family: var(--card-font-jap);
  font-size: 84px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--card-text-primary);
  margin-top: 4px;
}

/* Bottom Right Block Styles */
.block-bottom-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 2px;
}

.japanese-secondary {
  font-family: var(--card-font-jap);
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--card-text-secondary);
}

.english-secondary {
  font-family: var(--card-font-eng);
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--card-text-secondary);
}

/* Layout Presets for Template Alignments */
.layout-eva-default .block-top-left { align-items: flex-start; text-align: left; }
.layout-eva-default .block-bottom-right { align-items: flex-end; text-align: right; display: flex; }

.layout-sepia-reverse .block-top-left { align-items: flex-end; text-align: right; }
.layout-sepia-reverse .block-bottom-right { align-items: flex-start; text-align: left; display: flex; }

.layout-centered-title .block-top-left { align-items: center; text-align: center; }
.layout-centered-title .block-bottom-right { align-items: flex-start; text-align: left; display: flex; }

.layout-centered-only .block-top-left { align-items: center; text-align: center; }
.layout-centered-only .block-bottom-right { display: none !important; }

/* ==========================================================================
   4. FLOATING STUDIO DOCK (LEFT SIDEBAR)
   ========================================================================== */

.sidebar-toggle {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--studio-panel-border);
  color: var(--studio-text-muted);
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 14px;
  transition: color 0.15s;
}

.sidebar-toggle:hover {
  color: #fff;
}

.studio-sidebar {
  order: -1;
  width: 360px;
  background: var(--studio-panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--studio-panel-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.3);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.studio-sidebar.sidebar-collapsed {
  width: 52px;
}

.sidebar-collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar-collapsed .sidebar-tabs {
  grid-template-columns: 1fr;
}

.sidebar-collapsed .tab-btn span {
  display: none;
}

.sidebar-collapsed .tab-btn {
  padding: 14px 0;
}

.sidebar-collapsed .tab-content {
  display: none !important;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--studio-panel-border);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--studio-text-muted);
  padding: 14px 6px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.tab-btn i {
  font-size: 15px;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--studio-accent);
  background: rgba(110, 86, 207, 0.08);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
}

/* Custom Scrollbar for Dock */
.tab-content::-webkit-scrollbar {
  width: 6px;
}
.tab-content::-webkit-scrollbar-track {
  background: transparent;
}
.tab-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--studio-text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.mt-4 { margin-top: 16px; }

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--studio-text-main);
}

.control-group input[type="text"],
.control-group textarea,
.control-group select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  resize: vertical;
}

.control-group input[type="text"]:focus,
.control-group textarea:focus,
.control-group select:focus {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 3px var(--studio-accent-glow);
}

/* Slider Groups */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--studio-text-main);
}

.slider-group label span {
  font-family: var(--font-mono);
  color: var(--studio-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--studio-accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--studio-accent-glow);
  transition: transform 0.15s, background 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--studio-cyan);
  box-shadow: 0 0 12px var(--studio-cyan-glow);
}

/* Toggle Switch */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.toggle-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--studio-text-main);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--studio-accent);
}

input:checked + .slider.round:before {
  transform: translateX(20px);
}

/* Theme Grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.theme-card {
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(0, 0, 0, 0.3);
}

.theme-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.theme-card.active {
  border-color: var(--studio-accent);
  box-shadow: 0 0 0 2px var(--studio-accent-glow);
}

.theme-preview {
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: Impact, sans-serif;
  line-height: 1.1;
  padding: 4px;
}

.theme-preview .jp {
  font-family: serif;
  font-size: 10px;
}

.theme-name {
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--studio-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Color Pickers */
.color-picker-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

.hex-input {
  width: 80px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
}

.btn-full {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.secondary-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--studio-text-main);
}

.secondary-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   5. STUDIO FOOTER
   ========================================================================== */

.studio-footer {
  height: 36px;
  background: #080c14;
  border-top: 1px solid var(--studio-panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 11px;
  color: var(--studio-text-muted);
  z-index: 100;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator.online {
  color: var(--studio-green);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.status-indicator.online i {
  font-size: 8px;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.sep { color: rgba(255, 255, 255, 0.15); }

kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #fff;
}

/* ==========================================================================
   6. MODALS & OVERLAYS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #121824;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-card.modal-lg {
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h3 i { color: var(--studio-accent); }

.close-icon-btn {
  background: transparent;
  border: none;
  color: var(--studio-text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.15s;
}

.close-icon-btn:hover { color: #fff; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.progress-bar-wrapper {
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--studio-accent), var(--studio-cyan));
  border-radius: 4px;
  transition: width 0.2s ease;
}

.preview-box {
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 300px;
}

.preview-box img {
  max-width: 100%;
  max-height: 300px;
  display: block;
}

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.preset-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.preset-item:hover {
  transform: translateY(-4px);
  border-color: var(--studio-accent);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.preset-thumb {
  height: 120px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.preset-thumb .t-main {
  font-family: Impact, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.preset-thumb .t-sub {
  font-family: serif;
  font-size: 16px;
  font-weight: 800;
  margin-top: 4px;
}

.preset-info {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-info h4 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.preset-info p {
  font-size: 12px;
  color: var(--studio-text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   7. STUDIO TOOLS HOST THEME OVERRIDES
   ========================================================================== */

body {
  background: var(--studio-bg);
  color: var(--studio-text-main);
}

.studio-header,
.studio-sidebar,
.studio-footer,
.floating-toolbar,
.modal-card,
.dropdown-menu,
.hint-badge,
.zoom-controls,
.tool-panel {
  background: var(--studio-panel-bg);
  border-color: var(--studio-panel-border);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.studio-header {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(360px, 1fr);
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--studio-panel-border);
}

.logo-area {
  grid-column: 2;
  justify-self: center;
  gap: 10px;
}

.header-actions {
  grid-column: 3;
  justify-self: end;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--studio-border-strong, #3a3a3a);
  border-radius: 0;
  box-shadow: none;
  color: var(--studio-text-main);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.logo-text .brand {
  background: none;
  color: var(--studio-text-main);
  -webkit-background-clip: initial;
  -webkit-text-fill-color: currentColor;
  font-family: var(--font-ui);
  font-size: 0.98rem;
  letter-spacing: 0;
}

.logo-text .sub-brand,
.hint-badge,
#zoom-level,
.section-title,
.tab-btn,
.tool-category,
.footer-left,
.footer-right,
.theme-name,
.preset-info p {
  color: var(--studio-text-muted);
}

.aspect-ratio-selector,
.zoom-controls,
.hint-badge {
  background: #101010;
  border: 1px solid var(--studio-panel-border);
  border-radius: 0;
}

.ratio-btn,
.action-btn,
.dropdown-menu button,
.zoom-controls button,
.ft-btn,
.btn-full,
.tab-btn,
.sidebar-toggle,
.close-icon-btn {
  border-radius: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ratio-btn {
  color: var(--studio-text-muted);
}

.ratio-btn:hover,
.ratio-btn.active,
.zoom-controls button:hover,
.dropdown-menu button:hover,
.ft-btn:hover,
.tab-btn:hover,
.tab-btn.active,
.secondary-outline:hover {
  background: var(--studio-panel-hover);
  color: var(--studio-text-main);
  box-shadow: none;
}

.ratio-btn.active,
.tab-btn.active {
  border-color: var(--studio-border-strong, #3a3a3a);
}

.action-btn {
  border: 1px solid var(--studio-panel-border);
  background: #101010;
  color: var(--studio-text-main);
  box-shadow: none;
}

.action-btn.secondary,
.action-btn.primary {
  background: #101010;
  border: 1px solid var(--studio-panel-border);
  color: var(--studio-text-main);
  box-shadow: none;
}

.action-btn.secondary:hover,
.action-btn.primary:hover {
  background: var(--studio-panel-hover);
  border-color: var(--studio-border-strong, #3a3a3a);
  transform: none;
  box-shadow: none;
}

.dropdown-menu {
  width: 272px;
  background: #171717;
  border: 1px solid var(--studio-panel-border);
  padding: 6px;
}

.dropdown-menu .divider,
.sidebar-tabs,
.section-title,
.modal-header,
.modal-footer,
.studio-footer {
  border-color: var(--studio-panel-border);
}

.dropdown-menu button i,
.hint-badge i,
.modal-header h3 i {
  color: var(--studio-text-muted);
}

.studio-workspace,
.stage-container {
  background: var(--studio-bg);
}

.stage-container::before {
  background-image: none;
}

.stage-controls {
  top: 18px;
  left: 18px;
  right: 18px;
}

.stage-control-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-controls .aspect-ratio-selector {
  padding: 0;
}

.stage-controls .ratio-btn {
  min-height: 34px;
  padding: 0 10px;
}

.stage-controls .hint-badge {
  min-height: 34px;
  padding: 0 10px;
}

.title-card-wrapper {
  box-shadow: 0 0 0 1px var(--studio-panel-border);
}

.card-text-block:hover:not(.is-selected):not(.is-editing),
.card-text-block.is-selected,
.card-text-block.is-editing {
  border-color: var(--studio-text-main);
  box-shadow: none;
}

.snap-guide-h,
.snap-guide-v {
  border-color: var(--studio-yellow);
  box-shadow: none;
}

.floating-toolbar {
  background: #171717;
  border: 1px solid var(--studio-panel-border);
  padding: 6px;
}

.floating-toolbar .ft-actions {
  gap: 6px;
}

.ft-btn.ft-btn-text {
  width: auto;
  min-width: 46px;
  padding: 0 10px;
  color: var(--studio-text-main);
  font-weight: 700;
}

.floating-toolbar::after {
  display: none;
}

.floating-toolbar select,
.floating-toolbar input[type="number"],
.control-group input[type="text"],
.control-group textarea,
.control-group select,
.hex-input,
.search-box {
  background: #101010;
  border: 1px solid var(--studio-panel-border);
  border-radius: 0;
  color: var(--studio-text-main);
  box-shadow: none;
}

.floating-toolbar select:focus,
.floating-toolbar input[type="number"]:focus,
.control-group input[type="text"]:focus,
.control-group textarea:focus,
.control-group select:focus,
.hex-input:focus {
  border-color: var(--studio-border-strong, #3a3a3a);
  box-shadow: none;
}

input[type="range"] {
  background: #101010;
  border: 1px solid var(--studio-panel-border);
  border-radius: 0;
}

input[type="range"]::-webkit-slider-thumb {
  background: var(--studio-text-main);
  border-radius: 0;
  box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--studio-text-main);
  box-shadow: none;
  transform: none;
}

.switch {
  border: 1px solid var(--studio-panel-border);
}

.slider.round,
.slider.round:before,
input:checked + .slider.round,
input:checked + .slider.round:before {
  border-radius: 0;
}

.slider.round {
  background: #101010;
}

.slider.round:before {
  background: var(--studio-text-muted);
}

input:checked + .slider.round {
  background: var(--studio-panel-hover);
}

input:checked + .slider.round:before {
  background: var(--studio-green);
}

.studio-sidebar {
  background: #171717;
  border-right: 1px solid var(--studio-panel-border);
  border-left: 0;
  width: 348px;
}

.sidebar-tabs {
  background: #101010;
}

.tab-btn {
  min-height: 44px;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  padding: 0 8px;
}

.tab-btn.active {
  border-bottom-color: var(--studio-border-strong, #3a3a3a);
}

.tab-content {
  padding: 18px;
  gap: 13px;
}

.section-title {
  margin: 6px 0 0;
  padding-bottom: 8px;
  color: var(--studio-text-main);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.control-group,
.slider-group {
  gap: 7px;
}

.control-group label,
.slider-group label,
.toggle-group label {
  color: var(--studio-text-muted);
}

.control-group input[type="text"],
.control-group textarea,
.control-group select {
  min-height: 38px;
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--studio-panel-border);
}

.theme-card,
.preset-item,
.local-aside,
.preview-box,
.progress-bar-wrapper,
.secondary-outline {
  background: #101010;
  border: 1px solid var(--studio-panel-border);
  border-radius: 0;
  box-shadow: none;
}

.theme-card:hover,
.theme-card.active,
.preset-item:hover {
  border-color: var(--studio-border-strong, #3a3a3a);
  background: var(--studio-panel-hover);
  box-shadow: none;
  transform: none;
}

.theme-preview,
.preset-thumb {
  border-bottom: 1px solid var(--studio-panel-border);
}

input[type="color"],
input[type="color"]::-webkit-color-swatch,
input[type="color"]::-webkit-color-swatch-wrapper,
.floating-toolbar input[type="color"],
.floating-toolbar input[type="color"]::-webkit-color-swatch {
  border-radius: 0;
}

.modal-overlay {
  background: rgba(16, 16, 16, 0.88);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.modal-card {
  background: #171717;
  border: 1px solid var(--studio-panel-border);
}

.modal-overlay.open .modal-card,
.modal-card {
  transform: none;
}

.progress-bar-fill {
  background: var(--studio-text-main);
  border-radius: 0;
}

.studio-footer {
  background: #101010;
  border-top: 1px solid var(--studio-panel-border);
}

kbd,
.status-indicator.online {
  border-radius: 0;
}

kbd {
  background: #171717;
  border: 1px solid var(--studio-panel-border);
}

/* ==========================================================================
   8. RESPONSIVE ADAPTATIONS
   ========================================================================== */

@media (max-width: 1280px) {
  .studio-sidebar { width: 320px; }
  .title-card-wrapper { transform: scale(0.85); }
}

@media (max-width: 1024px) {
  .studio-workspace { flex-direction: column; }
  .studio-sidebar { width: 100%; height: 320px; border-right: 0; border-left: 0; border-bottom: 1px solid var(--studio-panel-border); }
  .title-card-wrapper { transform: scale(0.65); }
}
