:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --border: #e1e4e8;
    --text: #1f2328;
    --muted: #5b6470;
    --accent: #1f6feb;
    --accent-hover: #1758b8;
    --error: #b3261e;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }
body { background: var(--bg); }

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

h1 { font-size: 1.6rem; margin-top: 0; }

.layout { display: flex; flex-direction: column; min-height: 100vh; }
.layout__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.layout__main { padding: 1.5rem; max-width: 1100px; width: 100%; margin: 0 auto; }

.brand {
    font-weight: 600;
    color: var(--text);
}
.brand:hover { text-decoration: none; }

.user { color: var(--muted); margin-left: auto; margin-right: 0.75rem; }

.signout-form { margin: 0; }
.signout-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.85rem;
    color: var(--text);
    cursor: pointer;
}
.signout-btn:hover { background: var(--bg); }

/* Login card */
.login-card {
    max-width: 360px;
    margin: 4rem auto;
    background: var(--surface);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.875rem; color: var(--muted); }
.login-form input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
    color: var(--text);
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-form button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.55rem 0.9rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}
.login-form button:hover { background: var(--accent-hover); }

.error {
    background: #fef0ef;
    border: 1px solid #fcd2cf;
    color: var(--error);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

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

.layout__nav { display: flex; gap: 1rem; margin-right: auto; margin-left: 1.5rem; }
.layout__nav a { color: var(--text); padding: 0.35rem 0.6rem; border-radius: 4px; }
.layout__nav a:hover { background: var(--bg); text-decoration: none; }

/* Tile grid for New draft */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    color: var(--text);
}
.tile:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-decoration: none; }
.tile--disabled { opacity: 0.55; cursor: not-allowed; }
.tile__title { font-weight: 600; font-size: 1.05rem; }
.tile__desc { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border-radius: 4px;
    font-size: 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn--primary:disabled { background: #9ab8e8; cursor: not-allowed; }
.btn--secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg); text-decoration: none; }
.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0 0 0 0.5rem;
    font-size: 0.85rem;
}
.link-btn:hover { text-decoration: underline; }

/* Intake form */
.intake { display: flex; flex-direction: column; gap: 1.25rem; max-width: 720px; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field__label { font-weight: 500; }
.field__hint { font-size: 0.8rem; color: var(--muted); }
.intake textarea {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.6rem;
    font: inherit;
    color: var(--text);
    resize: vertical;
}
.intake__actions { display: flex; gap: 0.75rem; align-items: center; }

.pending-images { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.pending-images h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.pending-images__list { list-style: none; margin: 0; padding: 0; }
.pending-images__list li { padding: 0.2rem 0; font-size: 0.9rem; }

/* Drafts table */
.drafts { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.drafts th, .drafts td { padding: 0.55rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.drafts thead th { background: var(--bg); color: var(--muted); font-weight: 500; }
.drafts tbody tr:last-child td { border-bottom: none; }
.drafts__actions { width: 1%; white-space: nowrap; text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Status badges */
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
.badge--draft { background: #eef2f7; color: #3b485e; }
.badge--inreview { background: #fff4d6; color: #6a4a00; }
.badge--published { background: #dff5e0; color: #1a5f29; }

/* Draft editor preview */
.draft-header { margin-bottom: 1rem; }
.draft-header h1 { margin-bottom: 0.25rem; }
.draft-section { margin-top: 1.5rem; }
.draft-section h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.draft-section__item { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; margin-bottom: 0.6rem; }
.draft-section__item h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.shortcode {
    background: #f3f4f6;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
}
.shortcode--full { max-height: 480px; overflow-y: auto; }

/* Image review grid */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.8rem; }
.image-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.image-card__thumb { background: #f3f4f6; display: flex; align-items: center; justify-content: center; height: 140px; }
.image-card__thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-card__meta { padding: 0.55rem 0.7rem; font-size: 0.82rem; }
.image-card__filename { margin: 0 0 0.25rem; word-break: break-all; }
.image-card__token { margin: 0 0 0.2rem; }
.image-card__token code { background: #f3f4f6; padding: 0.05rem 0.35rem; border-radius: 3px; }

.error {
    background: #fef0ef;
    border: 1px solid #fcd2cf;
    color: var(--error);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Docx intake */
.warnings { background: #fff8e0; border: 1px solid #ffe082; border-radius: 6px; padding: 0.5rem 0.75rem; }
.warnings summary { cursor: pointer; font-weight: 500; }
.warnings ul { margin: 0.5rem 0 0; padding-left: 1.25rem; font-size: 0.85rem; color: var(--muted); }

.docx-sections { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.docx-sections h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.docx-sections ul { margin: 0; padding-left: 1.1rem; }
.docx-sections li { padding: 0.2rem 0; font-size: 0.9rem; }

.docx-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.docx-preview h2 { font-size: 1rem; margin: 0 0 0.5rem; }
.docx-preview__body {
    max-height: 480px;
    overflow-y: auto;
    padding: 0.75rem;
    background: #fbfbfc;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}
.docx-preview__body img { max-width: 100%; }
.docx-preview__body table { border-collapse: collapse; }
.docx-preview__body th, .docx-preview__body td { border: 1px solid var(--border); padding: 0.25rem 0.45rem; }

/* Zendesk intake */
.checkbox { display: inline-flex; gap: 0.4rem; align-items: center; cursor: pointer; }
.checkbox input { margin: 0; }

.zd-fetch { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.zd-fetch__id input {
    width: 9rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    font: inherit;
}

.zd-ticket { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.zd-ticket h2 { margin: 0 0 0.3rem; font-size: 1.05rem; }

.zd-comments { display: flex; flex-direction: column; gap: 0.6rem; }
.zd-comments h2 { font-size: 1.05rem; margin: 0; }
.zd-comment {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.7rem 0.85rem;
}
.zd-comment--muted { opacity: 0.55; }
.zd-comment__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
    font-size: 0.9rem;
}
.zd-comment__meta { color: var(--muted); font-size: 0.82rem; display: flex; gap: 0.6rem; align-items: center; }
.zd-comment__body {
    margin: 0;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.88rem;
    white-space: pre-wrap;
    max-height: 240px;
    overflow-y: auto;
}

.zd-attachments { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.zd-attachments h2 { font-size: 1rem; margin: 0 0 0.4rem; }
.zd-attachments__list { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.zd-attachments__list li { padding: 0.2rem 0; }
.zd-attachments__list code { background: #f3f4f6; padding: 0.05rem 0.35rem; border-radius: 3px; }

/* Dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.dashboard-header h1 { margin: 0; }
.dashboard-controls { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.dashboard-tabs { display: flex; gap: 0.25rem; }
.tab {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
}
.tab:hover { background: var(--surface); }
.tab--active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab--active:hover { background: var(--accent-hover); }
.tab__count { background: rgba(0,0,0,0.08); border-radius: 999px; padding: 0 0.45rem; font-size: 0.78rem; }
.tab--active .tab__count { background: rgba(255,255,255,0.2); }
.dashboard-search {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.65rem;
    font: inherit;
    min-width: 240px;
}

/* Editor — full split view */
.draft-header--editor { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1rem; }
.draft-header__title { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.draft-header__meta { display: flex; gap: 1rem; align-items: center; font-size: 0.85rem; }
.draft-header__actions { display: flex; gap: 0.5rem; }

.title-input {
    flex: 1;
    min-width: 280px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 1.5rem;
    font-weight: 500;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
}
.title-input:hover, .title-input:focus { background: var(--surface); border-color: var(--border); outline: none; }

.save-status { font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 999px; }
.save-status--idle { display: none; }
.save-status--pending { background: #fff8e0; color: #6a4a00; }
.save-status--saving { background: #eef5ff; color: #1f4a8a; }
.save-status--saved { background: #dff5e0; color: #1a5f29; }
.save-status--error { background: #fef0ef; color: var(--error); }

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: flex-start;
}
@media (max-width: 1000px) {
    .editor-grid { grid-template-columns: 1fr; }
}
.editor-grid__left { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.editor-grid__right { position: sticky; top: 1rem; }

.editor-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.85rem 1rem; }
.editor-card > summary { cursor: pointer; font-weight: 500; }
.editor-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.editor-card__header h2 { font-size: 1rem; margin: 0; }
.editor-card textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    font: inherit;
    resize: vertical;
}
.btn--sm { padding: 0.3rem 0.65rem; font-size: 0.85rem; }

/* Section editor */
.section-editor { background: #fbfbfc; border: 1px solid var(--border); border-radius: 6px; padding: 0.7rem 0.85rem; margin-bottom: 0.6rem; }
.section-editor__header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.section-editor__index {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    min-width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}
.section-editor__heading {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font: inherit;
    font-weight: 500;
}
.section-editor__actions { display: flex; gap: 0.25rem; }
.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 1.8rem;
    height: 1.8rem;
    cursor: pointer;
    color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn--danger:hover:not(:disabled) { color: var(--error); }
.section-editor__body {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.55rem;
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    resize: vertical;
}

/* Shortcode preview pane */
.shortcode-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.shortcode-preview__banner {
    background: #fff8e0;
    color: #6a4a00;
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-bottom: 1px solid var(--border);
}
.shortcode-preview__body {
    padding: 1rem;
    max-height: 70vh;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.5;
}
.preview-empty { color: var(--muted); }
.preview-section { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.preview-section:first-child { border-top: none; padding-top: 0; }
.preview-row { display: grid; grid-template-columns: 25% 1fr; gap: 1rem; align-items: start; }
@media (max-width: 600px) { .preview-row { grid-template-columns: 1fr; } }
.preview-col--head h3 { margin: 0; color: var(--accent); font-size: 1rem; }
.preview-col--body p { margin: 0 0 0.75rem; }
.preview-list { margin: 0 0 0.75rem 1.1rem; padding: 0; }
.preview-img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; margin: 0.35rem 0; }
.preview-token {
    background: #fef0ef;
    color: #b3261e;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
}

/* Publish confirm */
.publish-grid { display: flex; flex-direction: column; gap: 1rem; max-width: 720px; }
.category-list { list-style: none; margin: 0; padding: 0; }
.category-list li { padding: 0.2rem 0; }
.radio { display: flex; gap: 0.5rem; padding: 0.4rem 0; }
.radio input { margin-top: 0.3rem; }
.publish-result { border-radius: 6px; padding: 0.85rem 1rem; }
.publish-result--ok { background: #dff5e0; border: 1px solid #a4dbb1; color: #1a5f29; }
.publish-result--warn { background: #fff8e0; border: 1px solid #ffe082; color: #6a4a00; }
.publish-result h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.publish-result ul { margin: 0.4rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; }
.publish-result a { text-decoration: underline; }
