:root {
    --primary: #009cde;
    --primary-dark: #0080b8;
    --text: #1a1a1a;
    --text-muted: #666;
    --border: #e5e5e5;
    --bg: #fff;
    --bg-muted: #f8f8f8;
    --radius: 4px;
    --max-width: 720px;
    --admin-max-width: 1200px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Public header */
.site-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
}

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

.site-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.site-nav {
    display: flex;
    gap: 1.5rem;
}

.site-nav a {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.site-nav a:hover {
    color: var(--text);
    text-decoration: none;
}

/* Main content */
main.container {
    padding-top: 3rem;
    padding-bottom: 4rem;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-top: 4rem;
}

.site-footer p {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* Empty state */
.posts-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.posts-empty {
    color: var(--text-muted);
}

/* Login page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-muted);
}

.login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s;
}

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

/* Buttons */
.btn-primary {
    display: inline-block;
    width: 100%;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.15s;
}

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

/* Admin layout */
.admin-body {
    background: var(--bg-muted);
    min-height: 100vh;
}

.admin-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 0;
}

.admin-header .container {
    max-width: var(--admin-max-width);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.admin-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.admin-nav {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}

.admin-nav a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-nav a:hover {
    color: var(--text);
    text-decoration: none;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.btn-logout:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.admin-main {
    max-width: var(--admin-max-width);
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Admin dashboard */
.admin-dashboard h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

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

.dashboard-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s;
}

.dashboard-card:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.dashboard-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.dashboard-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.flash-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.flash-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

/* Admin tables */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.admin-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.admin-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

.admin-table th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table .empty {
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.inline-form input[type="text"],
.inline-form select,
.inline-edit-form input[type="text"],
.inline-edit-form select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
}

.inline-edit-form {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.3125rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    cursor: pointer;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
}

.btn-sm:hover {
    border-color: var(--text-muted);
}

.btn-sm.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    width: auto;
}

.btn-sm.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm.btn-danger {
    color: #dc2626;
    border-color: #fecaca;
}

.btn-sm.btn-danger:hover {
    border-color: #dc2626;
}

/* Post editor */
.post-form-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

.post-editor {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.title-input {
    width: 100%;
    font-size: 1.5rem;
    font-weight: 600;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    color: var(--text);
    outline: none;
}

.slug-input {
    width: 100%;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border: none;
    padding: 0.25rem 0;
    margin-bottom: 0.75rem;
    outline: none;
    font-family: monospace;
}

.editor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.editor-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -1px;
}

.editor-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.markdown-editor {
    width: 100%;
    min-height: 400px;
    border: none;
    resize: vertical;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
    outline: none;
    padding: 0;
}

.markdown-preview {
    min-height: 400px;
    line-height: 1.8;
    font-size: 0.9375rem;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.markdown-preview p { margin-bottom: 1rem; }
.markdown-preview code {
    background: var(--bg-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
}
.markdown-preview pre code {
    background: none;
    padding: 0;
}
.markdown-preview pre {
    background: var(--bg-muted);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1rem;
}

.hidden { display: none !important; }

/* Sidebar */
.post-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.sidebar-card h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.sidebar-card select,
.sidebar-card textarea,
.sidebar-card input[type="datetime-local"] {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg);
}

.sidebar-card small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.sidebar-actions {
    margin-top: 0.5rem;
}

/* Tag checkboxes */
.tag-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.tag-cat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-draft {
    background: #fef3c7;
    color: #92400e;
}

.status-published {
    background: #d1fae5;
    color: #065f46;
}

/* Tag chips (public) */
.tag-chip {
    display: inline-block;
    padding: 0.125rem 0.625rem;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
}

a.tag-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.row-actions {
    white-space: nowrap;
}

/* Blog public pages */
.posts-header {
    margin-bottom: 2rem;
}

.posts-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-chip-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.post-card {
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border);
}

.post-card:last-child {
    border-bottom: none;
}

.post-title {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    line-height: 1.3;
}

.post-title a {
    color: var(--text);
    text-decoration: none;
}

.post-title a:hover {
    color: var(--primary);
}

.post-date {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}

.post-excerpt {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Single post */
.post-single-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.post-single-header h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.75rem;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.post-meta time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Markdown body */
.markdown-body {
    line-height: 1.8;
    font-size: 1.0625rem;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.markdown-body h1 { font-size: 1.75rem; }
.markdown-body h2 { font-size: 1.375rem; border-bottom: 1px solid var(--border); padding-bottom: 0.375rem; }
.markdown-body h3 { font-size: 1.125rem; }

.markdown-body p { margin-bottom: 1.25rem; }

.markdown-body a { color: var(--primary); }

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.markdown-body li { margin-bottom: 0.25rem; }

.markdown-body blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-body code {
    background: var(--bg-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.markdown-body pre {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
    border-radius: 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
}

.markdown-body th, .markdown-body td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-muted);
    font-weight: 600;
}

/* Callout boxes */
.callout {
    border-left: 4px solid var(--border);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--bg-muted);
}

.callout-note { border-left-color: var(--primary); }
.callout-warning { border-left-color: #f59e0b; background: #fffbeb; }
.callout-tip { border-left-color: #10b981; background: #f0fdf4; }
.callout-info { border-left-color: #6366f1; background: #eef2ff; }

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

/* Video embed */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin-bottom: 1.25rem;
    border-radius: var(--radius);
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.post-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.back-link {
    font-size: 0.9375rem;
    color: var(--text-muted);
}

.back-link:hover {
    color: var(--primary);
    text-decoration: none;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.pagination-link {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.pagination-link:hover {
    color: var(--primary);
    text-decoration: none;
}

/* Related items section */
.related-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
}

.related-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

/* Search form */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Tools public grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.tool-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    transition: box-shadow 0.15s;
}

.tool-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.tool-screenshot {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-muted);
}

.tool-screenshot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tool-body {
    padding: 1rem;
}

.tool-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.tool-title a {
    color: var(--text);
}

.tool-title a:hover {
    color: var(--primary);
    text-decoration: none;
}

.tool-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Tool admin */
.screenshot-preview {
    display: block;
    max-width: 100%;
    max-height: 200px;
    margin-top: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.upload-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.pos-cell {
    width: 2.5rem;
    color: var(--text-muted);
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* =========================================================
   Newsletter
   ========================================================= */

.footer-newsletter {
    margin-bottom: 1.5rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
}

.footer-newsletter h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 600;
}

.footer-newsletter p {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-copy {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.newsletter-form {
    display: flex;
    gap: 0.5rem;
    max-width: 400px;
}

.newsletter-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
}

.newsletter-btn {
    white-space: nowrap;
}

.newsletter-message {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
}

.newsletter-success {
    background: #d4edda;
    color: #155724;
}

.newsletter-error {
    background: #f8d7da;
    color: #721c24;
}

.newsletter-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* Newsletter public pages */
.newsletter-page {
    max-width: 520px;
    margin: 4rem auto;
    text-align: center;
}

.newsletter-page h1 {
    margin-bottom: 1rem;
}

.newsletter-page p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Admin newsletter */
.subscriber-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary, #009cde);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-active { background: #d4edda; color: #155724; }
.status-pending { background: #fff3cd; color: #856404; }
.status-unsubscribed { background: #f8f9fa; color: #6c757d; }

.nl-result { padding: 0.5rem 0.75rem; border-radius: 4px; font-size: 0.875rem; margin-top: 0.5rem; }
.nl-result--success { background: #d4edda; color: #155724; }
.nl-result--error { background: #f8d7da; color: #721c24; }
.nl-result--warning { background: #fff3cd; color: #856404; }
