:root {
  --bg: #070b14;
  --panel: rgba(17, 24, 39, 0.9);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
}

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

html, body {
  width: 100%;
  min-height: 100dvh;
  background: radial-gradient(circle at 25% 15%, #172554 0%, #070b14 75%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #06b6d4, #ec4899);
  color: #fff;
}

.brand h1 {
  font-size: 1.08rem;
  font-weight: 800;
}

.top-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.upload-btn,
.icon-btn,
.sample-btn {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-btn {
  background: rgba(6, 182, 212, 0.25);
  border-color: #22d3ee;
}

.icon-btn.active,
.sample-btn.active {
  background: rgba(236, 72, 153, 0.24);
  border-color: #f472b6;
  color: #fbcfe8;
}

.main-grid {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 14px;
  align-items: stretch;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(10px);
}

.canvas-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 400px;
}

.sample-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bar-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.term-status {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fde68a;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  background: #04070e;
  border: 1px solid var(--border);
  touch-action: none;
}

.canvas-wrap.drag-over {
  border-color: #22d3ee;
  box-shadow: inset 0 0 24px rgba(34, 211, 238, 0.25);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.controls-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
}

.ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #22d3ee;
  border: 2px solid #0f172a;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  min-height: 32px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: #22d3ee;
}

.primary-btn {
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  color: #fff;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
}

.info-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .canvas-wrap {
    min-height: 340px;
  }
}
