/* ═══════════════════════════════════════════════════
   Glitch Studio v6.0 - CSS
   配合 v6.0 HTML 結構
═══════════════════════════════════════════════════ */

@font-face {
  font-family: 'ChenYuluoyan';
  src: url('https://cdn.jsdelivr.net/gh/Chenyu-otf/chenyuluoyan_thin/ChenYuluoyan-2.0-Thin.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'NaikaiFont';
  src: url('https://cdn.jsdelivr.net/gh/max32002/naikaifont@1.89/webfont/NaikaiFont-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #0a0a0a;
  --b:  #2a2a2a;
  --t:  #e8e4dc;
  --m:  #888;
  --a:  #ff2244;
  --a2: #00ffcc;
  --ui-scale: 1;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--t);
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,.05) 3px, rgba(0,0,0,.05) 4px);
  pointer-events: none;
  z-index: 9999;
}

.hidden { display: none !important; }

/* ═══ App layout ═══ */
.app-wrap {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══ Header ═══ */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--b);
  flex-shrink: 0;
}

.logo-area { display: flex; align-items: center; }
.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 4px;
  line-height: 1;
  color: var(--t);
}
.logo .g1, .logo .s1 { color: var(--a); }
.logo .g2, .logo .s2 { color: var(--t); }
.logo .g3, .logo .s3 { color: var(--a2); }

.ui-sizes {
  display: flex;
  gap: 4px;
}
.us-btn {
  padding: 5px 14px;
  border: 1px solid var(--b);
  background: transparent;
  color: var(--m);
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  transition: all .15s;
}
.us-btn:hover { border-color: #555; color: var(--t); }
.us-btn.on { border-color: var(--a2); color: var(--a2); }

.dot-anim {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--a2);
  margin-left: auto;
  animation: bl 2s infinite;
}
@keyframes bl { 0%,100% {opacity:1} 50% {opacity:.2} }

/* ═══ Main layout ═══ */
.lay {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr calc(360px * var(--ui-scale));
  overflow: hidden;
}

/* ═══ Left pane (預覽) ═══ */
.left-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-right: 1px solid var(--b);
  gap: 12px;
  overflow: hidden;
}

.meta {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--m);
}
.meta span { color: var(--t); }

.dropzone {
  width: 100%;
  flex: 1;
  max-width: 900px;
  position: relative;
  background: #0c0c0c;
  border: 1px dashed #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color .2s;
}
.dropzone:hover { border-color: #444; }
.dropzone.has { border-style: solid; border-color: #1a1a1a; }

#cvs {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: none;
  touch-action: none;
}
#cvs.has-text { cursor: grab; }
#cvs.dragging-text { cursor: grabbing; }

#uploadPrompt {
  text-align: center;
  color: var(--m);
  font-size: 14px;
  letter-spacing: 1px;
}

/* Inline editor */
.inline-editor {
  position: absolute;
  border: 2px solid var(--a2);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 4px 8px;
  font-family: inherit;
  outline: none;
  resize: none;
  z-index: 100;
  box-shadow: 0 0 20px rgba(0,255,204,0.4);
  text-align: center;
  line-height: 1.2;
  border-radius: 2px;
}

/* ═══ Trim bar ═══ */
.trim-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trim-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--m);
  letter-spacing: 1px;
}
.trim-labels span:nth-child(2) { color: var(--a2); }

.trim-track {
  position: relative;
  height: 28px;
  background: #1a1a1a;
  border: 1px solid var(--b);
  cursor: pointer;
  user-select: none;
}
.trim-range {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(0, 255, 204, 0.15);
  border-left: 2px solid var(--a2);
  border-right: 2px solid var(--a2);
  pointer-events: none;
}
.trim-handle {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 14px;
  background: var(--a2);
  cursor: ew-resize;
  z-index: 2;
}
.trim-handle-start { transform: translateX(-100%); }
.trim-handle-end { transform: translateX(0); }
.trim-playhead {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 2px;
  background: var(--a);
  pointer-events: none;
  z-index: 1;
  transition: left .05s linear;
}

/* ═══ Progress bar ═══ */
.prog-bar {
  width: 100%;
  max-width: 900px;
  height: 24px;
  background: #1a1a1a;
  border: 1px solid var(--b);
  position: relative;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--a2);
  width: 0;
  transition: width .15s;
}

/* ═══ Right pane (控制面板) ═══ */
.right-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  zoom: var(--ui-scale);
}

/* ═══ Tabs ═══ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--b);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--m);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 2px;
  transition: all .15s;
}
.tab:hover { color: var(--t); }
.tab.on { color: var(--a2); border-bottom-color: var(--a2); }

/* ═══ Panel ═══ */
.panel {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  display: none;
  padding: 12px;
}
.panel.on { display: block; }
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: var(--b); }

.section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--b);
}
.section:last-child { border-bottom: none; }
.section h4 {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--a2);
  margin-bottom: 8px;
  font-weight: bold;
}

/* ═══ FX grid (特效按鈕) ═══ */
.fx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
}
.fx-btn {
  padding: 10px 4px;
  border: 1px solid var(--b);
  background: transparent;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all .15s;
}
.fx-btn:hover { border-color: #444; }
.fx-btn.on { border-width: 2px; }
.fx-btn .label {
  font-size: 11px;
  color: var(--m);
  letter-spacing: 1px;
}
.fx-btn .fx-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--t);
}

.fx-btn.fx-film.on  { border-color: #f5c842; background: rgba(245,200,66,.05); } .fx-film.on  .fx-name { color: #f5c842; }
.fx-btn.fx-cyber.on { border-color: #00e5ff; background: rgba(0,229,255,.05); } .fx-cyber.on .fx-name { color: #00e5ff; }
.fx-btn.fx-retro.on { border-color: #ff6b00; background: rgba(255,107,0,.05); } .fx-retro.on .fx-name { color: #ff6b00; }
.fx-btn.fx-err.on   { border-color: #ff2244; background: rgba(255,34,68,.05); } .fx-err.on   .fx-name { color: #ff2244; }
.fx-btn.fx-cctv.on  { border-color: #aaffaa; background: rgba(170,255,170,.05); } .fx-cctv.on .fx-name { color: #aaffaa; }
.fx-btn.fx-hack.on  { border-color: #00ff41; background: rgba(0,255,65,.05); } .fx-hack.on .fx-name { color: #00ff41; }

/* ═══ FX 強度 table ═══ */
.fxc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}
.fxc-table td {
  padding: 4px;
  font-size: 11px;
}
.fxc-table td.label {
  color: var(--m);
  letter-spacing: 1px;
  width: 60px;
}
.fxc-table td:last-child {
  width: 40px;
  text-align: right;
  color: var(--t);
}
.fxc-table input[type=range] {
  width: 100%;
}

/* ═══ 可編輯數值輸入框（取代純顯示 span） ═══ */
.num-val {
  width: 34px;
  padding: 1px 2px;
  text-align: right;
  font-size: 11px;
  font-family: inherit;
  color: var(--t);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  -moz-appearance: textfield;
  appearance: textfield;
  cursor: text;
}
.num-val::-webkit-outer-spin-button,
.num-val::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.num-val:hover { border-color: var(--b); }
.num-val:focus {
  outline: none;
  border-color: var(--a2);
  background: rgba(0,0,0,.4);
}
.num-unit {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
}
.num-unit i { font-style: normal; color: var(--m); margin-left: 1px; }

/* ═══ 預覽下方常駐控制列 ═══ */
.preview-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}
.pv-btn {
  padding: 8px 20px;
  background: var(--b);
  color: var(--t);
  border: 1px solid var(--b);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.pv-btn:hover { border-color: #555; }

/* ═══ ⚙ 各特效進階設定面板 ═══ */
.adv-panel {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--b);
  border-radius: 3px;
  background: rgba(0,0,0,.25);
}
.adv-panel:empty { display: none; }
.adv-panel h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--a2);
  letter-spacing: 1px;
}
.adv-row { margin-bottom: 8px; font-size: 12px; }
.adv-row:last-child { margin-bottom: 0; }
.adv-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--t);
}
.adv-slider {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 8px;
  align-items: center;
}
.adv-slider .adv-label { color: var(--m); }
.adv-select {
  background: var(--b);
  color: var(--t);
  border: 1px solid var(--b);
  border-radius: 2px;
  padding: 3px 4px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

/* ═══ Range slider 通用樣式 ═══ */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--b);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--t);
  cursor: pointer;
  border: 2px solid var(--bg);
}
input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--t);
  cursor: pointer;
  border: 2px solid var(--bg);
}

/* ═══ Focus / Align / Effect / Lang / Font / Dur / Res / Qual buttons ═══ */
.focus-btn, .align-btn, .valign-btn, .effect-btn, .lang-btn,
.font-btn, .dur-btn, .res-btn, .qual-btn, .style-btn {
  padding: 8px 4px;
  border: 1px solid var(--b);
  background: transparent;
  color: var(--m);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  transition: all .15s;
}
.focus-btn:hover, .align-btn:hover, .valign-btn:hover,
.effect-btn:hover, .lang-btn:hover, .font-btn:hover,
.dur-btn:hover, .res-btn:hover, .qual-btn:hover, .style-btn:hover {
  border-color: #555;
  color: var(--t);
}
.focus-btn.on, .align-btn.on, .valign-btn.on,
.effect-btn.on, .lang-btn.on, .font-btn.on,
.dur-btn.on, .res-btn.on, .qual-btn.on, .style-btn.on {
  border-color: var(--a2);
  color: var(--a2);
}

/* style-btn 特別：粗體/斜體用對應字型 */
.style-btn[data-style="bold"] { font-weight: bold; }
.style-btn[data-style="italic"] { font-style: italic; }
.style-btn[data-style="underline"] { text-decoration: underline; }

/* Color swatches */
.sw {
  width: 28px; height: 28px;
  border: 1px solid var(--b);
  cursor: pointer;
  flex-shrink: 0;
}
.sw:hover { border-color: #aaa; }
.sw.on { border: 2px solid var(--a2) !important; }

/* ═══ 段落清單 ═══ */
.txt-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--b);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--m);
  transition: all .15s;
}
.txt-row:hover { background: rgba(255,255,255,0.02); color: var(--t); }
.txt-row.on { color: var(--a2); background: rgba(0,255,204,0.05); }
.txt-row .preview {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txt-row .preview.empty { color: var(--m); font-style: italic; }
.txt-row .del, .txt-row .layer-btn {
  background: transparent;
  border: 1px solid var(--b);
  color: var(--m);
  padding: 0 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  line-height: 1;
  height: 20px;
  flex-shrink: 0;
}
.txt-row .del:hover { color: var(--a); border-color: var(--a); }
.txt-row .layer-btn:hover:not(:disabled) { color: var(--a2); border-color: var(--a2); }
.txt-row .layer-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══ Details (進階) ═══ */
details summary {
  outline: none;
  padding: 6px 0;
}
details[open] summary { margin-bottom: 8px; }
details label {
  font-size: 11px;
  color: var(--m);
  letter-spacing: 1px;
}

/* ═══ Inputs 通用 ═══ */
textarea, input[type=number], input[type=text] {
  background: #0c0c0c !important;
  border: 1px solid var(--b) !important;
  color: var(--t) !important;
  border-radius: 2px;
  outline: none;
  font-family: 'Share Tech Mono', monospace;
}
textarea:focus, input[type=number]:focus, input[type=text]:focus {
  border-color: var(--a2) !important;
}

input[type=color] {
  border: 1px solid var(--b);
  background: transparent;
  cursor: pointer;
}

input[type=checkbox] {
  cursor: pointer;
  accent-color: var(--a2);
}

/* ═══ Info button (ℹ 關於) — header 右側 ═══ */
.info-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--b);
  color: var(--m);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
.info-btn:hover {
  border-color: var(--a2);
  color: var(--a2);
  box-shadow: 0 0 8px rgba(0, 255, 204, 0.3);
}

/* ═══ Site footer — 低調列 ═══ */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-top: 1px solid var(--b);
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: var(--m);
  flex-wrap: wrap;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
}
.footer-tool-name {
  color: var(--a2);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.footer-author { color: var(--t); }
.footer-divider { color: var(--b); opacity: 0.8; }
.site-footer a {
  color: var(--m);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
}
.site-footer a:hover {
  color: var(--a2);
  background: rgba(0, 255, 204, 0.08);
}

/* ═══ About dialog ═══ */
.about-dialog {
  background: var(--bg);
  border: 1px solid var(--a2);
  color: var(--t);
  border-radius: 4px;
  max-width: 460px;
  width: calc(100% - 32px);
  padding: 0;
  box-shadow:
    0 0 0 1px rgba(0, 255, 204, 0.15),
    0 30px 80px -10px rgba(0, 0, 0, 0.8),
    0 0 60px -10px rgba(0, 255, 204, 0.25);
}
.about-dialog::backdrop {
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.about-form {
  position: relative;
  padding: 26px 28px 22px;
}
.about-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--m);
  font-size: 22px;
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}
.about-close:hover {
  color: var(--a);
  background: rgba(255, 34, 68, 0.12);
}
.about-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--a2);
  margin: 0 0 12px;
  font-weight: 400;
}
.about-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--t);
  margin-bottom: 14px;
}
.about-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.about-link,
.about-tool {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--b);
  border-radius: 2px;
  color: var(--m);
  text-decoration: none;
  font-size: 12.5px;
  transition: all 0.15s ease;
}
.about-link:hover,
.about-tool:not(.about-tool-current):hover {
  background: rgba(0, 255, 204, 0.06);
  border-color: var(--a2);
  color: var(--t);
}
/* 作者連結首欄需容納「Threads (FFXIV 創作)」標籤 */
.about-link { grid-template-columns: minmax(135px, max-content) 1fr auto; }
.about-link:focus-visible,
.site-footer a:focus-visible {
  outline: 2px solid var(--a2);
  outline-offset: 2px;
}
.about-platform {
  color: var(--a2);
  font-weight: 600;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.about-handle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: inherit;
}
.about-arrow { color: var(--m); transition: color 0.15s, transform 0.15s; }
.about-link:hover .about-arrow,
.about-tool:hover .about-tool-arrow { color: var(--a2); transform: translateX(2px); }
.about-msg {
  font-size: 12px;
  color: var(--m);
  line-height: 1.95;
  text-align: center;
  font-style: italic;
  padding: 8px 4px 2px;
  letter-spacing: 0.04em;
}
.about-sep {
  margin: 18px 0;
  border: none;
  border-top: 1px dashed var(--b);
}
.about-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-tool {
  grid-template-columns: 28px 1fr auto;
}
.about-tool-icon {
  font-size: 18px;
  text-align: center;
  user-select: none;
}
.about-tool-name {
  color: inherit;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.about-tool-arrow {
  color: var(--m);
  font-size: 13px;
  transition: color 0.15s, transform 0.15s;
}
.about-tool-current {
  cursor: default;
  border-color: var(--a);
  background: rgba(255, 34, 68, 0.06);
  color: var(--t);
}
.about-tool-badge {
  font-size: 10px;
  color: var(--a);
  border: 1px solid var(--a);
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.08em;
}

/* ═══ Mobile block — 僅支援桌面 (≥1024px) ═══ */
#mobile-block {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg);
  color: var(--t);
  text-align: center;
  padding: 32px;
  text-decoration: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Share Tech Mono', monospace;
  cursor: pointer;
}
#mobile-block.show { display: flex; }
#mobile-block .block-icon {
  font-size: 56px;
  margin-bottom: 22px;
  line-height: 1;
}
#mobile-block h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--a2);
  margin-bottom: 14px;
  letter-spacing: 0.12em;
  font-weight: 400;
}
#mobile-block p {
  color: var(--m);
  font-size: 14px;
  line-height: 1.9;
  margin: 0;
}
#mobile-block .block-hint {
  color: var(--b);
  font-size: 12px;
  margin-top: 24px;
  letter-spacing: 0.05em;
}
