/* ==========================================================================
   Creator Studio AI — Design editor & image tool workspaces
   ========================================================================== */

.editor { display: flex; flex-direction: column; gap: 14px; }
.editor-topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 16px;
}
.editor-topbar .tb-title { display: flex; flex-direction: column; margin-right: auto; min-width: 0; padding: 0 6px; }
.editor-topbar .tb-title strong { font-family: var(--font-display); font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.editor-topbar .tb-title span { font-size: 0.75rem; color: var(--muted); }
.tb-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-sep { width: 1px; height: 26px; background: var(--border); margin: 0 2px; }
.export-group { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.export-group .select { width: auto; }

.editor-body { display: grid; grid-template-columns: 300px minmax(0, 1fr) 290px; gap: 14px; align-items: start; }
.editor-panel { border-radius: 18px; padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - var(--header-h) - 120px); position: sticky; top: calc(var(--header-h) + 14px); }
.panel-scroll { overflow-y: auto; padding: 16px; scrollbar-width: thin; flex: 1; }
.panel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.panel-tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font: 600 0.72rem/1 var(--font); cursor: pointer; transition: all 0.2s;
}
.panel-tabs button .icon { width: 18px; height: 18px; }
.panel-tabs button:hover { background: var(--surface-3); color: var(--text); }
.panel-tabs button[aria-selected="true"] { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }
.panel-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; margin: 0 0 10px; }
.panel-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.panel-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-row > label, .prop-label { font-size: 0.8rem; color: var(--text-2); min-width: 74px; font-weight: 500; }
.panel-row .input, .panel-row .select { height: 36px; font-size: 0.85rem; border-radius: 10px; }
.panel-row .select { padding-right: 30px; background-position: right 8px center; }
.panel-row .num { width: 72px; flex: none; text-align: center; padding: 0 6px; }
.panel-row input[type="range"] { flex: 1; }
.panel-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.panel-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.panel-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font: 600 0.74rem/1.2 var(--font); cursor: pointer; transition: all 0.2s; text-align: center;
}
.tool-tile:hover { border-color: rgba(139, 92, 246, 0.5); color: var(--text); background: var(--grad-soft); transform: translateY(-1px); }
.tool-tile .icon { width: 22px; height: 22px; color: var(--primary-2); }
.tool-tile svg.shape-ico { width: 26px; height: 26px; fill: currentColor; stroke: none; color: var(--primary-2); }
.mini-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; font: 700 0.9rem/1 var(--font); transition: all 0.2s; }
.mini-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.mini-toggle[aria-pressed="true"] { background: var(--grad); color: #fff; border-color: transparent; }
.mini-toggle .icon { width: 17px; height: 17px; }

.text-preset {
  display: flex; align-items: center; justify-content: center; height: 64px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: #15151f; transition: all 0.2s; overflow: hidden; padding: 0 6px;
  font-size: 1.15rem; line-height: 1; text-transform: uppercase; text-align: center;
}
.text-preset:hover { border-color: rgba(139, 92, 246, 0.6); transform: translateY(-2px); box-shadow: var(--glow); }
.tp-yellow { font-family: "Anton", sans-serif; color: #fde047; -webkit-text-stroke: 1.2px #000; text-shadow: 3px 3px 0 #000; background: linear-gradient(135deg, #312e81, #1e1b4b); }
.tp-white { font-family: "Montserrat", sans-serif; font-weight: 900; color: #fff; text-shadow: 0 3px 10px rgba(0, 0, 0, 0.7); background: linear-gradient(135deg, #0f172a, #334155); }
.tp-red { font-family: "Bebas Neue", sans-serif; font-size: 1.5rem; color: #fff; background: #111; }
.tp-red span { background: #ef4444; padding: 4px 8px; border-radius: 4px; }
.tp-neon { font-family: "Poppins", sans-serif; font-weight: 800; color: #67e8f9; text-shadow: 0 0 8px #22d3ee, 0 0 18px #22d3ee; background: #030712; }
.tp-grad { font-family: "Archivo Black", sans-serif; background: #0b0b12; }
.tp-grad span { background: linear-gradient(180deg, #fde047, #f97316); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tp-telugu { font-family: "Ramabhadra", "Noto Sans Telugu", sans-serif; color: #fff; -webkit-text-stroke: 0.8px #000; text-shadow: 2px 2px 0 #b91c1c; background: linear-gradient(135deg, #7c2d12, #c2410c); text-transform: none; font-size: 1.05rem; }

.template-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.template-cats .chip { padding: 5px 10px; font-size: 0.76rem; }
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.template-grid.vertical { grid-template-columns: 1fr 1fr 1fr; }
.template-card { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; padding: 0; transition: all 0.2s; }
.template-card:hover { border-color: rgba(139, 92, 246, 0.7); transform: translateY(-2px); box-shadow: var(--glow); }
.template-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--surface-3); }
.template-grid.vertical .template-card img { aspect-ratio: 9 / 16; }
.template-card span { display: block; padding: 6px 8px; font-size: 0.72rem; color: var(--text-2); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-skeleton { aspect-ratio: 16 / 9; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.template-grid.vertical .template-skeleton { aspect-ratio: 9 / 16; }
@keyframes shimmer { to { background-position: -200% 0; } }
.gradient-presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.gradient-presets button { aspect-ratio: 1; border-radius: 9px; border: 1px solid var(--border-strong); cursor: pointer; transition: transform 0.2s; }
.gradient-presets button:hover { transform: scale(1.08); }

/* Stage */
.editor-stage-wrap { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.editor-stage {
  position: relative; border-radius: 18px; padding: 16px; display: flex; align-items: center; justify-content: center;
  min-height: 320px; background-color: var(--bg-3); border: 1px solid var(--border); overflow: hidden;
  background-image: radial-gradient(circle at 1px 1px, rgba(140, 140, 170, 0.18) 1px, transparent 0); background-size: 22px 22px;
}
.canvas-holder { position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); border-radius: 4px; line-height: 0; }
.canvas-holder .canvas-container { border-radius: 4px; }
.guide-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.guide-box { position: absolute; border: 2px dashed rgba(34, 211, 238, 0.95); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
.guide-shade { position: absolute; background: rgba(0, 0, 0, 0.42); }
.guide-zone { position: absolute; background: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.22) 0 10px, rgba(239, 68, 68, 0.08) 10px 20px); border: 1px dashed rgba(239, 68, 68, 0.8); }
.guide-line { position: absolute; background: rgba(255, 255, 255, 0.45); }
.guide-label { position: absolute; font: 700 10px/1 var(--font); color: #fff; background: rgba(0, 0, 0, 0.65); padding: 4px 6px; border-radius: 5px; white-space: nowrap; letter-spacing: 0.02em; }
.stage-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); padding: 0 4px; }
.stage-footer .chips { gap: 6px; }
.stage-footer .chip { padding: 5px 11px; font-size: 0.76rem; }
.stage-empty { position: absolute; inset: 16px; display: grid; place-items: center; z-index: 6; }
.stage-drop-hint { position: absolute; inset: 8px; border: 2px dashed var(--primary); border-radius: 14px; background: rgba(139, 92, 246, 0.15); display: none; place-items: center; z-index: 10; font-weight: 700; color: var(--text); }
.editor-stage.is-dragover .stage-drop-hint { display: grid; }
.draft-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

/* Properties */
.props-empty { text-align: center; padding: 26px 8px; color: var(--muted); font-size: 0.86rem; }
.props-empty .icon { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--primary-2); opacity: 0.8; }
.props-empty ul { text-align: left; font-size: 0.8rem; padding-left: 18px; margin: 14px 0 0; }
.props-empty kbd, .kbd { font: 600 0.72rem var(--mono); padding: 2px 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); }
.prop-textarea { min-height: 76px; font-size: 0.95rem; font-family: var(--font); }
.font-select { font-size: 0.85rem; }

/* Layers */
.layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.layer-item { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 0.82rem; transition: all 0.15s; }
.layer-item.is-active { border-color: rgba(139, 92, 246, 0.7); background: var(--grad-soft); }
.layer-item .layer-name { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--text); font: 500 0.82rem var(--font); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 0; }
.layer-item .layer-kind { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; flex: none; }
.layer-item .lbtn { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.layer-item .lbtn:hover { background: var(--surface-3); color: var(--text); }
.layer-item .lbtn .icon { width: 14px; height: 14px; }
.layer-item.is-hidden .layer-name { opacity: 0.45; }

/* Projects modal */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.project-card { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; }
.project-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-3); }
.project-card.vertical img { aspect-ratio: 9 / 16; max-height: 220px; object-fit: contain; background: #000; }
.project-card .pc-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.project-card strong { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card small { color: var(--muted); font-size: 0.74rem; }

/* ---------- Image tools ---------- */
.compare { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); user-select: none; touch-action: none; background: #000; }
.compare img { width: 100%; display: block; max-height: none; }
.compare .c-after { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.compare .compare-handle { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.6); transform: translateX(-50%); cursor: ew-resize; }
.compare .compare-handle::after { content: "⇆"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 1rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
.compare .compare-tag { position: absolute; top: 10px; font: 700 0.72rem var(--font); color: #fff; background: rgba(0, 0, 0, 0.6); padding: 4px 8px; border-radius: 6px; }
.compare .tag-before { left: 10px; }
.compare .tag-after { right: 10px; }
.compare input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }

.crop-stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; line-height: 0; }
.crop-stage img { max-width: 100%; max-height: 560px; display: block; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); cursor: move; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; border: 0 solid rgba(255, 255, 255, 0.45); pointer-events: none; }
.crop-box::before { left: 33.33%; right: 33.33%; top: 0; bottom: 0; border-left-width: 1px; border-right-width: 1px; }
.crop-box::after { top: 33.33%; bottom: 33.33%; left: 0; right: 0; border-top-width: 1px; border-bottom-width: 1px; }
.crop-handle { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid var(--primary); border-radius: 50%; z-index: 2; }
.crop-handle[data-h="nw"] { left: -9px; top: -9px; cursor: nwse-resize; }
.crop-handle[data-h="ne"] { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-handle[data-h="sw"] { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-handle[data-h="se"] { right: -9px; bottom: -9px; cursor: nwse-resize; }
.crop-handle[data-h="n"] { left: 50%; top: -9px; margin-left: -8px; cursor: ns-resize; }
.crop-handle[data-h="s"] { left: 50%; bottom: -9px; margin-left: -8px; cursor: ns-resize; }
.crop-handle[data-h="w"] { top: 50%; left: -9px; margin-top: -8px; cursor: ew-resize; }
.crop-handle[data-h="e"] { top: 50%; right: -9px; margin-top: -8px; cursor: ew-resize; }
.crop-size { position: absolute; left: 0; top: -28px; font: 600 11px/1 var(--font); background: rgba(0, 0, 0, 0.7); color: #fff; padding: 5px 7px; border-radius: 6px; white-space: nowrap; }

.file-rows { display: flex; flex-direction: column; gap: 10px; }
.file-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); animation: fadeUp 0.3s var(--ease) both; }
.file-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--surface-3); }
.file-row .fr-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fr-meta { font-size: 0.78rem; color: var(--muted); }

/* ---------- Planner ---------- */
.planner-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 16px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h2 { margin: 0 6px; font-size: 1.25rem; min-width: 170px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: center; font-weight: 700; padding: 6px 0; }
.cal-day { min-height: 116px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: border-color 0.2s, background 0.2s; min-width: 0; }
.cal-day:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cal-day.is-other { opacity: 0.4; }
.cal-day.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day.is-dragover { background: var(--grad-soft); border-color: var(--primary); }
.cal-num { font-size: 0.8rem; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.cal-num .add { opacity: 0; font-size: 1rem; color: var(--primary-2); transition: opacity 0.2s; }
.cal-day:hover .cal-num .add { opacity: 1; }
.cal-entry { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--primary); background: var(--surface-3); color: var(--text); font: 500 0.72rem/1.25 var(--font); padding: 4px 6px; border-radius: 6px; cursor: grab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-entry:hover { background: var(--grad-soft); }
.cal-more { font-size: 0.7rem; color: var(--muted); padding-left: 4px; }
.st-draft { border-left-color: #94a3b8 !important; }
.st-editing { border-left-color: #f59e0b !important; }
.st-scheduled { border-left-color: #3b82f6 !important; }
.st-published { border-left-color: #22c55e !important; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.draft { color: #94a3b8; }
.status-pill.editing { color: #f59e0b; }
.status-pill.scheduled { color: #60a5fa; }
.status-pill.published { color: #22c55e; }
.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.entry-row .er-date { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-row .er-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-row .er-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; font-size: 0.78rem; color: var(--muted); }

/* Chart */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { width: 100%; height: 300px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--text-2); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* Script output */
.scene { border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); overflow: hidden; animation: fadeUp 0.35s var(--ease) both; }
.scene-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-3); font-size: 0.84rem; }
.scene-head strong { font-family: var(--font-display); }
.scene-time { font: 600 0.76rem var(--mono); color: var(--primary-2); }
.scene-body { padding: 12px 14px; display: grid; gap: 8px; font-size: 0.88rem; }
.scene-body div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.scene-body b { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 2px; }
.scene-body span { color: var(--text); white-space: pre-wrap; }

/* ---------- Editor responsive ---------- */
@media (max-width: 1280px) {
  .editor-body { grid-template-columns: 280px minmax(0, 1fr); }
  .editor-left { position: static; max-height: 720px; }
  .editor-right { grid-column: 1 / -1; position: static; max-height: none; }
  .editor-right .props-empty { grid-column: 1 / -1; }
  .editor-right .panel-scroll { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }
}
@media (max-width: 900px) {
  .editor-body { grid-template-columns: minmax(0, 1fr); }
  .editor-stage-wrap { order: -1; }
  .editor-panel { position: static; max-height: none; }
  .editor-left .panel-scroll { max-height: 460px; }
  .panel-tabs { grid-template-columns: repeat(6, 1fr); }
  .panel-tabs button { font-size: 0.66rem; padding: 7px 2px; }
  .editor-topbar .tb-title { width: 100%; }
  .editor-stage { padding: 10px; min-height: 220px; }
  .template-grid.vertical { grid-template-columns: repeat(4, 1fr); }
  .cal-day { min-height: 78px; padding: 4px; }
  .cal-entry { font-size: 0; padding: 0; height: 6px; border-left-width: 0; border-radius: 3px; }
  .cal-entry.st-draft { background: #94a3b8; }
  .cal-entry.st-editing { background: #f59e0b; }
  .cal-entry.st-scheduled { background: #3b82f6; }
  .cal-entry.st-published { background: #22c55e; }
  .cal-more { font-size: 0.62rem; }
  .entry-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .scene-body div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-width: 520px) {
  .editor-topbar .btn-sm span { display: none; }
  .editor-topbar .btn-sm { padding: 0 10px; }
  .template-grid.vertical { grid-template-columns: repeat(3, 1fr); }
  .file-row { grid-template-columns: 52px minmax(0, 1fr); }
  .file-row img { width: 52px; height: 52px; }
  .file-row .btn-row { grid-column: 1 / -1; }
  .month-nav h2 { min-width: 0; font-size: 1.05rem; }
}
