/* ==========================================
   全域 CSS 變數 - 提升對比度與辨識度
   ========================================== */
:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-title: 'Cinzel', serif;
  
  --bg-color: #0f172a;               /* 深藍黑背景 */
  --card-bg: #1e293b;                 /* 明亮灰藍卡片面板 */
  --card-border: #334155;             /* 高對比邊框 */
  --card-hover-border: #d4af37;       /* 懸停金色 Highlight */
  
  --primary: #d4af37;                 /* 主題金 */
  --primary-hover: #f59e0b;
  --text-main: #f8fafc;               /* 純白文字 */
  --text-muted: #cbd5e1;              /* 淺灰次要文字 */
  
  --input-bg: #0f172a;                /* 深色清晰輸入框背景 */
  --input-border: #475569;            /* 明亮輸入框邊框 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px 15px;
}

.container {
  max-width: 1040px;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
}

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

header { grid-column: 1 / -1; margin-bottom: 5px; border-bottom: 2px solid var(--card-border); padding-bottom: 12px; }
header h1 { font-family: var(--font-title); font-size: 24px; letter-spacing: 0.08em; color: var(--primary); font-weight: 700; }
header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.section-title {
  font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--primary); margin: 20px 0 12px 0; display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }

/* 動態選單網格 */
.tab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 16px; }

.grid-card {
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-main);
  transition: all 0.2s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.grid-card:hover { border-color: var(--primary); color: #fff; background: rgba(212, 175, 55, 0.1); }
.grid-card.active { background: var(--primary); border-color: var(--primary); color: #0f172a; font-weight: 700; }

.card-icon { font-size: 1rem; }

/* 表單元件 */
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="password"], textarea, select {
  width: 100%; background: var(--input-bg); border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm); padding: 10px 12px; color: #fff;
  font-family: inherit; font-size: 0.9rem; transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2); }
textarea { resize: vertical; height: 65px; }

input[type="color"] {
  width: 100%; height: 40px; background: var(--input-bg); border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm); cursor: pointer; padding: 2px;
}

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

/* 右側預覽區域 */
.preview-section {
  background: #0f172a; border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md); padding: 25px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}

#canvas-container {
  position: relative; margin-bottom: 20px;
  padding: 12px; background: #ffffff; border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}
canvas { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); }

.hidden { display: none !important; }

/* ==========================================
   品質滑桿控制項
   ========================================== */

.quality-control-wrapper {
  width: 100%;
  margin-top: 10px;
  margin-bottom: 18px;
}

#size-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
  margin-bottom: 12px;
}

#size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00a8ea;
  border: 4px solid #ffffff;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
  cursor: pointer;
}

.quality-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.quality-tag {
  color: #94a3b8;
  font-weight: 500;
}

.resolution-display {
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ==========================================
   格式選擇與整合下載按鈕
   ========================================== */

.download-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.format-pills {
  display: flex;
  gap: 8px;
  width: 100%;
}

.format-pill {
  flex: 1;
  padding: 8px 0;
  background: #1e293b;
  border: 1.5px solid #00a8ea;
  color: #00a8ea;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.format-pill:hover {
  background: rgba(0, 168, 234, 0.15);
}

.format-pill.active {
  background: #00a8ea;
  color: #ffffff;
  border-color: #00a8ea;
  box-shadow: 0 0 10px rgba(0, 168, 234, 0.4);
}

.btn-download-main {
  width: 100%;
  padding: 14px;
  background-color: #00a8ea;
  color: #ffffff;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 168, 234, 0.3);
}

.btn-download-main:hover {
  background-color: #0093ce;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 168, 234, 0.4);
}

.btn-download-main:active {
  transform: translateY(0);
}