* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: #0f172a; background: #f8fafc; }

.app { min-height: 100%; display: flex; flex-direction: column; }
.header { padding: 16px 20px; background: #111111; color: white; }
.header h1 { margin: 0; font-size: 20px; font-weight: 600; }

.main { display: grid; grid-template-columns: 320px 1fr; gap: 16px; padding: 16px; }

@media (max-width: 900px) {
    .main { display: flex; flex-direction: column-reverse; gap: 16px; }
}

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

.button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; border-radius: 8px; background: #e2e8f0; color: #0f172a; cursor: pointer; user-select: none; border: 1px solid #cbd5e1; }
.button.primary { background: #111111; color: white; border-color: #0a0a0a; }
.button[disabled] { opacity: .6; cursor: not-allowed; }

.hint { color: #475569; font-size: 12px; margin-top: 6px; }

.frames { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.frame-option { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: white; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.frame-option.selected { border-color: #111111; }
.frame-option img { display: block; width: 100%; height: auto; }
.frame-option .label { position: absolute; bottom: 6px; left: 6px; right: 6px; background: rgba(15,23,42,.65); color: white; font-size: 12px; padding: 2px 6px; border-radius: 4px; text-align: center; }

.covers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cover-option { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: white; box-shadow: 0 1px 2px rgba(0,0,0,.06); aspect-ratio: 4 / 3; }
.cover-option:hover { border-color: #111111; }
.cover-option img { display: block; width: 100%; height: auto; }
.cover-option .label { position: absolute; bottom: 6px; left: 6px; right: 6px; background: rgba(15,23,42,.65); color: white; font-size: 12px; padding: 2px 6px; border-radius: 4px; text-align: center; }

.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar select { padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1; background: white; }

.preview { display: flex; align-items: center; justify-content: center; }
.canvas-wrap { width: 100%; max-width: 800px; aspect-ratio: 1 / 1; background: #e2e8f0; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 2px #cbd5e1; }
#canvas { width: 100%; height: 100%; display: block; }

.footer { padding: 10px 16px; color: #475569; font-size: 12px; }


/* Modal for cover preview */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal[hidden] { display: none; }
.modal:not([hidden]) { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-content { position: relative; background: #ffffff; border-radius: 12px; padding: 12px; max-width: min(92vw, 900px); width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-close { position: absolute; top: 6px; right: 6px; border: 1px solid #cbd5e1; background: #e2e8f0; color: #0f172a; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.modal-actions { display: flex; justify-content: center; margin-top: 10px; }
#cover-modal-img { display: block; width: 100%; height: auto; border-radius: 8px; background: #e2e8f0; }


