@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --font-display: 'Lora', Georgia, serif;
    --font-body: 'DM Sans', sans-serif;

    --bg: #f7f5f2;
    --surface: #ffffff;
    --surface-2: #faf9f7;
    --border: #e8e3dc;
    --border-light: #f0ece6;

    --text: #1a1714;
    --text-secondary: #4a4540;
    --muted: #9a928a;

    --accent: #c8783a;
    --accent-light: #f5ede4;
    --accent-dark: #a85f28;

    --green: #3a7c5a;
    --green-light: #e8f4ee;
    --red: #c84040;
    --red-light: #fef2f2;

    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
    --transition: 0.18s ease;
}

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

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ─── LAYOUT ─────────────────────────────────────── */
.page-wrap {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ─── NAV ─────────────────────────────────────────── */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.nav-brand {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.nav-brand span {
    color: var(--accent);
}
.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    align-items: center;
}
.nav-link {
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link.active {
    background: var(--accent-light);
    color: var(--accent-dark);
}
.nav-search {
    flex: 1;
    max-width: 320px;
    position: relative;
}
.nav-search input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 1rem 0.45rem 2.25rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text);
    transition: border-color var(--transition);
}
.nav-search input:focus {
    outline: none;
    border-color: var(--accent);
}
.nav-search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.875rem;
    pointer-events: none;
}

/* ─── FLASH ──────────────────────────────────────── */
.flash {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}
.flash-success { background: var(--green-light); color: var(--green); }
.flash-error   { background: var(--red-light); color: var(--red); }

/* ─── PAGE HEADER ────────────────────────────────── */
.page-header {
    padding: 2.5rem 0 1.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}
.page-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.page-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* ─── SECTION LABEL ──────────────────────────────── */
.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* ─── BUTTONS ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.btn-ghost {
    background: transparent;
    color: var(--muted);
    padding: 0.4rem 0.7rem;
}
.btn-ghost:hover { color: var(--text); background: var(--border-light); }
.btn-danger {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}
.btn-copy {
    background: var(--accent-light);
    color: var(--accent-dark);
    border: 1px solid #e8d0bc;
    font-weight: 600;
}
.btn-copy:hover { background: var(--accent); color: white; }
.btn-copy.copied {
    background: var(--green-light);
    color: var(--green);
    border-color: #b6d9c6;
}

/* ─── FORMS ──────────────────────────────────────── */
.field { margin-bottom: 1.25rem; }
.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.field-input, .field-textarea, .field-select {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.field-input:focus, .field-textarea:focus, .field-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,120,58,0.1);
}
.field-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}
.field-textarea.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    min-height: 160px;
}
.field-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

/* ─── CARDS ──────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

/* ─── CATEGORY GRID ──────────────────────────────── */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}
.cat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: block;
}
.cat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--cat-color, var(--accent));
}
.cat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.cat-card-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}
.cat-card-desc {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}
.cat-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}
.cat-card-meta span { display: flex; align-items: center; gap: 0.3rem; }

/* ─── PROMPT GRID ────────────────────────────────── */
.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}
.prompt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition), transform var(--transition);
}
.prompt-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.prompt-card-img {
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg);
    cursor: zoom-in;
    flex-shrink: 0;
}
.prompt-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.prompt-card:hover .prompt-card-img img { transform: scale(1.03); }
.prompt-card-img.no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: unset;
    height: 60px;
}
.prompt-card-img.no-img span { color: var(--muted); font-size: 1.5rem; }
.prompt-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.prompt-card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.6rem;
    line-height: 1.3;
}
.prompt-card-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    flex: 1;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.prompt-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 1rem;
}
.tag {
    background: var(--accent-light);
    color: var(--accent-dark);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.prompt-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ─── ASSET GRID ─────────────────────────────────── */
.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}
.asset-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.asset-card:hover { box-shadow: var(--shadow-lg); }
.asset-card-img {
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg);
    cursor: zoom-in;
}
.asset-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.asset-card:hover .asset-card-img img { transform: scale(1.05); }
.asset-card-name {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── SECTIONS ───────────────────────────────────── */
.section { margin-bottom: 3rem; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.section-head h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

/* ─── SETTINGS ───────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 2rem;
    padding: 2rem 0;
    min-height: 80vh;
}
.settings-nav {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    height: fit-content;
    position: sticky;
    top: 80px;
}
.settings-nav-item {
    display: block;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
    text-decoration: none;
}
.settings-nav-item:hover, .settings-nav-item.active {
    background: var(--accent-light);
    color: var(--accent-dark);
}
.settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
}
.settings-panel h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

/* ─── TABLE ──────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table .thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    cursor: zoom-in;
}

/* ─── MODAL / FORM OVERLAY ───────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,23,20,0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(12px);
    transition: transform 0.2s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ─── IMAGE UPLOAD ZONE ──────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--bg);
    position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
}
.upload-zone-text {
    font-size: 0.85rem;
    color: var(--muted);
    pointer-events: none;
}
.upload-zone-text strong { color: var(--accent); }
.upload-preview {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.upload-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.upload-preview-name { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── LIGHTBOX ───────────────────────────────────── */
#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.5);
    cursor: default;
}
#lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
#lightbox-close:hover { background: rgba(255,255,255,0.2); }
#lightbox-caption {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    font-family: var(--font-body);
    background: rgba(0,0,0,0.4);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
#lightbox-caption:hover { background: rgba(0,0,0,0.6); }

/* ─── SEARCH RESULTS ─────────────────────────────── */
.search-bar-wrap {
    position: relative;
    margin-bottom: 2rem;
}
.search-bar-wrap input {
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 1.2rem 0.8rem 3rem;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,120,58,0.1);
}
.search-bar-wrap .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

/* ─── BREADCRUMB ─────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }

/* ─── EMPTY STATE ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ─── COLOR SWATCH ───────────────────────────────── */
.color-swatches {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover, .color-swatch.selected { transform: scale(1.2); border-color: var(--text); }

/* ─── MISC ───────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.ml-auto { margin-left: auto; }

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-nav { position: static; }
    .prompt-grid, .cat-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .nav-search { max-width: none; }
}
