@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700;800&display=swap');

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

:root {
    --bg: #080808;
    --surface: #0f0f0f;
    --surface2: #181818;
    --border: #222;
    --border2: #303030;
    --accent: #dc2626;
    --accent-h: #ef4444;
    --text: #eeeeee;
    --muted: #555;
    --muted2: #888;
    --font: 'JetBrains Mono', monospace;
}

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    min-height: 100vh;
}

header {
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo { font-size: 17px; font-weight: 800; letter-spacing: -1px; color: var(--text); text-decoration: none; }
.logo-slash { color: var(--accent); }

nav { display: flex; gap: 4px; }

nav a {
    color: var(--muted2);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 6px 12px;
    border-radius: 3px;
    border: 1px solid transparent;
    transition: all 0.1s;
}

nav a:hover { color: var(--text); background: var(--surface2); }
nav a.active { color: var(--accent); border-color: var(--border2); background: var(--surface2); }

.sim-layout {
    display: grid;
    grid-template-columns: 196px 1fr 220px;
    height: calc(100vh - 54px);
    overflow: hidden;
}

.tools-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.8px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tool-btns { display: flex; flex-direction: column; gap: 4px; }

.tool-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted2);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 3px;
    text-align: left;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn:hover { background: var(--border2); color: var(--text); }
.tool-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.color-palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 3px;
    border: 2px solid var(--border2);
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
}

.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.color-swatch.custom { background: conic-gradient(red, yellow, green, cyan, blue, magenta, red); overflow: hidden; }

.color-swatch.custom input[type="color"] {
    opacity: 0;
    position: absolute;
    inset: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
}

.range-wrap { display: flex; flex-direction: column; gap: 5px; }

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 3px;
    background: var(--border2);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px; height: 13px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.stamp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }

.stamp-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted2);
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 3px;
    text-align: center;
    transition: all 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.stamp-btn:hover { background: var(--border2); color: var(--text); }
.stamp-btn.active { border-color: var(--accent); color: var(--accent); }
.stamp-preview { display: block; }

.canvas-area {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #060606;
    overflow: hidden;
    position: relative;
    padding: 8px;
}

.canvas-bg {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #1a1a1a 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.4;
}

.canvas-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    position: relative;
    z-index: 1;
}

.persp-tabs {
    display: flex;
    gap: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 3px;
    flex-shrink: 0;
}

.persp-tab {
    background: none;
    border: 1px solid transparent;
    color: var(--muted2);
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 5px 10px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
}

.persp-tab:hover { color: var(--text); background: var(--surface2); }
.persp-tab.active { color: var(--accent); background: var(--surface2); border-color: var(--border2); }

.canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: 460 / 720;
    max-width: 460px;
    position: relative;
    border: 1px solid var(--border2);
    border-radius: 3px;
    box-shadow: 0 0 50px rgba(0,0,0,0.7);
}

#body-canvas, #draw-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#draw-canvas {
    position: absolute;
    top: 0; left: 0;
    cursor: crosshair;
}

.submit-panel {
    background: var(--surface);
    border-left: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.submit-title { font-size: 15px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; }
.submit-title span { color: var(--accent); }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--muted);
    text-transform: uppercase;
}

input[type="text"] {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 3px;
    outline: none;
    transition: border-color 0.1s;
}

input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--muted); }

.btn {
    display: block;
    width: 100%;
    padding: 10px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s;
    text-align: center;
    border: none;
    text-decoration: none;
}

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-h); }
.btn-accent:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--muted2);
}

.btn-outline:hover { background: var(--surface2); color: var(--text); border-color: var(--muted); }

.divider { height: 1px; background: var(--border); }

.info-text { font-size: 10px; color: var(--muted); line-height: 1.7; text-align: center; }

.toast {
    position: fixed;
    bottom: 20px; right: 20px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    padding: 11px 16px;
    border-radius: 4px;
    z-index: 999;
    transform: translateY(16px);
    opacity: 0;
    transition: all 0.2s;
    pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: #22c55e; }
.toast.error { border-color: var(--accent); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.gallery-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.gallery-title span { color: var(--accent); }
.gallery-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

.sort-btns { display: flex; gap: 5px; }

.sort-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted2);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s;
}

.sort-btn:hover { color: var(--text); background: var(--border2); }
.sort-btn.active { color: var(--accent); border-color: var(--accent); }

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

.tattoo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s;
}

.tattoo-card:hover { border-color: var(--border2); transform: translateY(-2px); }

.tattoo-img-wrap {
    width: 100%;
    aspect-ratio: 460 / 720;
    overflow: hidden;
    background: var(--surface2);
}

.tattoo-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tattoo-info { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }

.tattoo-author { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.tattoo-author::before { content: '//'; color: var(--accent); font-size: 11px; }

.tattoo-time { font-size: 10px; color: var(--muted); }

.rating-display { display: flex; align-items: center; gap: 5px; font-size: 11px; }
.stars-display { color: var(--accent); letter-spacing: -1px; font-size: 13px; }
.rating-avg { font-weight: 700; }
.rating-count { color: var(--muted); font-size: 10px; }

.rate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding-top: 9px;
}

.rate-label { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }

.star-input { display: flex; gap: 1px; }

.star-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--border2);
    transition: color 0.1s, transform 0.1s;
    padding: 1px;
    line-height: 1;
    font-family: inherit;
}

.star-btn:hover, .star-btn.lit { color: var(--accent); }
.star-btn:hover { transform: scale(1.2); }
.star-btn.done { cursor: default; }

.empty-state { grid-column: 1/-1; text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state p { font-size: 13px; margin-bottom: 14px; }
.empty-state a { color: var(--accent); text-decoration: none; font-size: 11px; letter-spacing: 0.5px; }

@media (max-width: 860px) {
    .sim-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        overflow: auto;
    }
    .tools-panel {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border);
        gap: 12px;
        padding: 12px;
    }
    .submit-panel { border-left: none; border-top: 1px solid var(--border); }
    .canvas-area { padding: 16px; min-height: 500px; }
    .canvas-wrap { max-width: 320px; }
}
