/* ==========================================================================
   Pipe — design system
   ========================================================================== */
:root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-alt: #f6f8fa;
    --border: #d0d7de;
    --border-soft: #eaeef2;
    --text: #1f2328;
    --text-muted: #656d76;
    --primary: #2da44e;
    --primary-hover: #2c974b;
    --primary-soft: #dafbe1;
    --danger: #cf222e;
    --danger-hover: #a40e26;
    --danger-soft: #ffebe9;
    --info: #0969da;
    --info-soft: #ddf4ff;
    --nav-bg: #1f2328;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(27, 31, 35, 0.06), 0 1px 2px rgba(27, 31, 35, 0.04);
    --shadow-lg: 0 8px 24px rgba(140, 149, 159, 0.25);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
nav {
    background: var(--nav-bg);
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
nav a { color: #e6edf3; margin-right: 8px; font-size: 14px; padding: 6px 10px; border-radius: var(--radius-sm); transition: background 0.15s, color 0.15s; }
nav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
nav .brand { font-weight: 700; font-size: 17px; line-height: 1; margin-right: 22px; display: flex; align-items: center; gap: 8px; letter-spacing: -0.2px; }
nav .brand:hover { background: transparent; }
nav .brand .brand-name { font-family: Arial, Helvetica, sans-serif; line-height: 1; }
nav .brand .logo { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: 700; line-height: 1; color: #fff; }

nav a.active { background: rgba(255, 255, 255, 0.14); color: #fff; }
nav .spacer { flex: 1; }
nav .nav-right { display: flex; align-items: center; }
nav .nav-right a { margin-right: 0; }
nav .nav-user { font-size: 13px; color: #9ba7b4; margin-right: 10px; }

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

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.25; }
.page-head p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-head-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head-row .page-head { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:active { background: #eceff2; }
.btn-primary { background: var(--primary); color: #fff; border-color: rgba(27, 31, 35, 0.15); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }

/* --------------------------------------------------------------------------
   Cards / gist list
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: 8px; }

.gist-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; transition: border-color 0.15s, box-shadow 0.15s; }
.gist-card:hover { border-color: var(--border); box-shadow: 0 3px 10px rgba(140, 149, 159, 0.18); }
.gist-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.gist-title a { color: var(--info); }
.gist-main { min-width: 0; flex: 1; }
.meta { font-size: 12.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.meta a { color: var(--text-muted); font-weight: 500; }
.gist-files { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); font-size: 12px; flex: 0 0 auto; }
.gist-files .num { font-size: 18px; font-weight: 600; color: var(--text); line-height: 1; }
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; font-size: 12px; line-height: 1; padding: 4px 10px; border-radius: 999px; background: var(--info-soft); color: #0a3069; border: 1px solid #b6d8ff; }

.handle { font-family: 'Ubuntu Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace; font-weight: 700; color: #ED3E5F; }
.meta a.handle { font-weight: 700; color: #ED3E5F; }
.badge { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 8px; border-radius: 999px; font-weight: 600; vertical-align: middle; }
.badge-private { background: var(--danger-soft); color: var(--danger); border: 1px solid #ffcecb; }
.badge-admin { background: var(--info); color: #fff; }
.badge-active { background: var(--primary-soft); color: #1a7f37; }
.badge-banned { background: var(--danger-soft); color: var(--danger); }

.card-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: none; }
.card-actions form { display: inline; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus,
.file-name:focus, .file-content:focus, .file-lang:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-grid { grid-template-columns: 1fr; gap: 0; } }
.checkbox-group { display: flex; align-items: flex-start; gap: 8px; }
.checkbox-group input { width: auto; margin-top: 3px; }
.checkbox-group label { font-weight: 600; font-size: 14px; margin: 0; }
.form-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }
.form-hint { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.notice { display: flex; align-items: center; gap: 8px; background: var(--info-soft); border: 1px solid #b6d8ff; color: #0a3069; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin: 4px 0 22px; }
.notice svg { flex: 0 0 auto; }

/* --------------------------------------------------------------------------
   File editor
   -------------------------------------------------------------------------- */
.files-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.files-head h4 { font-size: 16px; font-weight: 600; }
.files-count { font-size: 12px; color: var(--text-muted); }

.file-entry { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; background: var(--surface); }
.file-head { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--surface-alt); border-bottom: 1px solid var(--border-soft); }
.file-name { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
.file-lang { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; background: var(--surface); max-width: 170px; }
.file-content { display: block; width: 100%; padding: 14px; border: none; border-radius: 0; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px; line-height: 1.5; min-height: 150px; resize: vertical; background: var(--surface); color: var(--text); }
.file-content:focus { box-shadow: inset 0 0 0 2px rgba(9, 105, 218, 0.25); }
.file-remove { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 6px 9px; border-radius: var(--radius-sm); }
.file-remove:hover { background: var(--danger-soft); color: var(--danger); }
.add-pipe { border-style: dashed; width: 100%; color: var(--text-muted); }
.add-pipe:hover { background: var(--info-soft); border-color: var(--info); color: var(--info); }

/* --------------------------------------------------------------------------
   Flash messages
   -------------------------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.flash-success { background: var(--primary-soft); color: #1a7f37; border-color: #aceebb; }
.flash-danger { background: var(--danger-soft); color: var(--danger); border-color: #ffcecb; }
.flash-warning { background: #fff8c5; color: #7d4e00; border-color: #f5d76e; }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal { display: none; position: fixed; z-index: 100; inset: 0; background: rgba(31, 35, 40, 0.5); padding: 20px; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--surface); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.modal-content h3 { margin-bottom: 8px; }
.modal-actions { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--surface-alt); text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); padding: 12px; border-bottom: 1px solid var(--border); }
tbody td { padding: 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td .btn { margin-right: 4px; }
td form { display: inline; }
.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px; }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state .empty-icon { font-size: 34px; margin-bottom: 10px; opacity: 0.5; }
.empty-state p { margin-bottom: 16px; }

/* --------------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------------- */
.auth-wrap { max-width: 400px; margin: 36px auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.auth-card .btn-block { margin-top: 4px; }
.auth-footer { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 18px; }

/* --------------------------------------------------------------------------
   Token box
   -------------------------------------------------------------------------- */
.token-box { display: flex; align-items: center; gap: 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.token-box code { flex: 1; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 15px; word-break: break-all; color: var(--text); }
.copy-btn { flex: 0 0 auto; }

/* --------------------------------------------------------------------------
   Gist detail
   -------------------------------------------------------------------------- */
.gist-header { margin-bottom: 20px; }
.gist-header h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }
.gist-header .meta { margin-top: 6px; }

.file-block { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; box-shadow: var(--shadow); }
.file-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--surface-alt); border-bottom: 1px solid var(--border-soft); font-size: 13px; font-weight: 600; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
.file-block-head .lang { font-weight: 500; font-family: inherit; color: var(--text-muted); font-size: 12px; }

pre { background: #0d1117; border-radius: 0; padding: 16px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; }
pre code { background: none; padding: 0; border: none; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px; line-height: 1.5; }

/* --------------------------------------------------------------------------
   Markdown
   -------------------------------------------------------------------------- */
.markdown-body { padding: 16px; }
.markdown-body > :last-child { margin-bottom: 0; }
.gist-description .markdown-body { padding: 15px 18px 13px; font-family: Arial, Helvetica, sans-serif; line-height: 1.5; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; }
.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-soft); padding-bottom: 6px; }
.markdown-body p, .markdown-body ul, .markdown-body ol { margin-bottom: 16px; }
.markdown-body ul, .markdown-body ol { padding-left: 2em; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body blockquote { border-left: 4px solid var(--border); padding: 0 16px; color: var(--text-muted); margin-bottom: 16px; }
.markdown-body code:not(pre code) { background: #eff1f3; border-radius: 4px; padding: 2px 6px; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 85%; }
.markdown-body pre { background: #0d1117; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; border: none; font-size: 13px; }
.markdown-body table { border-collapse: collapse; width: 100%; margin-bottom: 16px; }
.markdown-body table th, .markdown-body table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown-body table th { background: var(--surface-alt); font-weight: 600; }
.markdown-body img { max-width: 100%; }

/* --------------------------------------------------------------------------
   Dashboard — collapsible sidebar
   -------------------------------------------------------------------------- */
.dash { display: flex; min-height: 100vh; background: var(--bg); }

.dash .brand { font-weight: 700; font-size: 17px; line-height: 1; color: #fff; display: flex; align-items: center; gap: 9px; text-decoration: none; white-space: nowrap; }
.dash .brand:hover { text-decoration: none; }
.dash .brand .logo { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 6px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: 700; line-height: 1; color: #fff; }

.dash-sidebar {
    width: 240px; flex: 0 0 240px;
    background: var(--nav-bg); color: #e6edf3;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    overflow: hidden;
    transition: width 0.18s ease, flex-basis 0.18s ease, transform 0.2s ease;
    z-index: 100;
}
.dash.collapsed .dash-sidebar { width: 64px; flex-basis: 64px; }

.dash-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 14px; min-height: 56px; }

.sidebar-toggle { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15); color: #e6edf3; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.18); }

.sidebar-nav { flex: 1; padding: 4px 8px 12px; overflow-y: auto; overflow-x: hidden; }
.sidebar-link { display: flex; align-items: center; gap: 11px; padding: 9px 11px; margin: 2px 0; border-radius: 6px; color: #c9d1d9; font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.sidebar-link.active { background: rgba(255, 255, 255, 0.14); color: #fff; }
.sidebar-link svg { flex: 0 0 18px; width: 18px; height: 18px; }
.sidebar-sep { height: 1px; background: rgba(255, 255, 255, 0.12); margin: 8px 6px; }

.sidebar-foot { padding: 8px 8px 14px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 4px 11px 10px; min-width: 0; }
.sidebar-user-email { font-size: 12px; color: #9ba7b4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash.collapsed .dash-sidebar-head { justify-content: center; padding-left: 0; padding-right: 0; }
.dash.collapsed .dash-sidebar-head .brand { display: none; }
.dash.collapsed .sidebar-label,
.dash.collapsed .brand-name,
.dash.collapsed .sidebar-user { display: none; }
.dash.collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }

.dash-main { flex: 1; min-width: 0; }
.dash-topbar { display: none; }
.dash-backdrop { display: none; }

.sidebar-toggle svg { width: 18px; height: 18px; }

@media (max-width: 768px) {
    .dash-sidebar { position: fixed; left: 0; top: 0; width: 240px; flex-basis: 240px; transform: translateX(-100%); box-shadow: none; }
    .dash.mobile-open .dash-sidebar { transform: translateX(0); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
    .dash.collapsed .dash-sidebar { width: 240px; flex-basis: 240px; }
    .dash.collapsed .sidebar-label,
    .dash.collapsed .brand-name,
    .dash.collapsed .sidebar-user { display: flex; }
    .dash.collapsed .brand-name { display: inline; }
    .dash.collapsed .dash-sidebar-head .brand { display: flex; }
    .dash.collapsed .sidebar-link { justify-content: flex-start; padding-left: 11px; padding-right: 11px; }
    .dash.collapsed .dash-sidebar-head { justify-content: space-between; padding-left: 14px; padding-right: 14px; }
    .dash-topbar { display: flex; align-items: center; gap: 12px; background: var(--nav-bg); color: #fff; height: 56px; padding: 0 16px; position: sticky; top: 0; z-index: 90; }
    .dash-topbar .sidebar-toggle { background: rgba(255, 255, 255, 0.12); }
    .dash.mobile-open .dash-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 95; }
}
