* {
    box-sizing: border-box;
}

/* Author rules that set `display` on an element (e.g. .btn-small, .queue-
   toolbar) otherwise beat the browser's built-in `[hidden] { display: none }`
   — the fix has to win the cascade explicitly, not just set the attribute. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Chivo", sans-serif;
    color: #1c1c1c;
    background: #fff;
}

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 18px 24px;
    border-bottom: 1px solid #e4e1db;
}

header .title {
    flex: 0 0 auto;
    font-weight: 600;
    font-size: 15px;
    color: #1c1c1c;
    text-decoration: none;
}

header .count {
    flex: 0 0 auto;
    margin-left: auto;
    white-space: nowrap;
    font-size: 14px;
    color: #8a8a8a;
}

header .save-status {
    flex: 0 0 auto;
    margin-left: auto;
    white-space: nowrap;
    font-size: 12px;
    color: #9a9a9a;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1100px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 700px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 420px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.item {
    border-right: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
}

.thumb {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f2f2f2;
    cursor: pointer;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.caption {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13px;
}

.caption .idx {
    color: #1a1a1a;
}

.caption .name {
    color: #1a1a1a;
    font-weight: 500;
}

.empty {
    padding: 60px 24px;
    color: #6b6b6b;
    font-size: 14px;
}

/* Edit page */
.edit-layout {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - 57px);
}

.edit-form {
    order: 1;
    width: 50%;
    padding: 64px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    align-items: flex-start;
}

.edit-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.field-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9a9a9a;
}

.edit-form input,
.edit-form select {
    font: inherit;
    font-size: 14px;
    padding: 8px 2px;
    border: none;
    border-bottom: 1px solid #e4e1db;
    border-radius: 0;
    background: transparent;
    color: #1c1c1c;
    transition: border-color 0.15s ease;
}

.edit-form input:focus,
.edit-form select:focus {
    outline: none;
    border-bottom-color: #1c1c1c;
}

.name-input {
    font: inherit;
    font-size: 26px;
    font-weight: 500;
    line-height: 1.3;
    padding: 8px 2px 10px;
    border: none;
    border-bottom: 1px solid #e4e1db;
    border-radius: 0;
    background: transparent;
    color: #1c1c1c;
    width: 100%;
    resize: none;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.name-input:focus {
    outline: none;
    border-bottom-color: #1c1c1c;
}

.edit-image {
    order: 2;
    width: 50%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 64px;
    background: transparent;
}

.edit-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Add-a-want page: file picker fills the image slot instead of a photo */
.edit-image .file-drop {
    width: 100%;
    max-width: 480px;
}

.edit-image .camera-btn {
    margin-top: 16px;
}

/* Want page: photo grid (select/pin/reprocess) + an add-more-photos form,
   stacked in the image slot instead of a single photo */
.want-photos-column {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.add-photos-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.add-photos-form .file-drop {
    padding: 16px;
}

.want-price {
    margin-left: auto;
    color: #8a8a8a;
}

@media (max-width: 700px) {
    .edit-layout {
        flex-direction: column;
    }

    .edit-form,
    .edit-image {
        width: 100%;
    }

    .edit-image {
        order: 1;
        padding: 32px;
    }

    .edit-form {
        order: 2;
    }
}

/* Checkbox groups (occasion, condition) */
.field-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.checkbox-group .checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: auto;
    font-size: 14px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* Colors tag input */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 2px;
    border: none;
    border-bottom: 1px solid #e4e1db;
}

.tag-input .tags {
    display: contents;
}

.tag-input .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 12px;
    font-size: 13px;
    background: #f7f5f2;
    border: none;
    border-radius: 14px;
}

.tag-input .tag button {
    border: none;
    background: none;
    font: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    color: #9a9a9a;
    padding: 0;
}

.tag-input .tag button:hover {
    color: #1c1c1c;
}

.tag-input .tag-entry {
    flex: 1 1 120px;
    min-width: 100px;
    border: none;
    padding: 4px 2px;
    font: inherit;
    font-size: 14px;
    background: transparent;
}

.tag-input .tag-entry:focus {
    outline: none;
}

.tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e4e1db;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.tag-suggestion {
    padding: 8px 12px;
    font-size: 13px;
    color: #1c1c1c;
    cursor: pointer;
}

.tag-suggestion:hover,
.tag-suggestion.active {
    background: #f7f5f2;
}

.tag-create {
    position: sticky;
    bottom: 0;
    padding: 8px 12px;
    font-size: 13px;
    color: #1a4fd6;
    cursor: pointer;
    background: #fff;
    border-top: 1px solid #e4e1db;
}

.tag-create:hover,
.tag-create.active {
    background: #f7f5f2;
}

/* Collapsible "More details" */
.more-details {
    width: 100%;
    max-width: 400px;
}

.more-details summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9a9a9a;
    list-style: none;
}

.more-details summary::-webkit-details-marker {
    display: none;
}

.more-details summary::before {
    content: "▸ ";
}

.more-details[open] summary::before {
    content: "▾ ";
}

.more-details-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-top: 20px;
}

.readonly-value {
    font-size: 14px;
    color: #8a8a8a;
}

/* Notes editor */
.notes-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.notes-editor {
    min-height: 100px;
    padding: 8px 2px;
    border: none;
    border-top: 1px solid #e4e1db;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.notes-editor:focus {
    outline: none;
}

.notes-editor:empty::before {
    content: attr(data-placeholder);
    color: #9a9a9a;
}

.notes-editor .mention {
    display: inline-block;
    padding: 1px 6px;
    background: #eef0ff;
    border: 1px solid #c7ccf7;
    border-radius: 10px;
    font-size: 13px;
    color: #33399e;
    cursor: pointer;
}

.notes-editor a {
    color: #1a4fd6;
    cursor: pointer;
}

.mention-menu {
    position: absolute;
    z-index: 10;
    min-width: 160px;
    background: #fff;
    border: 1px solid #e4e1db;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.mention-option {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}

.mention-option:hover {
    background: #f2f2f2;
}

/* Search & filters */
.search-form {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}

.search-input {
    flex: 1 1 auto;
    min-width: 160px;
    font: inherit;
    font-size: 14px;
    padding: 8px 2px;
    border: none;
    border-bottom: 1px solid #e4e1db;
    border-radius: 0;
    background: transparent;
    color: #1c1c1c;
    transition: border-color 0.15s ease;
}

.search-input:focus {
    outline: none;
    border-bottom-color: #1c1c1c;
}

.filters-panel {
    position: relative;
}

.filters-panel .filters-body {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    min-width: 480px;
    max-width: 640px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e4e1db;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.filter-group {
    min-width: 140px;
}

.filter-group.scrollable .checkbox-group {
    flex-direction: column;
    flex-wrap: nowrap;
    max-height: 160px;
    overflow-y: auto;
}

.filter-count {
    font-size: 11px;
    color: #9a9a9a;
}

.clear-filters {
    border: none;
    background: none;
    font: inherit;
    font-size: 13px;
    padding: 0;
    color: #9a9a9a;
    cursor: pointer;
    text-decoration: none;
}

.clear-filters:hover {
    color: #1c1c1c;
}

.empty a {
    color: #1a4fd6;
}

@media (max-width: 700px) {
    .filters-panel .filters-body {
        position: static;
        min-width: 0;
        max-width: none;
        margin-top: 12px;
        box-shadow: none;
    }
}

/* Buttons (upload + label pages) */
.btn-primary {
    align-self: flex-start;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 22px;
    background: #1c1c1c;
    color: #fff;
    border: 1px solid #1c1c1c;
    cursor: pointer;
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-small {
    font: inherit;
    font-size: 12px;
    padding: 5px 10px;
    background: #fff;
    color: #1c1c1c;
    border: 1px solid #cfcbc4;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-small:hover {
    border-color: #1c1c1c;
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: default;
    border-color: #cfcbc4;
}

.btn-danger:hover {
    border-color: #b3261e;
    color: #b3261e;
}

.btn-label {
    background: #1c1c1c;
    color: #fff;
    border-color: #1c1c1c;
}

/* Header nav link (Queue, Wants — go look at something that already
   exists): plain text, low visual weight. */
.header-link {
    font-size: 13px;
    color: #1a4fd6;
    text-decoration: none;
    white-space: nowrap;
}

/* Header action (Add items, Add Wants — go create something): bordered
   like a button (same recipe as .btn-small) so it reads as a distinct
   action rather than another destination alongside the nav links. */
.header-action {
    font-size: 13px;
    padding: 5px 10px;
    background: #fff;
    color: #1c1c1c;
    border: 1px solid #cfcbc4;
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
}

.header-action:hover {
    border-color: #1c1c1c;
}

/* Upload page */
.upload-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 44px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.file-drop {
    display: block;
    border: 1px dashed #b9b4ab;
    padding: 28px;
    text-align: center;
    cursor: pointer;
}

.file-drop.dragover {
    border-color: #1c1c1c;
    background: #f7f5f2;
}

.file-drop-hint {
    font-size: 14px;
    color: #6b6b6b;
    line-height: 1.6;
}

.file-drop-hint small {
    color: #9a9a9a;
}

.file-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.file-previews:empty {
    display: none;
    margin-top: 0;
}

.file-preview {
    width: 72px;
    height: 72px;
    object-fit: cover;
    background: #f2f2f2;
    border: 1px solid #e4e1db;
}

.file-preview-chip {
    font-size: 12px;
    padding: 6px 10px;
    border: 1px solid #e4e1db;
    background: #f7f5f2;
    align-self: center;
}

.upload-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 480px;
}

.upload-options .checkbox,
.redo-form .checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.message-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-field textarea {
    font: inherit;
    font-size: 14px;
    padding: 8px 2px;
    border: none;
    border-bottom: 1px solid #e4e1db;
    border-radius: 0;
    background: transparent;
    resize: vertical;
}

.message-field textarea:focus {
    outline: none;
    border-bottom-color: #1c1c1c;
}

.upload-errors {
    color: #b3261e;
    font-size: 13px;
    margin: 0;
}

.upload-success {
    color: #1b7f3b;
    font-size: 13px;
    margin: 0;
}

.upload-success a {
    color: inherit;
}

/* Processing queue */
.queue-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.queue-header {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 28px;
}

.section-title {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9a9a9a;
    margin: 0;
}

.queue-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #6b6b6b;
}

.queue-toolbar .checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Pushes action buttons (Run/Clear, Redo/Delete/Clear) to the far right,
   separating "what will happen" from "do it" at a glance. */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.ucard {
    border: 1px solid #e4e1db;
    display: flex;
    flex-direction: column;
    position: relative;
}

.ucard.status-failed {
    border-color: #e0b4b1;
}

.ucard-select {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
}

.ucard-thumb {
    aspect-ratio: 4 / 3;
    background: #f2f2f2;
    overflow: hidden;
}

.ucard-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ucard.status-processing .ucard-thumb img {
    opacity: 0.45;
}

.ucard-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 0;
}

.ucard-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ucard-status {
    font-size: 12px;
    color: #6b6b6b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ucard-status.ok {
    color: #1b7f3b;
}

.ucard-status.err {
    color: #b3261e;
}

.ucard-error {
    font-size: 11px;
    color: #b3261e;
}

.ucard-actions {
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
    margin-top: auto;
}

.spinner {
    width: 11px;
    height: 11px;
    border: 2px solid #cfcbc4;
    border-top-color: #1c1c1c;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Redo dialog */
.redo-dialog {
    border: 1px solid #e4e1db;
    padding: 24px;
    max-width: 420px;
    width: calc(100vw - 48px);
    font-family: "Chivo", sans-serif;
    color: #1c1c1c;
}

.redo-dialog::backdrop {
    background: rgba(0, 0, 0, 0.25);
}

.redo-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.redo-form h3 {
    margin: 0;
    font-size: 15px;
}

.redo-form .field-block {
    max-width: none;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.edit-form .btn-primary {
    margin-top: 8px;
}

/* Camera capture + removable pending previews */
.camera-btn {
    align-self: center;
    font-size: 14px;
    padding: 10px 18px;
    margin-top: -8px;
}

.file-preview-item {
    position: relative;
    display: inline-flex;
}

.file-preview-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #cfcbc4;
    border-radius: 50%;
    background: #fff;
    color: #6b6b6b;
    font: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.file-preview-remove:hover {
    border-color: #b3261e;
    color: #b3261e;
}

/* Login page */
.login-page {
    min-height: calc(100vh - 57px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 320px;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
    text-align: center;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form input[type="password"] {
    font: inherit;
    font-size: 16px;
    padding: 10px 2px;
    border: none;
    border-bottom: 1px solid #e4e1db;
    background: transparent;
}

.login-form input[type="password"]:focus {
    outline: none;
    border-bottom-color: #1c1c1c;
}

.login-form .btn-primary {
    align-self: stretch;
    text-align: center;
}

.login-error {
    margin: 0;
    font-size: 13px;
    color: #b3261e;
}

