:root {
    --bg: #f7f4ef;
    --card: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --line: #e5e7eb;
    --ok: #15803d;
    --err: #b91c1c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
.container.narrow { max-width: 640px; }

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.site-header .inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.brand { font-size: 1.35rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }

.hero {
    background: linear-gradient(135deg, #eff6ff, #fef3c7);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px;
    margin-bottom: 28px;
}

.hero h1 { margin: 0 0 8px; font-size: 2rem; }
.hero p { margin: 0; color: var(--muted); }

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

.grid-posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.card h2, .card h3 { margin-top: 0; }

.post-card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.post-card:hover {
    text-decoration: none;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.post-card img {
    width: 100%;
    aspect-ratio: 210 / 297;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--line);
}

.post-card h3 { font-size: 1.1rem; margin: 14px 0 4px; }
.post-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.breadcrumb { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; }

.coloring-print-wrap {
    width: 100%;
    max-width: 100%;
    margin: 8px auto 24px;
    display: flex;
    justify-content: center;
}

.coloring-a4-sheet {
    width: min(100%, 920px, calc((100dvh - 240px) * 210 / 297));
    aspect-ratio: 210 / 297;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    padding: clamp(12px, 2vw, 24px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.coloring-a4-sheet img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.coloring-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.coloring-hint {
    text-align: center;
    margin-top: 12px;
}

.btn.secondary {
    background: #fff;
    color: var(--accent) !important;
    border: 1px solid var(--line);
}

.btn.secondary:hover {
    background: #f9fafb;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    body {
        background: #fff;
    }

    .site-header,
    .site-footer,
    .no-print {
        display: none !important;
    }

    .container {
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .coloring-print-wrap {
        max-width: none;
        margin: 0;
    }

    .coloring-a4-sheet {
        width: 100%;
        height: 277mm;
        aspect-ratio: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        page-break-inside: avoid;
    }

    .coloring-a4-sheet img {
        max-width: 100%;
        max-height: 277mm;
    }
}

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

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff !important;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
}

.btn:hover { background: var(--accent-dark); }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}
.alert.error { background: #fee2e2; color: var(--err); }
.alert.ok { background: #dcfce7; color: var(--ok); }

.form-card label { display: block; font-weight: 600; margin: 12px 0 6px; }
.form-card input, .form-card textarea, .form-card select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
}

.site-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

.placeholder-thumb {
    width: 100%;
    aspect-ratio: 210 / 297;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 10px, #e5e7eb 10px, #e5e7eb 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.site-nav .nav-user {
    color: var(--muted);
    font-size: 0.92rem;
}

.site-nav .nav-register {
    font-weight: 600;
}

.page-rating-wrap {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.star-rating-stars {
    display: inline-flex;
    gap: 2px;
}

.star-btn {
    background: none;
    border: 0;
    padding: 0 1px;
    font-size: 1.35rem;
    line-height: 1;
    color: #d1d5db;
    cursor: default;
}

.star-rating-interactive .star-btn {
    cursor: pointer;
    transition: color 0.12s ease, transform 0.12s ease;
}

.star-rating-interactive .star-btn:hover {
    transform: scale(1.1);
}

.star-btn.is-active,
.star-btn.is-user {
    color: #f59e0b;
}

.star-rating-meta {
    font-size: 0.9rem;
    color: var(--muted);
}

.star-rating-meta strong {
    color: var(--ink);
}

.star-rating-empty {
    color: var(--muted);
    font-size: 0.85rem;
}

.post-card-rating {
    margin-top: 8px;
}

.post-card-rating .star-rating-meta {
    font-size: 0.82rem;
}

.post-card-rating .star-btn {
    font-size: 1rem;
    pointer-events: none;
}

.gallery-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.artwork-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.heart-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.heart-btn:hover {
    border-color: #fca5a5;
    color: #ef4444;
}

.heart-btn.is-hearted,
.heart-btn.is-hearted:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #dc2626;
}

.heart-icon {
    font-size: 1rem;
    line-height: 1;
}

.comments-section {
    margin-top: 40px;
}

.comments-section h2 {
    margin: 0 0 16px;
    font-size: 1.35rem;
}

.comments-count {
    font-weight: 500;
    color: var(--muted);
    font-size: 1rem;
}

.comment-form {
    margin-bottom: 20px;
}

.comment-form label {
    display: block;
    font-weight: 600;
    margin: 12px 0 6px;
}

.comment-form label:first-child {
    margin-top: 0;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}

.comment-form-actions {
    margin-top: 12px;
}

.comment-form-error {
    margin: 10px 0 0;
    color: var(--err);
    font-size: 0.9rem;
}

.comment-signin-prompt p {
    margin: 0;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comments-empty {
    margin: 0;
}

.comment-item {
    padding: 14px 16px;
}

.comment-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.comment-author {
    font-size: 0.95rem;
}

.comment-date {
    font-size: 0.82rem;
    color: var(--muted);
}

.comment-body {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
