@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

/* =========================================================
   Self-hosted canvas fonts (downloaded from Google Fonts via
   the Fontsource distribution, see /fonts/LICENSE-fonts.txt)
   These are the fonts users can pick for the generated image
   text — kept separate from the UI chrome fonts above.
   ========================================================= */
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 800; font-style: normal; font-display: swap; src: url('fonts/inter-800.woff2') format('woff2'); }

@font-face { font-family: 'Montserrat'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/montserrat-400.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/montserrat-600.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/montserrat-700.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 800; font-style: normal; font-display: swap; src: url('fonts/montserrat-800.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 900; font-style: normal; font-display: swap; src: url('fonts/montserrat-900.woff2') format('woff2'); }

@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/plus-jakarta-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/plus-jakarta-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/plus-jakarta-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-weight: 800; font-style: normal; font-display: swap; src: url('fonts/plus-jakarta-sans-800.woff2') format('woff2'); }

@font-face { font-family: 'Poppins'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/poppins-400.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/poppins-600.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/poppins-700.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 900; font-style: normal; font-display: swap; src: url('fonts/poppins-900.woff2') format('woff2'); }

@font-face { font-family: 'Playfair Display'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/playfair-display-400.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/playfair-display-700.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-weight: 900; font-style: normal; font-display: swap; src: url('fonts/playfair-display-900.woff2') format('woff2'); }

@font-face { font-family: 'Bebas Neue'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/bebas-neue-400.woff2') format('woff2'); }

@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-style: normal; font-display: swap; src: url('fonts/space-grotesk-500.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/space-grotesk-700.woff2') format('woff2'); }

@font-face { font-family: 'DM Serif Display'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/dm-serif-display-400.woff2') format('woff2'); }

@font-face { font-family: 'Oswald'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/oswald-400.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/oswald-600.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/oswald-700.woff2') format('woff2'); }

@font-face { font-family: 'Courier Prime'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/courier-prime-400.woff2') format('woff2'); }
@font-face { font-family: 'Courier Prime'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/courier-prime-700.woff2') format('woff2'); }

:root {
    /* Studio palette — deep ink panel, warm paper canvas, ember accent */
    --ink-900: #14171F;
    --ink-800: #1B2030;
    --ink-700: #262C40;
    --ink-600: #363E58;
    --ink-line: #333B54;
    --paper: #F4EFE6;
    --paper-line: #E3DACB;

    --ember: #F0A24A;
    --ember-hover: #E0913A;
    --teal: #4DC9B0;
    --teal-hover: #38B39A;
    --danger: #E8677D;
    --ad-yellow: #FFCC00;

    --text-hi: #F4F1EA;
    --text-lo: #A6ADC6;
    --text-faint: #6E7590;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: all 0.18s ease;

    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

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

body {
    font-family: var(--font-ui);
    background: var(--ink-900);
    color: var(--text-hi);
    line-height: 1.5;
    min-height: 100vh;
}

.app {
    display: grid;
    grid-template-columns: 400px 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar (controls) ---------- */
.sidebar {
    background: var(--ink-800);
    border-right: 1px solid var(--ink-line);
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    overflow: hidden;
}

.app-header {
    padding: 1.75rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--ink-line);
}
.app-header .eyebrow {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ember);
    font-weight: 600;
}
.app-header h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 0.35rem;
    color: var(--text-hi);
}
.app-header .subtitle {
    color: var(--text-lo);
    font-size: 0.84rem;
    margin-top: 0.35rem;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 1rem 1.25rem 0;
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.76rem;
    padding: 0.6rem 0.2rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--text-hi); }
.tab-btn.active {
    color: var(--ember);
    border-bottom: 2px solid var(--ember);
}

.tab-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.25rem 1.5rem;
}
.tab-panel { display: none; flex-direction: column; gap: 1.1rem; }
.tab-panel.active { display: flex; }

.panel-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ink-line);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* ---------- Form elements ---------- */
.form-group { display: flex; flex-direction: column; gap: 0.45rem; }
.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }

label, .group-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-lo);
    text-transform: uppercase;
}
.hint { font-size: 0.78rem; color: var(--text-faint); text-transform: none; letter-spacing: normal; }
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.emoji-trigger {
    background: var(--ink-700);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    line-height: 1;
    padding: 0.25rem 0.45rem;
    cursor: pointer;
    transition: var(--transition);
}
.emoji-trigger:hover { border-color: var(--ember); background: var(--ink-600); }

textarea, select, input[type="text"] {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    background: var(--ink-700);
    color: var(--text-hi);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}
textarea:focus, select:focus, input:not([type="range"]):focus {
    outline: 2px solid var(--ember);
    outline-offset: 1px;
}

input[type="range"] {
    width: 100%;
    height: 20px;
    margin: 0;
    display: block;
    accent-color: var(--ember);
}
input[type="range"]:focus,
input[type="range"]:hover {
    outline: none;
}

input[type="color"] {
    width: 42px;
    height: 34px;
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    background: var(--ink-700);
    padding: 2px;
    cursor: pointer;
}

.color-row { display: flex; align-items: center; gap: 0.6rem; }
.color-row .swatch-label { font-size: 0.82rem; color: var(--text-lo); }

.range-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.range-row .range-value {
    font-size: 0.75rem;
    color: var(--text-faint);
    min-width: 2.6em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Segmented button groups (alignment, vertical position, fill type...) */
.segmented {
    display: flex;
    background: var(--ink-700);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-wrap: wrap;
}
.segmented button {
    flex: 1;
    min-width: 44px;
    background: transparent;
    border: none;
    color: var(--text-lo);
    padding: 0.55rem 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    border-right: 1px solid var(--ink-line);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--text-hi); }
.segmented button.active {
    background: var(--ember);
    color: var(--ink-900);
}

/* Swatch grid for shape/pattern choice */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.swatch-grid button {
    aspect-ratio: 1;
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    background: var(--ink-700);
    color: var(--text-lo);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.swatch-grid button:hover { border-color: var(--ember); color: var(--text-hi); }
.swatch-grid button.active {
    border-color: var(--ember);
    background: rgba(240, 162, 74, 0.14);
    color: var(--ember);
}

/* Named color-contrast presets */
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.preset-chip {
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    background: var(--ink-700);
}
.preset-chip:hover { border-color: var(--ember); }
.preset-chip .swatch {
    width: 22px; height: 22px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.25);
}
.preset-chip .preset-name {
    font-size: 0.76rem;
    color: var(--text-hi);
    font-weight: 500;
    line-height: 1.2;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
    position: absolute;
    inset: 0;
    background: var(--ink-600);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
}
.switch .track::before {
    content: "";
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    background: var(--text-hi);
    border-radius: 50%;
    transition: var(--transition);
}
.switch input:checked + .track { background: var(--ember); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--ink-900); }

hr.divider { border: none; border-top: 1px solid var(--ink-line); margin: 0.2rem 0; }

/* ---------- Buttons ---------- */
.btn {
    padding: 0.75rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.86rem;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
}
.btn-primary { background: var(--ember); color: var(--ink-900); }
.btn-primary:hover { background: var(--ember-hover); }
.btn-secondary { background: var(--ink-700); color: var(--text-hi); border: 1px solid var(--ink-line); }
.btn-secondary:hover { background: var(--ink-600); }
.btn-success { background: var(--teal); color: var(--ink-900); }
.btn-success:hover { background: var(--teal-hover); }
.btn-ghost {
    background: transparent;
    color: var(--text-lo);
    border: 1px dashed var(--ink-line);
    width: 100%;
}
.btn-ghost:hover { color: var(--ember); border-color: var(--ember); }
.btn-icon-danger {
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 0.92rem;
    width: auto;
    padding: 0.2rem 0.4rem;
}
.btn-icon-danger:hover { color: var(--danger); }

.export-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}
.font-credit {
    font-size: 0.7rem;
    color: var(--text-faint);
    text-align: center;
    margin-top: 0.2rem;
}
.font-credit a { color: var(--text-lo); }
.font-credit a:hover { color: var(--ember); }

.powered-by {
    font-size: 0.7rem;
    color: var(--text-faint);
    text-align: center;
    margin-top: 0;
    padding-top: 0;
}

.powered-by a { color: var(--text-lo); }
.powered-by a:hover { color: var(--ember); }

/* ---------- Overlays panel ---------- */
.overlay-card {
    background: var(--ink-700);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.overlay-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.overlay-card-head .overlay-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-hi);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.overlay-thumb, .image-thumb {
    width: 26px; height: 26px;
    border-radius: 6px;
    background: var(--paper);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.overlay-thumb img, .image-thumb img { max-width: 100%; max-height: 100%; object-fit: cover; width: 100%; height: 100%; }

.corner-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    width: 100%;
}
.corner-grid button {
    aspect-ratio: 1;
    background: var(--ink-800);
    border: 1px solid var(--ink-line);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
}
.corner-grid button.active { border-color: var(--ember); background: rgba(240,162,74,0.14); }
.corner-grid button .dot {
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
}
.corner-grid button.active .dot { background: var(--ember); }
.corner-grid button[data-corner="tl"] .dot { top: 4px; left: 4px; }
.corner-grid button[data-corner="tc"] .dot { top: 4px; left: 50%; transform: translateX(-50%); }
.corner-grid button[data-corner="tr"] .dot { top: 4px; right: 4px; }
.corner-grid button[data-corner="ml"] .dot { top: 50%; left: 4px; transform: translateY(-50%); }
.corner-grid button[data-corner="center"] .dot { top: 50%; left: 50%; transform: translate(-50%,-50%); }
.corner-grid button[data-corner="mr"] .dot { top: 50%; right: 4px; transform: translateY(-50%); }
.corner-grid button[data-corner="bl"] .dot { bottom: 4px; left: 4px; }
.corner-grid button[data-corner="bc"] .dot { bottom: 4px; left: 50%; transform: translateX(-50%); }
.corner-grid button[data-corner="br"] .dot { bottom: 4px; right: 4px; }

/* Background-image picker card */
.image-fill-card {
    background: var(--ink-700);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.image-fill-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.image-fill-head .image-name {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.82rem; color: var(--text-hi);
}

/* ---------- Preview / main column ---------- */
.main-col {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.preview-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2.5rem 1.5rem;
    background: repeating-conic-gradient(var(--paper-line) 0% 25%, var(--paper) 0% 50%) 0 0 / 24px 24px;
}
.preview-container {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    overflow: hidden;
    display: flex;
    max-width: 100%;
    max-height: 70vh;
}
.preview-container svg {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
}
.preview-container svg [data-overlay-id] {
    cursor: grab;
    touch-action: none;
}
.preview-container svg [data-overlay-id]:active {
    cursor: grabbing;
}

.canvas-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    color: var(--text-faint);
    font-size: 0.82rem;
}
.canvas-footer .dim-badge {
    font-family: var(--font-display);
    background: var(--ink-800);
    border: 1px solid var(--ink-line);
    color: var(--text-lo);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
}

/* ---------- Ad placeholder (Google AdSense slot) ---------- */
.ad-placeholder {
    margin: 1.25rem 2.5rem 2rem;

    /* 1. Change to block so the div takes up the full available width */
    display: block;
    width: auto;

    /* 2. Use min-height instead of fixed height so responsive ads can expand vertically */
    min-height: 90px; /* You can increase this to 250px if you prefer square ads */

    /* 3. Clean up the placeholder styling (remove the yellow stripes) */
    background: transparent;
    border-radius: var(--radius-sm);
    overflow: hidden; /* Prevents ad bleeding out of the border radius */
}

/* Ensure the inner wrapper also takes full width */
.ad-placeholder .ads {
    display: block;
    width: 100%;
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { max-height: none; border-right: none; border-bottom: 1px solid var(--ink-line); }
    .tab-scroll { max-height: 60vh; }
    .ad-placeholder, .canvas-footer, .preview-wrap { margin-left: 1rem; margin-right: 1rem; padding-left: 1rem; padding-right: 1rem; }
}

/* ---------------- Emoji picker modal ---------------- */
.emoji-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 18, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}
.emoji-modal {
    background: var(--ink-800);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
    overflow: hidden;
}
.emoji-modal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--ink-line);
}
.emoji-modal-header input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-sm);
    background: var(--ink-700);
    color: var(--text-hi);
    font-family: inherit;
    font-size: 0.9rem;
}
.emoji-modal-header input:focus { outline: 2px solid var(--ember); outline-offset: 1px; }
.emoji-grid {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    align-content: start;
}
.emoji-grid button {
    aspect-ratio: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.emoji-grid button:hover { background: var(--ink-700); border-color: var(--ink-line); }
.emoji-grid .no-results {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.85rem;
    padding: 1.5rem 0;
}

h1 a {
    text-decoration: none;
    color: #fff;
}
