:root {
    /* b&w */
    --stone-050: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --stone-950: #0c0a09;

    /* colors */
    --blue: #3b82f6;
    --green: #22c55e;
    --indigo: #6366f1;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Global Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: 0 !important;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

body {
    background-color: var(--stone-950);
    color: var(--stone-200);
    font-family: var(--font-sans);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    user-select: none;
    line-height: 1.6;
}

/* --- Main Container --- */
.container {
    width: 100%;
    min-height: 100%;
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.content-wrapper {
    max-width: 480px;
    width: 90%;
}

h1 {
    font-size: 3rem;
    font-weight: bold;
    color: var(--stone-100);
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.1rem;
    color: var(--stone-400);
    margin-bottom: 2rem;
    font-weight: normal;
}

/* --- Sections --- */
.section {
    margin-bottom: 1.5rem;
    text-align: left;
}

.section-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--stone-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.section-label.small {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    margin-top: 0.75rem;
}

/* --- Variant Buttons --- */
.variant-group {
    display: flex;
    gap: 0;
}

.variant-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--stone-500);
    background-color: var(--stone-800);
    color: var(--stone-300);
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
}

.variant-btn + .variant-btn {
    border-left: none;
}

.variant-btn:hover {
    background-color: var(--stone-500);
}

.variant-btn.active {
    background-color: var(--blue);
    border-color: var(--blue);
    color: var(--stone-050);
}

/* --- Color Picker Row --- */
.color-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 48px;
    height: 40px;
    border: 1px solid var(--stone-500);
    background-color: var(--stone-800);
    cursor: pointer;
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
}

#color-hex {
    flex: 1;
    padding: 8px 12px;
    background-color: var(--stone-950);
    border: 1px solid var(--stone-500);
    color: var(--stone-100);
    font-family: monospace;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

#color-hex:focus {
    outline: none;
    border-color: var(--blue);
}

/* --- Noise Slider --- */
.noise-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.noise-row .section-label {
    flex-basis: 100%;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    background: var(--stone-800);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--blue);
    cursor: pointer;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--blue);
    cursor: pointer;
    border: none;
}

#noise-value {
    font-size: 0.85rem;
    color: var(--stone-400);
    min-width: 32px;
    text-align: right;
    font-family: monospace;
}

/* --- Preview --- */
.preview-area {
    display: flex;
    justify-content: center;
    background-color: var(--stone-900);
    border: 1px solid var(--stone-800);
    padding: 20px;
}

#preview-canvas {
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- Download Controls --- */
.size-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.size-group .action-btn {
    flex: 1;
    margin: 0;
}

.action-btn {
    display: inline-block;
    margin: 0;
    padding: 12px 24px;
    border: none;
    background-color: var(--blue);
    color: var(--stone-050);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.action-btn:hover {
    background-color: #5193f8;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background-color: var(--stone-800);
    color: var(--stone-200);
}

.action-btn.secondary:hover {
    background-color: var(--stone-500);
}

.custom-size-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.custom-size-row .input-group {
    flex: 1;
}

.custom-size-row .action-btn {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.8rem;
    color: var(--stone-400);
    margin-bottom: 4px;
}

.input-group input {
    width: 100%;
    padding: 8px;
    background-color: var(--stone-950);
    border: 1px solid var(--stone-500);
    color: var(--stone-100);
    font-family: inherit;
}

.input-group input:focus {
    outline: none;
    border-color: var(--blue);
}

/* --- Footer --- */

/* --- Brand Lookup --- */
.brand-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.brand-row #brand-input {
    flex: 1;
    padding: 8px 12px;
    background-color: var(--stone-950);
    border: 1px solid var(--stone-500);
    color: var(--stone-100);
    font-family: inherit;
    font-size: 0.95rem;
}

.brand-row #brand-input:focus {
    outline: none;
    border-color: var(--blue);
}

.brand-row .action-btn {
    padding: 0 20px;
    white-space: nowrap;
}

#brand-status {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    min-height: 1.2em;
}

#brand-status.error {
    color: #ef4444;
}

#brand-status.success {
    color: var(--green);
}

#brand-status.loading {
    color: var(--stone-400);
    font-style: italic;
}

/* --- Brand Color Swatches --- */
#brand-colors {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

#brand-colors:empty {
    display: none;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
    outline: none;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--stone-100);
    box-shadow: 0 0 0 2px var(--stone-950);
}

/* --- API Settings --- */
#api-settings {
    margin-top: 0.25rem;
}

#api-settings summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

#api-settings summary::before {
    content: '▸';
    font-size: 0.75rem;
    color: var(--stone-500);
    transition: transform 0.2s;
}

#api-settings[open] summary::before {
    transform: rotate(90deg);
}

#api-settings summary::-webkit-details-marker {
    display: none;
}

.section-label.clickable {
    margin-bottom: 0;
}

.api-key-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 0.75rem;
}

.api-key-row .input-group {
    flex: 1;
}

.api-key-row .action-btn {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.api-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--stone-500);
}

.api-hint a {
    color: var(--stone-400);
    text-decoration: underline;
    transition: color 0.2s;
}

.api-hint a:hover {
    color: var(--stone-200);
}

/* --- Footer --- */
#app-footer {
    margin-top: 2rem;
    color: var(--stone-500);
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
}

#app-footer a {
    color: var(--stone-500);
    text-decoration: none;
    transition: color 0.2s;
}

#app-footer a:hover {
    color: var(--stone-300);
    text-decoration: underline;
}
