:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #e6e6e6;
  --text: #1a1a1a;
  --text-dim: #8a8a8a;
  --accent: #3d5afe;
  --accent-soft: rgba(61, 90, 254, 0.1);
  --hover: #f0f0f2;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --panel: #1c1c1f;
    --border: #2b2b30;
    --text: #ededf0;
    --text-dim: #7a7a80;
    --accent: #6f86ff;
    --accent-soft: rgba(111, 134, 255, 0.15);
    --hover: #26262a;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

#brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

#upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}

#upload-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
}

#font-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.font-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}

.font-item:hover {
  background: var(--hover);
}

.font-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.font-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-item-remove {
  opacity: 0;
  border: none;
  background: none;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

.font-item:hover .font-item-remove {
  opacity: 0.6;
}

.font-item-remove:hover {
  opacity: 1 !important;
}

#sidebar-footer {
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 12px;
  line-height: 1.4;
}

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 10px;
  border-right: 1px solid var(--border);
}

.tool-group:last-child {
  border-right: none;
}

.sample-btn, .icon-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.sample-btn:hover, .icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn {
  width: 30px;
  padding: 0;
  font-size: 14px;
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

#case-select {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  padding: 0 6px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  display: inline-block;
}

.color-swatch input {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  transform: scale(1.6);
}

#canvas-scroll {
  flex: 1;
  overflow: auto;
  background: var(--canvas-bg, #ffffff);
}

#canvas {
  min-height: 100%;
  padding: 60px;
  outline: none;
  word-break: break-word;
  color: var(--canvas-color, #1a1a1a);
}

#controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 24px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

.control-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  backdrop-filter: blur(4px);
  border: 3px dashed var(--accent);
}

#drop-overlay.active {
  display: flex;
}

#drop-overlay-text {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}
