:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-hover: #f2f2f2;
    --surface-translucent: rgba(255, 255, 255, 0.72);
    --text: #0a0a0a;
    --muted: #737373;
    --border: #e5e5e5;
    --accent: #144391;
    --accent-contrast: #ffffff;
    --danger-bg: #fdf2f2;
    --danger-text: #9f2f2f;
    --danger-border: #f3d6d6;
    --info-bg: #f2f2f2;
    --info-text: #404040;
    --info-border: #e5e5e5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.05);
    --radius: 14px;
    --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a0a0a;
        --surface: #141414;
        --surface-hover: #1c1c1c;
        --surface-translucent: rgba(10, 10, 10, 0.72);
        --text: #f5f5f5;
        --muted: #8a8a8a;
        --border: #262626;
        --accent: #3567c4;
        --accent-contrast: #ffffff;
        --danger-bg: #241414;
        --danger-text: #e08585;
        --danger-border: #3a2020;
        --info-bg: #161616;
        --info-text: #c7c7c7;
        --info-border: #262626;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    }
}

:root[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1c1c1c;
    --surface-translucent: rgba(10, 10, 10, 0.72);
    --text: #f5f5f5;
    --muted: #8a8a8a;
    --border: #262626;
    --accent: #3567c4;
    --accent-contrast: #ffffff;
    --danger-bg: #241414;
    --danger-text: #e08585;
    --danger-border: #3a2020;
    --info-bg: #161616;
    --info-text: #c7c7c7;
    --info-border: #262626;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html {
    color-scheme: light dark;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
    border-radius: 4px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-translucent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}


.content {
    max-width: 960px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

h1 {
    margin-top: 0;
    letter-spacing: -0.02em;
    font-weight: 650;
}

h2 {
    letter-spacing: -0.01em;
    font-weight: 600;
    font-size: 1.15rem;
}

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

.card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--muted);
}

.card-icon { font-size: 1.75rem; }
.card-name { font-weight: 600; }
.card-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

.empty { color: var(--muted); }

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s ease;
}

.back-link:hover { color: var(--text); }

.upload-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.upload-form input[type="file"] {
    padding: 0.5rem 0;
    color: var(--muted);
}

button, .btn {
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 550;
    cursor: pointer;
    width: fit-content;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover, .btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

button:active, .btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.field label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.field .copy-row {
    display: flex;
    gap: 0.5rem;
}

.field input, .field textarea, .field select {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    flex: 1;
    transition: border-color 0.15s ease;
}

.field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--muted);
}

.field textarea { min-height: 120px; resize: vertical; }

.result-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.hint {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    color: var(--info-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.error-box {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
}

.spinner-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.htmx-request .btn-label { display: none; }
.htmx-request .btn-spinner { display: inline; }
.btn-spinner { display: none; }

.thumbs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
}

.thumbs img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.sort-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.drafts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.draft-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease;
    overflow: hidden;
}

.draft-row:hover {
    box-shadow: var(--shadow-md);
}

.draft-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 0.85rem 1.1rem;
    background: none;
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    text-align: left;
    color: inherit;
}

.draft-summary:hover {
    background: var(--surface-hover);
}

.draft-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.draft-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.draft-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

.draft-chevron {
    color: var(--muted);
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.draft-row.expanded .draft-chevron {
    transform: rotate(90deg);
}

.draft-fields {
    display: none;
    padding: 0 1.1rem 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.draft-row.expanded .draft-fields {
    display: block;
}

.draft-fields .field input[readonly],
.draft-fields .field textarea[readonly] {
    background: var(--info-bg);
    color: var(--text);
}

.draft-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.85rem 1.1rem;
    border-top: 1px solid var(--border);
}

.draft-row.expanded .draft-actions {
    border-top: none;
}

.draft-actions button {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.idea-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.idea-card-compact {
    margin-bottom: 0;
}

.idea-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.idea-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.idea-date {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.idea-title {
    margin: 0.2rem 0 0;
}

.idea-pitch {
    color: var(--text);
    line-height: 1.5;
}

.idea-features {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
    line-height: 1.6;
}

.star-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    border-radius: 999px;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}

.star-btn:hover {
    background: var(--surface-hover);
    box-shadow: none;
    transform: none;
}

.star-btn.starred {
    color: #d9a441;
    border-color: #d9a441;
}
