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

body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 500;
  background: #2a2a2a;
  color: #d0d0d0;
  height: 100dvh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100dvh;
  gap: 1.5rem;
  padding: 1.5rem;
}

#panel {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  scrollbar-width: none;
}

#panel::-webkit-scrollbar {
  display: none;
}

h1 {
  font-family: 'Bungee', sans-serif;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  color: #eee;
  text-align: center;
  margin-bottom: 0.5rem;
}

#canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#canvas-wrap {
  position: relative;
  aspect-ratio: 1;
  height: 100%;
  width: auto;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.2),
    0 8px 40px rgba(0, 0, 0, 0.4);
}

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

@media (max-width: 640px) {
  #app {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  #panel {
    width: 100%;
    order: 2;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }

  h1 { display: none; }

  #canvas-area {
    order: 1;
    flex: 0 0 auto;
    max-height: 50dvh;
  }

  #canvas-wrap {
    height: auto;
    width: 100%;
    max-height: 50dvh;
  }

  #canvas, #text-canvas {
    width: 100%;
    height: auto;
  }
}

#text-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
}

#progress {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  font-family: 'Bungee', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: #fff;
}

#progress-slow {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  color: #aaa;
  max-width: 280px;
  text-align: center;
  line-height: 1.5;
}

#progress-slow[hidden] {
  display: none;
}

#progress[hidden] {
  display: none;
}


input {
  width: 100%;
  background: #363636;
  border: 1px solid #4a4a4a;
  color: #eee;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: #777;
}

input::placeholder {
  color: #777;
  font-weight: 500;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem 0;
  border-top: 1px solid #3a3a3a;
}

.panel-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.section-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
}

select {
  width: 100%;
  background: #363636;
  border: 1px solid #4a4a4a;
  color: #eee;
  padding: 0.3rem 0.5rem;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: #777;
}

.size-align-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.size-align-row .range-field {
  flex: 1;
}

.align-toggle {
  display: flex;
  flex-shrink: 0;
}

.align-btn {
  background: #363636;
  border: 1px solid #4a4a4a;
  color: #888;
  padding: 0.25rem 0.4rem;
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}

.align-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.align-btn:last-child {
  border-radius: 0 4px 4px 0;
}

.align-btn:not(:first-child) {
  border-left: none;
}

.align-btn.active {
  background: #5a5a5a;
  color: #fff;
}

.align-btn:hover:not(.active) {
  background: #444;
  color: #bbb;
}

.color-row {
  display: flex;
  gap: 0.5rem;
}

.color-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #363636;
  border: 1px solid #4a4a4a;
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}

.color-field input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid #5a5a5a;
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.color-field span {
  font-size: 0.75rem;
  font-weight: 600;
  color: #999;
}

.color-field input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #999;
  cursor: pointer;
  flex-shrink: 0;
}

.range-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-field span {
  font-size: 0.65rem;
  font-weight: 600;
  color: #999;
  width: 48px;
  flex-shrink: 0;
}

.range-field input[type="range"] {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: #4a4a4a;
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
}

.range-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #999;
  cursor: pointer;
}

.range-field input[type="range"]::-webkit-slider-thumb:hover {
  background: #ccc;
}

.btn {
  background: #3a3a3a;
  border: 1px solid #4a4a4a;
  color: #ccc;
  padding: 0.35rem 0.75rem;
  border-radius: 5px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  letter-spacing: 0.02em;
  width: 100%;
  text-align: center;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn-group .btn {
  flex: 1;
}

.btn:hover:not(:disabled) {
  background: #4a4a4a;
  border-color: #5a5a5a;
  color: #fff;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn.primary {
  background: #e8e8e8;
  color: #222;
  border-color: #e8e8e8;
}

.btn.primary:hover:not(:disabled) {
  background: #d0d0d0;
  border-color: #d0d0d0;
}

.btn.link {
  background: none;
  border: none;
  color: #888;
  padding: 0.3rem 0;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
  text-align: left;
  width: auto;
}

.btn.link:hover {
  color: #bbb;
}

.drag-hint {
  font-size: 0.65rem;
  color: #777;
  text-align: center;
  padding: 0.3rem 0;
}

.panel-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.55rem;
  color: #666;
  line-height: 1.6;
  text-align: center;
}

.panel-footer a {
  color: #777;
  text-decoration: none;
}

.panel-footer a:hover {
  color: #aaa;
}
