body { font-family: 'Inter', 'Segoe UI', Verdana, sans-serif; background: linear-gradient(145deg, #eef3ff 0%, #fffaf7 60%, #fefefe 100%); color: #1c1f2c; margin: 0; min-height: 100vh; display: flex; justify-content: center; align-items: flex-start; padding: 40px 20px; touch-action: none; overscroll-behavior: none; }
.page { width: min(1100px, 100%); background: #fff; border-radius: 28px; padding: 32px; box-shadow: 0 20px 45px rgba(17, 24, 39, 0.15); display: flex; flex-direction: column; gap: 24px; }
.hero h2 { margin: 0; font-size: 2.5rem; letter-spacing: 0.01em; }
.hero .lead { margin: 8px 0 0; font-size: 1rem; color: #5f6683; max-width: 600px; }
.controls { display: flex; flex-direction: column; gap: 16px; background: #f8f9ff; border-radius: 24px; padding: 20px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7); }
.controls label { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: #6c748f; }
.controls select, .controls textarea { border: none; border-radius: 14px; padding: 12px 14px; background: rgba(255, 255, 255, 0.9); font-size: 1rem; color: #1c1f2c; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.controls textarea { resize: vertical; min-height: 100px; }
.type-section { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.type-buttons { display: flex; flex-direction: column; gap: 10px; }
.type-buttons button { width: 100%; }
.type-btn { font-weight: 600; border: none; background: #e3e6f5; color: #1c1f2c; padding: 14px 18px; border-radius: 18px; cursor: pointer; transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.type-btn.active { background: #1f67ff; color: #fff; box-shadow: 0 10px 22px rgba(31, 103, 255, 0.3); }
.mask-control, #maskControl { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-bottom: 4px; }
.mask-control label, #maskControl label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: #6c748f; }
.question-message { border-radius: 16px; padding: 14px 16px; background: #f2f4ff; border: 1px solid rgba(31, 103, 255, 0.2); color: #1c1f2c; font-size: 0.95rem; line-height: 1.4; }
.question-message .question-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.2em; color: #5f6683; margin-bottom: 6px; display: block; }
.question-message .question-text { display: block; }
.question-message.hidden { display: none; }
.mask-control.hidden, #maskControl.hidden { display: none; }
.color { cursor: pointer; background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1); transition: transform 0.2s ease, box-shadow 0.2s ease; text-align: center; }
.color:hover { transform: translateY(-2px); box-shadow: 0 16px 28px rgba(15, 23, 42, 0.18); }
.color div { font-weight: 600; font-size: 0.68rem; color: rgba(28, 31, 44, 0.85); margin-top: 8px; transition: font-size 0.2s ease, opacity 0.2s ease; opacity: 0.9; }
.color:hover div { font-size: 1.05rem; opacity: 1; color: #0f172a; }
.circle { width: 20px; height: 20px; border-radius: 50%; margin: auto; border: 2px solid rgba(0,0,0,0.08); }
.mode-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#modeButtons button { flex: 1; min-width: 120px; border: none; background: #e3e6f5; color: #1c1f2c; padding: 10px 16px; border-radius: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12); }
#modeButtons button.active { background: #1f67ff; color: #fff; box-shadow: 0 10px 20px rgba(31, 103, 255, 0.35); }
.canvas-area { display: flex; flex-direction: column; align-items: center; background: #f6f7fb; border-radius: 24px; padding: 24px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8); gap: 18px; }
.palette-stack { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 10px; padding: 10px 14px 12px; border-radius: 18px; border: 1px solid rgba(31, 103, 255, 0.25); background: rgba(255, 255, 255, 0.9); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8); }
.palette-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.2em; color: #5f6683; text-align: center; }
@media (min-width: 720px) {
  .canvas-area { padding: 28px; gap: 22px; }
}

#canvasWrapper { position: relative; width: min(100%, 720px); max-width: 100%; border-radius: 24px; background: #fff; padding: 20px; box-shadow: 0 20px 45px rgba(17, 24, 39, 0.1); overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 14px; touch-action: none; -webkit-user-select: none; user-select: none; }
#palette { display: grid; grid-template-columns: repeat(var(--palette-columns, 5), minmax(56px, 1fr)); gap: 10px; width: 100%; }
.canvas-frame { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.zoom-layer { width: 100%; position: relative; transform-origin: center top; transition: transform 0.2s ease; }
.canvas-frame canvas { width: 100%; height: 100%; display: block; touch-action: none; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.05); position: relative; z-index: 1; }
.canvas-frame img#mask { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; z-index: 2; border-radius: 12px; }
#cursorPreview { position: fixed; pointer-events: none; width: 44px; height: 44px; opacity: 0; transition: opacity 0.15s ease; z-index: 30; transform: translate(-50%, -50%); --cursor-color: rgba(255, 255, 255, 0.9); }
#cursorPreview::before, #cursorPreview::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--cursor-color, #fff); transform: translate(-50%, -50%); }
#cursorPreview::before { width: 2px; height: 100%; border-radius: 999px; }
#cursorPreview::after { width: 100%; height: 2px; border-radius: 999px; }
.actions { text-align: center; }
.permalink { margin-top: 12px; padding: 14px 18px; border-radius: 16px; background: rgba(31, 103, 255, 0.08); color: #1f67ff; font-weight: 500; word-break: break-word; }
.permalink.hidden { display: none; }
.permalink a { display: block; margin-top: 4px; color: #1f67ff; text-decoration: underline; }
.result-link { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.result-link-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.7rem; color: #5f6683; }
.result-link-row { display: flex; gap: 10px; align-items: center; }
.result-link-row input { flex: 1; border: none; border-radius: 14px; padding: 12px 14px; background: rgba(255, 255, 255, 0.9); font-size: 0.95rem; color: #1c1f2c; box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12); }
.result-link-row input:focus { outline: 2px solid rgba(31, 103, 255, 0.6); }
.result-link-row button { flex-shrink: 0; padding: 10px 18px; border-radius: 14px; font-size: 0.9rem; box-shadow: 0 10px 22px rgba(15, 23, 42, 0.15); }
.result-link-anchor { font-size: 0.85rem; color: #0b63ff; text-decoration: none; word-break: break-all; }
.result-link-anchor:hover { text-decoration: underline; }
.result-preview { margin-top: 16px; border-radius: 18px; overflow: hidden; box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18); background: #fff; }
.result-preview-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.2em; color: #5f6683; padding: 12px 16px 0; display: block; }
.result-preview img { width: 100%; height: auto; display: block; object-fit: cover; margin-top: 6px; border-radius: 0 0 16px 16px; }
.result-error { margin-top: 16px; padding: 16px; border-radius: 16px; background: #fff0f2; border: 1px solid #f098a8; color: #9c1d3b; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75); }
.canvas-actions { width: 100%; display: flex; justify-content: flex-end; }
.canvas-actions button { border-radius: 18px; padding: 12px 20px; border: none; background: #ffe2e4; color: #a11d2b; font-weight: 600; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6); transition: transform 0.2s ease; }
.canvas-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.canvas-actions button:not(:disabled):hover { transform: translateY(-1px); }
button { font-family: inherit; border: none; border-radius: 18px; background: #1f67ff; color: #fff; padding: 14px 32px; font-size: 1rem; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; box-shadow: 0 14px 30px rgba(31, 103, 255, 0.35); }
button:hover { transform: translateY(-2px); }
@media (max-width: 720px) { .page { padding: 24px 20px; } .canvas-area { padding: 12px; } #canvasWrapper { width: 100%; } }

@media (max-width: 480px) {
  #palette .circle { width: 14px; height: 14px; }
}

@media (max-width: 640px) {
  #palette { grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); }
}
.step.hidden {
  display: none;
}
