@font-face {
    font-family: 'Super Kiddy Sans';
    src: url('SuperKiddySans-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f7f3ec;
    color: #1a2744;
    min-height: 100vh;
    line-height: 1.5;
}

/* Header */
header {
    background: #ffffff;
    border-bottom: 1px solid #e5ded3;
    padding: 16px 20px;
}

.header-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: #1a2744;
}

.brand-subtitle {
    font-size: 0.82rem;
    color: #7b7468;
    margin-top: 2px;
    font-weight: 400;
}

.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 4px 10px;
    background: #f0ebe1;
    color: #5a5245;
    border-radius: 4px;
    white-space: nowrap;
}

/* Main Layout */
.main-container {
    max-width: 1180px;
    margin: 24px auto 40px;
    padding: 0 20px;
}

.editor-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 36px;
    align-items: start;
}

/* Form Card */
.form-card {
    background: #ffffff;
    border: 1px solid #e3dcce;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.section-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0ebe2;
}

.section-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2744;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-header p {
    font-size: 0.8rem;
    color: #827b70;
    margin-top: 2px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.76rem;
    font-weight: 600;
    color: #4a4336;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.label-hint {
    font-weight: 400;
    color: #8c8579;
    text-transform: none;
    letter-spacing: normal;
}

input[type="text"], textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.88rem;
    font-family: inherit;
    color: #1a2744;
    background: #faf8f4;
    border: 1px solid #dcd5c7;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

input[type="text"]:focus, textarea:focus {
    border-color: #1a2744;
    background: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 160px;
    line-height: 1.6;
}

.counter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.char-counter {
    font-size: 0.74rem;
    color: #8c8579;
}

.char-counter.full {
    color: #b33927;
    font-weight: 600;
}

/* Actions */
.action-row {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.btn-download {
    flex: 2;
    padding: 12px 18px;
    background: #1a2744;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, transform 0.05s;
}

.btn-download:hover {
    background: #2b3d63;
}

.btn-download:active {
    transform: scale(0.99);
}

.btn-reset {
    flex: 1;
    padding: 12px 14px;
    background: #ffffff;
    color: #5a5245;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid #dcd5c7;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-reset:hover {
    background: #faf8f4;
    color: #1a2744;
    border-color: #b8b0a2;
}

/* Preview Pane */
.preview-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-header-bar {
    width: 100%;
    max-width: 540px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #7b7468;
}

.preview-hint {
    font-size: 0.74rem;
    color: #9c9487;
}

.btn-toggle-size {
    display: none; /* Only visible on mobile */
    align-items: center;
    gap: 4px;
    background: #ffffff;
    border: 1px solid #dcd5c7;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 500;
    color: #5a5245;
    cursor: pointer;
    font-family: inherit;
}

.btn-toggle-size:hover {
    background: #f7f3ec;
    color: #1a2744;
}

.canvas-frame {
    width: 100%;
    max-width: 540px;
    background: #ffffff;
    border: 1px solid #dfd8cc;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease-in-out;
}

#letterCanvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    aspect-ratio: 1638 / 2048;
}

/* ========================================================
   MOBILE VIEW ADJUSTMENT:
   Sticky top live-preview so user can see letter WHILE typing
   ======================================================== */
@media (max-width: 860px) {
    header {
        padding: 12px 16px;
    }

    .brand-title {
        font-size: 1rem;
    }

    .brand-subtitle {
        display: none;
    }

    .badge {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

    .main-container {
        margin: 0;
        padding: 0 12px 30px;
    }

    .editor-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* Move Preview to the TOP and make it STICKY */
    .preview-pane {
        order: -1;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 100;
        background: #f7f3ec;
        padding: 8px 0 10px;
        border-bottom: 1px solid #dfd8cc;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
        width: 100%;
    }

    .preview-header-bar {
        margin-bottom: 6px;
        padding: 0 4px;
    }

    .preview-hint {
        display: none;
    }

    .btn-toggle-size {
        display: inline-flex;
    }

    .canvas-frame {
        max-width: 100%;
        padding: 6px;
        background: #ffffff;
        border-radius: 6px;
    }

    /* Compact height on mobile so typing keyboard & form fit cleanly */
    #letterCanvas {
        max-height: 25vh;
        width: auto;
        margin: 0 auto;
    }

    /* Expanded view if user taps "Perbesar" */
    .canvas-frame.is-expanded #letterCanvas {
        max-height: 65vh;
        width: 100%;
    }

    .form-card {
        padding: 16px;
        border-radius: 8px;
    }

    textarea {
        min-height: 120px;
    }
}
