@font-face {
    font-family: 'Bakso Sapi';
    src: url('fonts/BaksoSapi.otf') format('opentype');
    font-display: swap;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
}

:root {
    touch-action: manipulation;
}

body {
    background-color: #f4f4f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Prevents pull-to-refresh on mobile while designing */
    overscroll-behavior-y: contain;
}

header {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(90deg, #F898A4 0%, #FCDA9C 20%, #F7FAA1 40%, #B4F6A4 60%, #9BE0F1 80%, #A2ACEB 100%);
    color: #1a202c;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 22px;
    color: #1a202c;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
}

main {
    width: 100%;
    max-width: 500px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#canvas-container {
    background-color: #ffffff;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    width: max-content;
    height: max-content;
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.t-shirt.preview #canvas-container {
    background-color: transparent;
    border-color: transparent;
}

/* T-Shirt Mockup & Zooming Styles */
.clip {
    width: 100%;
    aspect-ratio: 5 / 4;
    overflow: clip;
    position: relative;
    margin: 0 auto;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: #fff;
}

.t-shirt {
    position: absolute;
    inset: 0;
    background: url('https://dev.serializer.ca/mocks/designer/images/bg.jpg') no-repeat center 29%;
    background-size: 120% auto;
    transition: transform 1s cubic-bezier(0.25, 1, 0.5, 1);
}

.t-shirt.edit {
    transform: translateY(-68%) scale(2.7);
}

.t-shirt.preview {
    transform: none;
}

.editor-wrapper {
    position: absolute;
    top: 56.9%;
    left: 32.0%;
    width: 100%;
    transform-origin: top left;
}

.toolbar {
    display: flex;
    gap: 10px;
    width: 100%;
}

.tool-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.tool-controls label {
    font-size: 14px;
    font-weight: bold;
    color: #555;
}

#font-family-select {
    padding: 12px;
    border: 2px solid #9BE0F1;
    border-radius: 8px;
    font-size: 16px;
    background-color: white;
    color: #333;
    cursor: pointer;
    width: 100%;
    outline: none;
}

.color-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#font-color-picker,
#stroke-color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 42px;
    height: 42px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#font-color-picker:hover,
#stroke-color-picker:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#font-color-picker::-webkit-color-swatch-wrapper,
#stroke-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#font-color-picker::-webkit-color-swatch,
#stroke-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

/* Category Sub-Tool Tab Buttons */
.tool-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    margin-bottom: 6px;
}

.tool-tab-btn {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
    justify-content: center;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 8px;
    border: 1px solid #cbd5e0;
    background-color: #f7fafc;
    color: #4a5568;
    cursor: pointer;
    white-space: nowrap;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.tool-tab-btn:hover {
    background-color: #edf2f7;
    border-color: #a0aec0;
}

.tool-tab-btn.active {
    background-color: #9BE0F1;
    color: #1a202c;
    border-color: #7cd0e4;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Layer item drag and drop states & compact styling */
#layers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f7fafc;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    height: 38px;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12.5px;
    user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.layer-item.selected {
    background-color: #e6fffa;
    border-color: #38b2ac;
}

.layer-item .drag-handle {
    cursor: grab;
    color: #a0aec0;
    font-size: 15px;
    font-weight: bold;
    padding-right: 8px;
    touch-action: none;
}

.layer-item .drag-handle:active {
    cursor: grabbing;
    color: #4a5568;
}

.layer-move-btn {
    min-height: unset !important;
    height: 24px !important;
    width: 26px !important;
    padding: 0 !important;
    font-size: 11px !important;
    line-height: 24px !important;
    border-radius: 4px !important;
    background: #edf2f7 !important;
    border: 1px solid #cbd5e0 !important;
    color: #2d3748 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.layer-move-btn:disabled {
    opacity: 0.25 !important;
    cursor: not-allowed !important;
}

.layer-item.dragging {
    opacity: 0.4;
    transform: scale(0.98);
    border: 2px dashed #38b2ac !important;
}

.layer-item.drag-over {
    border: 2px solid #38b2ac !important;
    background-color: #e6fffa !important;
}

button {
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    flex: 1;
    min-height: 50px;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

button:active {
    transform: scale(0.97);
}

#add-text-btn {
    background-color: #B4F6A4;
    color: #1a202c;
}

#add-image-btn {
    background-color: #9BE0F1;
    color: #1a202c;
}

#add-clipart-btn {
    background-color: #A2ACEB;
    color: white;
}

#undo-btn {
    background-color: #FCDA9C;
    color: #2d3748;
}

.btn-gray {
    background-color: #f1f2f6;
    color: #333;
    border: 2px solid #dfe4ea;
}

.btn-gray:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.danger-btn {
    background-color: #F898A4;
    color: white;
}

.primary-btn {
    background: linear-gradient(90deg, #F898A4 0%, #FCDA9C 20%, #F7FAA1 40%, #B4F6A4 60%, #9BE0F1 80%, #A2ACEB 100%);
    color: #1a202c;
    font-weight: bold;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.secondary-btn {
    background-color: #45b7d1;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.text-btn {
    background: none;
    color: #666;
    margin-top: 15px;
    width: 100%;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 20px;
}

/* Welcome Screen & Mode Selector Styling */
.welcome-screen {
    width: 100%;
    max-width: 520px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.welcome-card-header {
    text-align: center;
    margin-bottom: 8px;
}

.welcome-title {
    font-size: 22px;
    font-weight: 800;
    color: #1a202c;
    margin-bottom: 4px;
}

.welcome-subtitle {
    font-size: 14px;
    color: #4a5568;
}

.mode-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.mode-card:hover {
    border-color: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(49, 130, 206, 0.15);
}

.mode-icon {
    font-size: 32px;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mode-info h3 {
    font-size: 16px;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 4px;
}

.mode-info p {
    font-size: 12.5px;
    color: #718096;
    line-height: 1.35;
}

.mode-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.badge-popular {
    background: #feebc8;
    color: #744210;
}

.badge-photo {
    background: #e9d8fd;
    color: #553c9a;
}

.badge-gallery {
    background: #c6f6d5;
    color: #22543d;
}

.badge-pro {
    background: #bee3f8;
    color: #2b6cb0;
}

.welcome-draft-input-group {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.welcome-draft-input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    text-transform: uppercase;
    font-family: monospace;
    letter-spacing: 1px;
}

.premade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    width: 100%;
    margin-top: 12px;
}

.premade-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.premade-item:hover {
    border-color: #3182ce;
    transform: scale(1.02);
}

.premade-item span {
    font-size: 12px;
    font-weight: bold;
    color: #4a5568;
    margin-top: 6px;
    display: block;
}

/* Modal Overlay Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1200;
    padding: 16px;
}

.modal-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Embedded Step Cards */
.welcome-step-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.welcome-step-card button,
#back-from-simple-text-btn,
#back-to-welcome-btn,
#switch-to-advanced-btn {
    flex: none;
    min-height: unset;
    width: auto;
}

.color-palette-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 6px;
}

.step-swatch,
.outline-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.step-swatch:hover,
.outline-swatch:hover {
    transform: scale(1.15);
}

.step-swatch.active,
.outline-swatch.active {
    transform: scale(1.18);
    box-shadow: 0 0 0 3px #3182ce;
}

/* Font Radio Choice Grid Styling */
.font-radio-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    background: #f7fafc;
}

.font-radio-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.font-radio-card.selected,
.font-radio-card:hover {
    border-color: #3182ce;
    background: #ebf8ff;
}

.font-radio-card input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #3182ce;
    cursor: pointer;
}

.font-radio-label {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.font-name {
    font-size: 10.5px;
    color: #718096;
    font-weight: bold;
}

.font-preview {
    font-size: 16px;
    color: #1a202c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clipart-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.clipart-btn {
    font-size: 32px;
    padding: 0;
    width: 50px;
    height: 50px;
    min-height: 50px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Mode-Tailored View Utility Classes */
body.mode-simple-text #add-image-btn,
body.mode-simple-text #add-clipart-btn,
body.mode-simple-text #panel-layers,
body.mode-simple-text #image-options-group {
    display: none !important;
}

body.mode-simple-photo #add-text-btn,
body.mode-simple-photo #add-clipart-btn,
body.mode-simple-photo #panel-layers,
body.mode-simple-photo #text-options-group {
    display: none !important;
}

#global-layer-up-btn:disabled,
#global-layer-down-btn:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    background: #F7FAA1 !important;
    /* retain background but faded */
    filter: grayscale(80%);
}

/* Custom Unified Modal System */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal-container {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 24px;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-modal-overlay.active .custom-modal-container {
    transform: translateY(0) scale(1);
}

.custom-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 12px 0;
    display: none;
}

.custom-modal-message {
    font-size: 15px;
    color: #4a5568;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.custom-modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    color: #2d3748;
    margin-bottom: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.custom-modal-input:focus {
    outline: none;
    border-color: #4299e1;
}

.custom-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.custom-modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.custom-modal-btn-cancel {
    background: #edf2f7;
    color: #4a5568;
}

.custom-modal-btn-cancel:hover {
    background: #e2e8f0;
}

.custom-modal-btn-confirm {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    box-shadow: 0 4px 6px rgba(66, 153, 225, 0.25);
}

.custom-modal-btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(66, 153, 225, 0.3);
}

/* Custom Color Picker Styles */
.custom-color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    flex: none;
    min-height: unset;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.custom-color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    padding: 0;
    min-height: unset;
    flex: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.color-swatch.active-swatch {
    border: 3px solid #1a202c;
    transform: scale(1.1);
}