:root {
  --ink: #f3ecd9;
  --ink-dark: #1e2530;
  --accent: #d76936;
  --panel: rgba(255, 247, 236, 0.95);
  --panel-line: rgba(30, 37, 48, 0.12);
  --shadow: 0 28px 60px rgba(22, 20, 18, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Outfit", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #214245 0, #141c22 40%, #0f1318 100%);
}

.app-shell {
  position: fixed;
  inset: 0;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #111;
}

#baseCanvas,
#scratchCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#baseCanvas {
  pointer-events: none;
}

#scratchCanvas {
  touch-action: none;
  cursor: crosshair;
  transition: opacity 0.12s ease;
}

#scratchCanvas.is-peeking {
  opacity: 0;
  pointer-events: none;
}

.topbar,
.bottombar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  pointer-events: none;
}

.topbar {
  top: 0;
}

.bottombar {
  bottom: 0;
}


.topbar-left,
.progress-wrap {
  pointer-events: auto;
}

.topbar-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-family: "Noto Serif SC", serif;
  color: var(--ink);
  font-size: 1.08rem;
  letter-spacing: 0.03em;
}

.hint-pill {
  color: rgba(243, 236, 217, 0.9);
  font-size: 0.84rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(243, 236, 217, 0.25);
  background: rgba(17, 20, 26, 0.42);
  transition: opacity 0.35s ease;
}

.hint-pill.is-faded {
  opacity: 0;
}

.progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(243, 236, 217, 0.96);
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(243, 236, 217, 0.25);
  background: rgba(14, 16, 22, 0.46);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.ghost-chip,
.solid-chip {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ghost-chip {
  color: #f7f1df;
  border: 1px solid rgba(243, 236, 217, 0.28);
  background: rgba(14, 18, 24, 0.52);
  backdrop-filter: blur(8px);
}

.topbar-right .ghost-chip {
  padding: 0;
  width: 42px;
  height: 42px;
}

.floating-toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(14, 20, 28, 0.48);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(243, 236, 217, 0.22);
  border-radius: 999px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 40;
  touch-action: none;
}

.drag-handle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(243, 236, 217, 0.5);
  cursor: grab;
  margin-left: 4px;
}

.drag-handle:active {
  cursor: grabbing;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-actions .ghost-chip {
  padding: 0;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 0;
}

.toolbar-actions .ghost-chip:hover {
  background: rgba(243, 236, 217, 0.1);
}

.ghost-chip svg {
  display: block;
}

.ghost-chip.is-active,
#pullBtn.is-pulling {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.solid-chip {
  color: #fff8ef;
  background: linear-gradient(135deg, #b84b22, #d98037);
}

.solid-chip:disabled {
  background: #cbd5e1;
  background-image: none;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.8;
  box-shadow: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  z-index: 20;
}

.config-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(78vh, 760px);
  display: grid;
  grid-template-rows: auto 1fr;
  color: var(--ink-dark);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border: 1px solid var(--panel-line);
  border-bottom: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateY(102%);
  transition: transform 0.24s ease;
  z-index: 30;
}

.app-shell.drawer-open .config-drawer {
  transform: translateY(0);
}

.drawer-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-line);
}

.drawer-title {
  display: grid;
  justify-items: center;
  line-height: 1.2;
}

.drawer-title small {
  color: rgba(30, 37, 48, 0.66);
  font-size: 0.82rem;
}

.drawer-body {
  overflow: auto;
  padding: 12px 14px 26px;
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  padding: 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-family: "Noto Serif SC", serif;
  font-size: 1.05rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span,
.range-row span,
.muted {
  font-size: 0.9rem;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.field-header strong {
  font-size: 0.95rem;
  color: var(--accent);
}


.is-hidden {
  display: none;
}

input[type="url"],
input[type="text"],
select,
input[type="file"],
input[type="range"] {
  width: 100%;
}

input[type="url"],
input[type="text"],
select {
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  font: inherit;
  color: var(--ink-dark);
}

input[type="file"] {
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--panel-line);
}

.range-row,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actions {
  margin-top: 10px;
  flex-wrap: wrap;
}

.muted {
  margin: 0;
  color: rgba(30, 37, 48, 0.7);
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  color: #f5eedf;
  background: rgba(15, 18, 24, 0.72);
  border: 1px solid rgba(243, 236, 217, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.86rem;
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.status-toast.is-visible {
  opacity: 1;
}

.pull-line-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  display: none;
}

.pull-line-overlay.is-visible {
  display: block;
}

.upload-tip {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #b84b22;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
}

.static-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.static-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 4px 10px;
  background: rgba(215, 105, 54, 0.08);
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 1px solid rgba(215, 105, 54, 0.12);
}

.static-links a:hover {
  background: rgba(215, 105, 54, 0.16);
  transform: translateY(-1px);
  border-color: rgba(215, 105, 54, 0.3);
}

@media (max-width: 720px) {

  .topbar,
  .bottombar {
    padding: 12px;
  }

  .ghost-chip,
  .solid-chip {
    padding: 9px 12px;
    font-size: 0.9rem;
  }

  .config-drawer {
    height: 82vh;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }

  .drawer-header {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .drawer-title {
    justify-items: start;
  }
}

.error-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15;
  background: rgba(14, 18, 24, 0.4);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.error-overlay:not(.is-hidden) {
  display: flex;
}

.error-card {
  background: var(--panel);
  border: 1px solid rgba(215, 105, 54, 0.3);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.error-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: rgba(215, 105, 54, 0.1);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-title {
  font-family: "Noto Serif SC", serif;
  font-size: 1.4rem;
  margin: 0 0 12px;
  color: var(--ink-dark);
}

.error-message {
  font-size: 0.95rem;
  color: rgba(30, 37, 48, 0.7);
  margin: 0 0 28px;
  line-height: 1.5;
}

#errorActionBtn {
  width: 100%;
  height: 48px;
  font-size: 1rem;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}