@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600&family=Noto+Sans+TC:wght@300;400;500;700&family=Cinzel:wght@400;700&family=Ma+Shan+Zheng&family=Great+Vibes&display=swap");

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Dark Mode */
  --bg-deep: #0a0a0c;
  --glass-bg: rgba(18, 18, 24, 0.95);
  --glass-border: rgba(255, 255, 255, 0.1);
  --section-bg: rgba(255, 255, 255, 0.04);
  --text-main: #f0f0f0;
  --text-muted: #999;
  --primary-gradient: linear-gradient(135deg, #7c4dff 0%, #00e5ff 100%);
  --glow-color: #00e5ff;
  --panel-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --canvas-bg: #000;
  --guide-color: rgba(255, 255, 255, 0.4);
  --canvas-glow-fixed: rgba(0, 229, 255, 0.2);
  --highlight-border: rgba(0, 229, 255, 0.5);
  --highlight-bg: rgba(0, 229, 255, 0.05);
}

[data-theme="light"] {
  /* Light Mode */
  --bg-deep: #f5f5f7;
  --glass-bg: rgba(255, 255, 255, 0.98);
  --glass-border: rgba(0, 0, 0, 0.08);
  --section-bg: rgba(0, 0, 0, 0.02);
  --text-main: #1d1d1f;
  --text-muted: #666;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --glow-color: #764ba2;
  --panel-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --canvas-bg: #fff;
  --guide-color: rgba(0, 0, 0, 0.25);
  --canvas-glow-fixed: rgba(118, 75, 162, 0.15);
  --highlight-border: rgba(118, 75, 162, 0.4);
  --highlight-bg: rgba(118, 75, 162, 0.05);
}

body {
  font-family: "Noto Sans TC", "Montserrat", sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.4s ease;
}

header {
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}
.header-left,
.header-right {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-right {
  justify-content: flex-end;
}
.header-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin: 0;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.brand-en {
  font-family: "Cinzel", serif;
  font-size: 1.8rem;
  letter-spacing: 0.15em;
  font-weight: 700;
}
.brand-cn {
  font-family: "Noto Sans TC", serif;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.6em;
  margin-top: 2px;
  opacity: 0.9;
  text-indent: 0.6em;
}
.subtitle {
  font-family: "Montserrat", "Noto Sans TC", sans-serif;
  letter-spacing: 2px;
  font-size: 0.7rem;
  margin-top: 5px;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
}

/* 語言選單 */
.lang-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 5px;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 0 10px;
  height: 36px;
  transition: 0.3s;
}
.lang-select-wrapper:hover {
  background: var(--section-bg);
  border-color: var(--glow-color);
}
.globe-icon {
  width: 16px;
  height: 16px;
  margin-right: 5px;
  opacity: 0.8;
}
#langSelect {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: "Montserrat", sans-serif;
  font-size: 0.8rem;
  padding: 0;
  cursor: pointer;
  appearance: none;
  outline: none;
}
#langSelect option {
  background: #222;
  color: #fff;
  padding: 10px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}
.icon-btn:hover,
.icon-btn.active {
  background: var(--section-bg);
  border-color: var(--glow-color);
  color: var(--glow-color);
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
}
[data-theme="dark"] .sun-icon {
  display: block !important;
}
[data-theme="dark"] .moon-icon {
  display: none !important;
}
[data-theme="light"] .sun-icon {
  display: none !important;
}
[data-theme="light"] .moon-icon {
  display: block !important;
}

/* Layout */
.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 30px;
  padding: 20px;
  max-width: 1800px;
  margin: 0 auto;
  flex: 1;
  position: relative;
  z-index: 2;
}
.canvas-wrapper-outer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.canvas-container {
  position: relative;
  width: 700px;
  height: 700px;
  border-radius: 8px;
  box-shadow: 0 0 60px -15px var(--canvas-glow-fixed);
  border: 1px solid var(--glass-border);
  background: var(--canvas-bg);
  max-width: 90vw;
  max-height: 90vw;
  transition: box-shadow 0.5s ease;
  overflow: hidden;
}
#breathingHalo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  animation: breatheAnim 12s infinite ease-in-out;
}
@keyframes breatheAnim {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.15;
  }
  50% {
    opacity: 0.15;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
}
.canvas-container.spinning {
  animation: spinCanvas 60s linear infinite;
}
@keyframes spinCanvas {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
#guideCanvas {
  pointer-events: none;
  z-index: 1;
}
#drawingCanvas {
  z-index: 2;
}
body.drawing .controls,
body.drawing header,
body.drawing footer {
  opacity: 0.15;
  transition: opacity 0.5s;
  pointer-events: none;
}

/* Action Buttons */
.canvas-actions {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-grid-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
button {
  font-family: "Noto Sans TC", sans-serif;
  border: none;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.2s;
}
.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 100%;
}
.btn-tool {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
}

/* Controls Panel */
.controls {
  width: 280px;
  padding: 20px;
  border-radius: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 15px;
  transition:
    transform 0.5s ease,
    opacity 0.5s ease;
}
.controls.collapsed {
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
}
.control-section {
  background: var(--section-bg);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
}
.control-section.highlight-section {
  border: 1px solid var(--highlight-border);
  background: var(--highlight-bg);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}
.section-title {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.special-title {
  color: #d4af37;
  font-weight: 700;
}
.merged-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.merged-header label {
  margin-bottom: 0;
}
.control-group {
  margin-bottom: 12px;
}
label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 6px;
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 400;
}
.val-display {
  font-family: "Montserrat", monospace;
  opacity: 0.8;
  font-weight: 600;
}
select {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-main);
  font-family: "Noto Sans TC", sans-serif;
  font-size: 0.9rem;
}
option {
  background: #222;
  color: #fff;
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  height: 20px;
  margin: 5px 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: rgba(128, 128, 128, 0.3);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--text-main);
  margin-top: -6px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #555;
  transition: 0.4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--glow-color);
}
input:focus + .slider {
  box-shadow: 0 0 1px var(--glow-color);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.chakra-palette {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chakra-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: 0.2s;
}
.chakra-btn.active {
  transform: scale(1.2);
  border-color: #fff;
  box-shadow: 0 0 8px var(--glow-color);
}
.color-picker-group {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.cp-item {
  flex: 1;
}
.color-wrapper {
  height: 35px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}
input[type="color"] {
  width: 100%;
  height: 100%;
  border: none;
  transform: scale(1.5);
  cursor: pointer;
}
details.advanced-settings {
  margin-top: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}
details.advanced-settings summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  outline: none;
  list-style: none;
  transition: 0.2s;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.advanced-settings summary:hover {
  color: var(--text-main);
  background: var(--section-bg);
}
details.advanced-settings summary::after {
  content: "▼";
  font-size: 0.7rem;
  transition: transform 0.3s;
}
details.advanced-settings[open] summary::after {
  transform: rotate(180deg);
}
details.advanced-settings summary::-webkit-details-marker {
  display: none;
}
.share-grid {
  display: none;
}

.mobile-toggle-btn {
  display: none;
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  z-index: 100;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.mobile-toggle-btn:active {
  transform: scale(0.95);
}

@media (max-width: 1400px) {
  .container {
    justify-content: center;
  }
}

/* === Mobile RWD === */
@media (max-width: 1000px) {
  header {
    padding: 10px 15px;
  }
  .brand-en {
    font-size: 1.4rem;
    letter-spacing: 0.1em;
  }
  .brand-cn {
    font-size: 0.75rem;
    letter-spacing: 0.4em;
    margin-top: 0;
  }
  .subtitle {
    display: none;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  .container {
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 10px;
  }
  .canvas-container {
    width: 92vw;
    height: 92vw;
    order: 1;
  }
  .canvas-actions {
    order: 2;
    width: 92vw;
    margin-bottom: 10px;
  }
  .ad-sidebar {
    order: 3;
    margin-bottom: 80px;
    width: 92vw;
  }
  .ad-placeholder {
    width: 100%;
    height: 100px;
  }
  .controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 70vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(110%);
    z-index: 90;
    order: 4;
    overflow-y: auto;
    padding: 20px 20px 120px 20px;
  }
  .controls.active {
    transform: translateY(0);
  }
  .mobile-toggle-btn {
    display: flex;
  }
}

.modal {
  display: none;
  position: fixed;
  z-index: 200;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--bg-deep);
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
}
.signature-group input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  margin: 15px 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  border: 2px solid var(--glow-color);
  text-align: center;
  font-size: 1.1rem;
  font-family: "Noto Sans TC", sans-serif;
  letter-spacing: 1px;
}
.ad-placeholder-rect {
  width: 100%;
  height: 250px;
  background: rgba(0, 0, 0, 0.5);
  margin: 15px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #555;
  color: #888;
}
footer {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  margin-top: auto;
  border-top: 1px solid var(--glass-border);
}
.footer-title {
  font-family: "Cinzel", serif;
  font-size: 1.2rem;
  color: var(--text-main);
  margin-bottom: 10px;
  letter-spacing: 2px;
}
.footer-desc {
  max-width: 600px;
  margin: 0 auto 20px;
  opacity: 0.8;
  line-height: 1.6;
}
.footer-links {
  font-family: "Montserrat", sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--text-main);
  text-decoration: none;
  opacity: 0.7;
  transition: 0.2s;
}
.footer-links a:hover {
  opacity: 1;
  color: var(--glow-color);
}
.footer-links .sep {
  opacity: 0.3;
}
.copyright {
  opacity: 0.5;
}
