* { box-sizing: border-box; }
body {
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    margin: 0;
    background: #000;
    color: #fff;
    color-scheme: dark;
}
.caption-box, .caption-box textarea,
input[type="text"], input[type="number"], textarea,
.login-form, .login-form input {
    color-scheme: light;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: #000;
    color: #fff;
    border-bottom: 1px solid #333;
    flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; flex-shrink: 0; color: #fff; }
.logout-link { color: #ccc; text-decoration: none; font-size: 14px; flex-shrink: 0; }
.logout-link:hover { color: #fff; }

.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: #000; }
.login-form {
    background: #fff;
    color: #000;
    padding: 32px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 260px;
}
.login-form input { padding: 10px; font-size: 15px; border: 1px solid #ccc; border-radius: 6px; background: #fff !important; color: #000 !important; }
.login-form button {
    padding: 10px; font-size: 15px; border: none; border-radius: 6px;
    background: #2d7a2d; color: #fff; cursor: pointer;
}
.error { color: #ff6b6b; font-size: 14px; margin: 0; }

.editor { max-width: 1200px; margin: 16px auto 40px; padding: 0 16px; }

.steps-guide {
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    gap: 8px; font-size: 13px; color: #ddd;
}
.steps-guide .step b { color: #fff; }
.steps-guide .step-arrow { color: #666; }

.file-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    height: 280px; border: 3px dashed #555; border-radius: 10px;
    background: #000; cursor: pointer; font-size: 18px; color: #fff;
}
.file-drop input { display: none; }
.file-drop-plus {
    font-size: 48px; line-height: 1; color: #4caf50; font-weight: 300;
}
.file-drop-text { font-size: 16px; color: #fff; }
.file-drop:hover { border-color: #888; background: #0a0a0a; }
.file-drop.dragover { border-color: #2d7a2d; background: #0a140a; color: #4caf50; }

/* ---- Edit step layout: image column | preview+caption+folder column ---- */
.edit-step[hidden] { display: none; }
.edit-step {
    display: grid;
    grid-template-columns: max-content 300px;
    justify-content: center;
    gap: 16px;
    align-items: start;
}
@media (max-width: 860px) {
    .edit-step { grid-template-columns: 1fr; justify-content: stretch; }
}

.image-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 12px; }

.image-panel {
    background: #000; border: 1px solid #333; border-radius: 10px; padding: 10px;
    display: flex; flex-direction: column; align-items: center;
}
.canvas-wrap {
    position: relative;
    display: inline-block;
    background: repeating-conic-gradient(#2a2a2a 0% 25%, #1a1a1a 0% 50%) 50% / 20px 20px;
    border-radius: 6px;
    overflow: hidden;
    max-width: 100%;
}
.canvas-wrap canvas { display: block; max-width: 100%; height: auto; }
#overlayCanvas { position: absolute; top: 0; left: 0; cursor: crosshair; touch-action: none; }
.dims { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: #fff; }
.hint { color: #fff; font-size: 12px; margin: 2px 0 0; }

/* ---- Toolbar: rows stacked, centered under the image ---- */
.toolbar {
    background: #000; border: 1px solid #333; border-radius: 10px; padding: 10px 14px;
    display: flex; flex-direction: column; gap: 10px; align-items: center;
    width: 100%;
}
.toolbar-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.toolbar-row.row-resize { flex-wrap: nowrap; }
.tool-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-label { font-size: 13px; font-weight: 700; text-transform: uppercase; color: #ddd; letter-spacing: 0.03em; margin-right: 2px; white-space: nowrap; }
.toolbar button {
    padding: 8px 14px; border: none; border-radius: 6px; background: #333; color: #fff;
    cursor: pointer; font-size: 14px; white-space: nowrap;
}
.toolbar button:hover { background: #4a4a4a; }
.toolbar button.btn-muted { background: #555; }
.toolbar button.btn-muted:hover { background: #777; }
.toolbar button.btn-save { background: #2d7a2d; }
.toolbar button.btn-save:hover { background: #1e5c1e; }
.dim-input {
    width: 3.5em !important;
    padding: 1px !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    text-align: center;
    background: #fff !important;
    color: #000 !important;
    -moz-appearance: textfield;
    appearance: textfield;
}
.dim-input::-webkit-outer-spin-button,
.dim-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.x-sep { color: #ccc; font-size: 15px; }
.inline-check { display: flex; align-items: center; gap: 6px; font-size: 15px; color: #eee; white-space: nowrap; }
.inline-check input[type="checkbox"] { width: 18px; height: 18px; }

/* ---- Caption ---- */
.caption-box {
    background: #fff; color: #000; border-radius: 10px; padding: 10px 14px;
}
.caption-box label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 4px; color: #000; }
.caption-box .sub { font-weight: 400; color: #555; font-size: 11px; }
.caption-box textarea { font-size: 14px; padding: 8px; background: #fff !important; color: #000 !important; }

/* ---- Folder picker ---- */
.folder-box {
    background: #000; border: 1px solid #333; border-radius: 10px; padding: 10px 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.folder-box > label { font-size: 14px; font-weight: 600; color: #fff; }
.folder-list { display: flex; flex-wrap: wrap; gap: 8px; }
.no-folders { color: #bbb; font-size: 13px; margin: 0; }
.folder-card {
    display: flex; align-items: center; gap: 8px;
    border: 2px solid #555; border-radius: 20px; padding: 7px 8px 7px 14px;
    cursor: pointer; font-size: 14px; background: #1a1a1a; color: #fff;
}
.folder-card:hover { border-color: #999; }
.folder-card.selected { border-color: #4caf50; background: #0a140a; color: #6fcf6f; font-weight: 600; }
.folder-card-name { white-space: nowrap; }
.folder-delete {
    border: none; background: transparent; color: #bbb; font-size: 18px; line-height: 1;
    cursor: pointer; padding: 2px 6px; border-radius: 50%;
}
.folder-delete:hover { background: #4a2020; color: #ff8080; }
.new-folder-row { display: flex; gap: 8px; }
.new-folder-row input { flex: 1; }
.new-folder-row button {
    padding: 9px 14px; border: none; border-radius: 6px; background: #444; color: #fff; cursor: pointer; font-size: 14px; white-space: nowrap;
}
.new-folder-row button:hover { background: #666; }

input[type="text"], input[type="number"], textarea {
    padding: 9px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; width: 100%; font-family: inherit;
    background: #fff !important; color: #000 !important;
}
input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
    color: #000 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #000 !important;
}
.status { min-height: 18px; font-size: 13px; margin: 0; text-align: center; color: #fff; }

/* ---- Live slideshow preview ---- */
.preview-card {
    background: #000; border: 1px solid #333; border-radius: 10px; padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.preview-card h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin: 0; color: #bbb; }
.preview-card img { width: 100%; border-radius: 6px; display: block; background: #000; max-height: 160px; object-fit: contain; }
.preview-card p#previewCaption { color: #fff; font-size: 13px; margin: 0; min-height: 16px; }
.preview-hint { font-size: 11px; color: #fff; margin: 0; }
