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

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f8f9fa;
    color: #212529;
}

/* Header */
header {
    background: #1a1a2e;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.logo {
    color: #fff;
    font-size: 1.4rem;
    font-weight: bold;
    text-decoration: none;
}
.search-form { display: flex; gap: 0.5rem; }
.search-form input {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    width: 250px;
}
.search-form button {
    padding: 0.5rem 1rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Layout */
.layout {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    gap: 2rem;
}

/* Sidebar */
.sidebar {
    width: 200px;
    flex-shrink: 0;
}
.sidebar h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 0.75rem;
}
.sidebar ul { list-style: none; }
.sidebar ul li { margin-bottom: 0.4rem; }
.sidebar ul li a {
    color: #444;
    text-decoration: none;
    font-size: 0.95rem;
}
.sidebar ul li a:hover { color: #e94560; }

/* Main */
main { flex: 1; }
main h1 { margin-bottom: 1.5rem; font-size: 1.8rem; }

/* Cards */
.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.card {
    background: white;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.15s;
}
.card:hover { transform: translateY(-3px); }
.card h2 { font-size: 1.05rem; margin: 0.5rem 0; }
.card h2 a { color: #1a1a2e; text-decoration: none; }
.card h2 a:hover { color: #e94560; }
.tag {
    background: #eef2ff;
    color: #4361ee;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}
.meta { font-size: 0.8rem; color: #999; margin-top: 0.5rem; }

/* Tutorial page */
.tutorial-layout { display: flex; gap: 2rem; align-items: flex-start; }
.tutorial-content { flex: 1; background: white; padding: 2rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.tutorial-content h1 { margin: 0.75rem 0 0.25rem; font-size: 2rem; }
.content { margin-top: 1.5rem; line-height: 1.8; }
.content h2, .content h3 { margin: 1.5rem 0 0.5rem; }
.content p { margin-bottom: 0.75rem; }

/* TOC */
.toc {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.toc h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-bottom: 0.75rem; }
.toc ul { list-style: none; }
.toc ul li { margin-bottom: 0.4rem; }
.toc ul li a { font-size: 0.88rem; color: #444; text-decoration: none; }
.toc ul li a:hover { color: #e94560; }
.toc-level-2 { padding-left: 0.75rem; }
.toc-level-3 { padding-left: 1.5rem; }

/* Footer */
footer { text-align: center; padding: 2rem; color: #aaa; font-size: 0.85rem; margin-top: 2rem; }

/* Admin */
.admin-login {
    max-width: 360px;
    margin: 8rem auto;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    text-align: center;
}
.admin-login h1 { margin-bottom: 1.5rem; }
.admin-login input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
}
.error { color: #e94560; margin-bottom: 1rem; }

.admin-layout {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.admin-layout h2 { margin-bottom: 1rem; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.admin-table th, .admin-table td {
    text-align: left;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}
.admin-table th { background: #f8f9fa; font-size: 0.8rem; text-transform: uppercase; color: #888; }
.admin-table td a { color: #1a1a2e; text-decoration: none; }
.admin-table td a:hover { color: #e94560; }
.actions { display: flex; gap: 0.5rem; }

.btn {
    background: #e94560;
    color: white;
    padding: 0.5rem 1.1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
}
.btn-sm {
    background: #eef2ff;
    color: #4361ee;
    padding: 0.3rem 0.75rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    text-decoration: none;
}
.btn-sm.danger { background: #fff0f0; color: #e94560; }

.admin-categories ul { list-style: none; margin-bottom: 1rem; }
.admin-categories li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.inline-form { display: flex; gap: 0.5rem; }
.inline-form input {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.admin-form-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}
.admin-form-page h1 { margin-bottom: 1.5rem; }
.tutorial-form { display: flex; flex-direction: column; gap: 1.25rem; }
.tutorial-form label { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; font-size: 0.9rem; color: #555; }
.tutorial-form input, .tutorial-form select, .tutorial-form textarea {
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
}
.tutorial-form textarea { font-family: monospace; resize: vertical; }

/* Image in tutorials */
.tutorial-img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

/* Editor toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.5rem 0.75rem;
}
.toolbar-hint { font-size: 0.8rem; color: #888; font-weight: normal; }
.toolbar-hint code { background: #eee; padding: 0.1rem 0.3rem; border-radius: 3px; }
.upload-btn { cursor: pointer; }
#upload-status { font-size: 0.85rem; margin: 0.25rem 0; min-height: 1.2rem; }
#editor { border-radius: 0 0 6px 6px !important; }

/* Image preview thumbnails */
#image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.preview-thumb {
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    width: 120px;
    text-align: center;
    transition: border-color 0.15s;
}
.preview-thumb:hover { border-color: #e94560; }
.preview-thumb img { width: 100%; height: 80px; object-fit: cover; display: block; }
.preview-thumb span { font-size: 0.65rem; color: #888; padding: 0.2rem; display: block; word-break: break-all; }