:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --border: #e5e7eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Pretendard", "Noto Sans KR", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.nav {
    display: flex;
    gap: 12px;
}

.nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.badge {
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #dbeafe;
    padding: 2px 8px;
    border-radius: 999px;
}

.logout {
    color: #dc2626;
    text-decoration: none;
}

.container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 20px 60px;
}

.card,
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.card {
    max-width: 420px;
    margin: 40px auto 0;
}

.grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

label {
    display: block;
    margin-top: 12px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

button,
.button {
    display: inline-block;
    margin-top: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.list-title {
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.flash {
    margin-bottom: 16px;
}

.flash-item {
    background: #fef3c7;
    color: #92400e;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

@media (max-width: 640px) {
    .site-header {
        padding: 12px 16px;
    }

    .nav {
        flex-wrap: wrap;
    }
}

.inline-form {
    margin-top: 12px;
}

.button.secondary {
    background: #0f172a;
}

.post-layout {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(280px, 1fr) 2fr;
}

.title-panel {
    max-height: 720px;
    overflow: hidden;
}

.title-list {
    max-height: 520px;
    overflow-y: auto;
    padding-right: 6px;
}

.title-item {
    cursor: pointer;
    padding: 12px 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.title-item:hover {
    background: #f8fafc;
}

.title-item.used {
    background: #f1f5f9;
    color: #64748b;
}

.keyword-used {
    background: #fef9c3;
}

@media (max-width: 900px) {
    .post-layout {
        grid-template-columns: 1fr;
    }
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.legend {
    display: flex;
    gap: 12px;
    margin: 8px 0 16px;
    font-size: 13px;
    color: var(--muted);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.dot.exact {
    background: #ef4444;
}

.dot.similar {
    background: #f59e0b;
}

.title-item.exact {
    border: 1px solid #fecaca;
    background: #fee2e2;
}

.title-item.similar {
    border: 1px solid #fde68a;
    background: #fef3c7;
}

#tagSelect {
    min-height: 120px;
}

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.button.small {
    padding: 6px 10px;
    font-size: 12px;
}

#tagSearch {
    margin-top: 8px;
}

.site-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.edit-form {
    display: none;
    margin-top: 12px;
}

.edit-form.open {
    display: block;
}

.suggested-tags {
    margin-top: 10px;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.tag-chip {
    background: #e0f2fe;
    color: #075985;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: #fff;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    border-radius: 12px;
    padding: 20px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-section {
    margin-top: 16px;
}

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

.image-grid img {
    width: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.preview-content {
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.image-grid.selectable {
    margin-top: 12px;
}

.image-option {
    display: block;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
}

.image-option input {
    display: none;
}

.image-option img {
    display: block;
}

.image-option input:checked + img {
    outline: 3px solid #2563eb;
    outline-offset: -3px;
}

.image-grid img {
    max-height: 180px;
}

.modal-content.small {
    max-width: 380px;
    text-align: center;
}

.loader {
    width: 32px;
    height: 32px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
