:root {
    color-scheme: light;
    --yellow: #ffd83d;
    --yellow-dark: #f3b800;
    --ink: #252525;
    --muted: #676767;
    --cream: #fffaf0;
    --card: #ffffff;
    --line: #f0c928;
    --border: #eadca3;
    --soft: #fffaf0;
    --danger: #b42318;
    --shadow: 0 18px 55px rgba(68, 50, 0, .12);
    --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 216, 61, .25), transparent 32rem),
        linear-gradient(180deg, #fffdf6 0%, var(--cream) 100%);
    line-height: 1.6;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }

.page-width {
    width: min(1120px, calc(100% - 48px));
    margin-inline: auto;
}

.hero {
    min-height: 55vh;
    display: grid;
    place-items: center;
    padding: 80px 24px 64px;
    overflow: hidden;
    position: relative;
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: var(--yellow);
    opacity: .2;
    filter: blur(1px);
}

.hero::before {
    width: 280px;
    height: 280px;
    top: -90px;
    right: -70px;
}

.hero::after {
    width: 170px;
    height: 170px;
    bottom: 20px;
    left: -60px;
}

.hero-inner {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 56px;
    align-items: center;
    position: relative;
    z-index: 1;
}

.eyebrow {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff3ad;
    font-weight: 800;
    font-size: .88rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 20px 0 18px;
    font-size: clamp(3.1rem, 8vw, 6.5rem);
    line-height: .92;
    letter-spacing: -.07em;
}

.hero p {
    max-width: 700px;
    font-size: clamp(1.08rem, 2vw, 1.32rem);
    color: var(--muted);
    margin: 0 0 28px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 22px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 900;
    transition: transform .2s ease, box-shadow .2s ease;
}

.button:hover { transform: translateY(-2px); }

.button-primary {
    background: var(--ink);
    color: #fff;
    box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

.portrait {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portrait-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    filter: drop-shadow(0 18px 35px rgba(0, 0, 0, .18));
}

.maker-section { padding: 20px 24px 90px; }

.message-maker-card {
    width: min(1120px, 100%);
    margin: 0 auto;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.controls,
.preview-panel {
    background: var(--card);
    border: 1px solid rgba(151, 119, 0, .12);
    border-radius: var(--radius);
    box-shadow: 0 12px 38px rgba(61, 47, 0, .08);
}

.controls {
    max-height: calc(100vh - 34px);
    overflow-y: auto;
    position: sticky;
    top: 17px;
    padding: 10px;
    scrollbar-width: thin;
}

.control-section { border-bottom: 1px solid var(--border); }
.control-section:last-of-type { border-bottom: 0; }

.control-section summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 10px;
    cursor: pointer;
    user-select: none;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .76rem;
    color: var(--ink);
}

.control-section summary::-webkit-details-marker { display: none; }
.control-section summary span { display: inline-flex; align-items: center; gap: 9px; }
.control-section summary .bi:first-child { font-size: 1.02rem; color: var(--yellow-dark); }
.section-chevron { transition: transform .18s ease; color: var(--muted); }
.control-section[open] .section-chevron { transform: rotate(180deg); }
.section-content { display: grid; gap: 15px; padding: 3px 10px 17px; }

label { display: grid; gap: 7px; font-weight: 800; font-size: .9rem; }
textarea, select, input[type="text"] {
    width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 11px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 112px; line-height: 1.25; }
input[type="color"] { width: 100%; min-width: 0; height: 42px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
input[type="range"] { width: 100%; min-width: 0; accent-color: var(--yellow-dark); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--yellow-dark); }

button {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid var(--border); border-radius: 11px; padding: 10px 13px;
    background: #fff; color: var(--ink); font-weight: 800; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}
button:hover { transform: translateY(-1px); border-color: var(--yellow-dark); }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.input-reset-row, .file-reset-row, .textarea-reset-row { display: grid; grid-template-columns: minmax(0, 1fr) 25px; gap: 7px; align-items: center; }
.textarea-reset-row { align-items: start; }
.slider-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 25px; gap: 8px; align-items: center; }
.slider-row.no-reset { grid-template-columns: minmax(0, 1fr) 58px; }
output { text-align: right; color: var(--muted); font-size: .82rem; font-weight: 750; white-space: nowrap; }
.default-button { width: 25px; height: 25px; min-width: 25px; padding: 0; border-radius: 6px; color: #8a949e; background: #fff; font-size: .87rem; }
.default-button:hover { color: var(--ink); border-color: var(--yellow-dark); background: #fff8d8; }
.hint { color: var(--muted); font-size: .77rem; font-weight: 400; line-height: 1.35; }
.upload-button { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-size: .88rem; }
.upload-button:hover { border-color: var(--yellow-dark); background: var(--soft); }
.visually-hidden-file { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.selected-file { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 400; overflow-wrap: anywhere; }
.check-row { display: flex; align-items: center; gap: 8px; }
.effect-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.effect-options { display: grid; gap: 13px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--soft); }
.effect-options.is-disabled { opacity: .45; pointer-events: none; }
.inline-action-row { display: flex; align-items: center; gap: 7px; }
.inline-action-row > button:first-child { flex: 1; }
.preset-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.preset-row:has(#presetSelect) { grid-template-columns: minmax(0, 1fr) auto auto; }
.danger { color: var(--danger); }
.export-actions { display: grid; gap: 8px; padding: 14px 10px 5px; }
.download-button { width: 100%; padding: 13px 16px; background: var(--ink); border-color: var(--ink); color: #fff; font-size: .98rem; }
.download-button:hover { background: #000; border-color: #000; }
.reset-all-button { width: 100%; border: 0; background: transparent; color: var(--muted); font-size: .83rem; padding: 8px; }

.preview-panel { padding: 18px; }
.preview-toolbar { display: flex; align-items: center; justify-content: center; margin-bottom: 11px; color: var(--muted); font-size: .8rem; }
.preview-toolbar span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; background: var(--soft); }
.canvas-frame { overflow: hidden; border-radius: 18px; border: 1px solid var(--border); }
.checkerboard {
    background-color: #fff;
    background-image: linear-gradient(45deg, #e8e8e8 25%, transparent 25%), linear-gradient(-45deg, #e8e8e8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e8e8e8 75%), linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
    background-size: 28px 28px;
    background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}
canvas { display: block; width: 100%; height: auto; cursor: grab; }
canvas.is-dragging { cursor: grabbing; }
.status { margin: 11px 2px 0; color: var(--muted); font-size: .83rem; }

footer {
    padding: 28px 24px 40px;
    text-align: center;
    color: var(--muted);
    font-size: .92rem;
}

@media (max-width: 920px) {
    .editor-grid { grid-template-columns: 1fr; }
    .controls { position: static; max-height: none; }
}

@media (max-width: 780px) {
    .hero { padding-top: 54px; }
    .hero-inner { grid-template-columns: 1fr; text-align: center; gap: 38px; }
    .hero p { margin-left: auto; margin-right: auto; }
    .hero-actions { justify-content: center; }
    .portrait { width: min(380px, 92vw); min-height: 320px; margin: 0 auto; }
    .portrait-image { max-height: 380px; }
    .page-width { width: min(100% - 36px, 1120px); }
    .maker-section { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 520px) {
    .two-column { grid-template-columns: 1fr; }
    .slider-row { grid-template-columns: minmax(0, 1fr) 54px 25px; }
}

@media (prefers-reduced-motion: no-preference) {
    .portrait-image { animation: bob 4s ease-in-out infinite; }
    @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
}
