/* J+I Social — base styles. Mobile first; tap targets at least 44px. */

:root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --ink: #24211d;
    --muted: #6f675d;
    --line: #e6dfd4;
    --accent: #9a7444;
    --accent-ink: #ffffff;
    --accent-soft: #f3ebdf;
    --ok: #2f7a4f;
    --ok-soft: #e4f2e9;
    --warn: #8a6100;
    --warn-soft: #fbf1d9;
    --fail: #b3261e;
    --fail-soft: #fbe5e3;
    --info-soft: #e8eef6;
    --radius: 10px;
    --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 var(--sans);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .95em; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* App shell: sidebar like Pallyy's section menu; collapses to a menu button on phones */
.sidebar { background: var(--surface); border-bottom: 1px solid var(--line); }
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: .25rem .75rem .25rem 1rem;
}
.nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
}
.nav-button:hover { background: var(--accent-soft); }
.nav-check:focus-visible ~ .shell .nav-button { outline: 2px solid var(--accent); }
.side-nav {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: .25rem .75rem 1rem;
}
.nav-check:checked ~ .shell .side-nav { display: flex; }
.side-nav a, .side-nav .nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    min-height: 44px;
    padding: 0 .75rem;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.side-nav a:hover, .side-nav .nav-item:hover { background: var(--accent-soft); }
.side-nav a.active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.side-nav .icon { flex: none; color: var(--muted); }
.side-nav a.active .icon { color: var(--accent); }
.side-nav form { margin: 0; }
.nav-heading {
    margin: 1rem .75rem .25rem;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.nav-foot { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--line); }

@media (min-width: 900px) {
    .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
    .sidebar {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow-y: auto;
        border-bottom: 0;
        border-right: 1px solid var(--line);
    }
    .sidebar-top { padding: 1rem 1.25rem .75rem; }
    .nav-button { display: none; }
    .side-nav { display: flex; flex: 1; }
    .nav-foot { margin-top: auto; }
}

.brand, .auth-brand {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: .02em;
}
.brand span, .auth-brand span { color: var(--accent); font-weight: 500; }

/* Layout */
.page { width: 100%; max-width: 1100px; padding: 1.25rem 1rem 3rem; }
.page > * + * { margin-top: 1rem; }
.page-head p { max-width: 68ch; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 760px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .page { padding: 2rem 2rem 4rem; }
}
.narrow-card { max-width: 560px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.card.narrow { max-width: 560px; margin: 2rem auto; }
.empty { color: var(--muted); margin: 0; }

/* Auth pages */
body.auth { display: flex; min-height: 100vh; align-items: flex-start; justify-content: center; }
.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 6vh 1rem 2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.75rem 1.5rem;
}
.auth-card .auth-brand { display: block; margin-bottom: 1.25rem; }
.auth-card .card.narrow { border: 0; padding: 0; margin: 0; }

/* Forms */
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .35rem; font-weight: 600; font-size: .95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: 16px var(--sans); /* 16px stops iOS zooming on focus */
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .btn-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.code-input { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .15em; }
textarea { min-height: 88px; line-height: 1.45; resize: vertical; }
.help { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; }
.field-error { color: var(--fail); font-size: .875rem; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--fail); }
fieldset { margin: 0; min-width: 0; }
legend { float: left; width: 100%; padding: 0; margin-bottom: .25rem; font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
legend + * { clear: both; }
label.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 600; }
label.check input { width: 20px; height: 20px; margin: .15rem 0 0; accent-color: var(--accent); flex: none; }
.form-row { display: grid; gap: 1rem; }
@media (min-width: 700px) {
    .form-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .form-row .narrow-field { max-width: 180px; }
}
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.inline-form input { flex: 1 1 240px; width: auto; }
.inline-form select { width: auto; min-height: 36px; padding: .25rem .5rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font: 600 1rem var(--sans);
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.94); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-small { min-height: 36px; padding: 0 .75rem; font-size: .9rem; }
.btn-link {
    min-height: 44px;
    background: none;
    border: 0;
    padding: 0 .25rem;
    color: var(--muted);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.btn-link:hover { color: var(--ink); text-decoration: underline; }
.btn-link.danger { color: var(--fail); }

/* Messages */
.flash { padding: .75rem 1rem; border-radius: 8px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--fail-soft); color: var(--fail); }
.flash-info { background: var(--info-soft); }
.banner { padding: .9rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; }
.banner-critical { background: var(--fail-soft); color: var(--fail); border: 1px solid #f0c3bf; }

/* 2FA setup */
.steps { padding-left: 1.25rem; display: grid; gap: .9rem; margin: 0 0 1.25rem; }
.secret {
    display: block;
    margin-top: .5rem;
    padding: .6rem .75rem;
    background: var(--accent-soft);
    border-radius: 8px;
    font-size: 1.05rem;
    letter-spacing: .08em;
    word-break: break-all;
    user-select: all;
}
.recovery-codes {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
}
.recovery-codes code {
    display: block;
    padding: .5rem;
    background: var(--accent-soft);
    border-radius: 6px;
    text-align: center;
    font-size: 1.05rem;
    user-select: all;
}

/* Credentials */
.cred { padding: 1rem 0; border-top: 1px solid var(--line); }
.cred:first-of-type { border-top: 0; padding-top: .25rem; }
.cred-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cred .help { margin: .25rem 0 .5rem; }
.masked { color: var(--muted); letter-spacing: .05em; }
.cred-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1rem; }
.cred-actions form { margin: 0; }
.reveal { flex: 1 1 320px; }
.reveal > summary { list-style: none; display: inline-flex; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal[open] > summary { display: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: .5rem;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-align: left;
    text-transform: uppercase;
}
.data-table td { padding: .75rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 .5rem; }
.row-actions form { margin: 0; }
@media (max-width: 760px) {
    .data-table thead { display: none; }
    .data-table tr { display: block; padding: .75rem 0; border-bottom: 1px solid var(--line); }
    .data-table td { display: block; padding: .2rem 0; border: 0; }
    .data-table td[data-label]:not([data-label="Name"])::before {
        content: attr(data-label) ": ";
        color: var(--muted);
        font-size: .85rem;
    }
    .row-actions { justify-content: flex-start; }
}
.invite-link { border-color: var(--accent); }

/* Page header with actions on the right */
.head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; }
.head-row h1 { margin: 0; }
.crumbs { margin: 0 0 .25rem; font-size: .9rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Uploader */
.uploader { display: grid; justify-items: end; gap: .35rem; max-width: 100%; }
.uploader .help { margin: 0; text-align: right; }
.uploader-form { display: flex; gap: .5rem; margin: 0; }
.upload-button { gap: .4rem; cursor: pointer; }
.upload-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-status {
    width: min(460px, 100%);
    margin: .25rem 0 0;
    padding: .5rem .75rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .9rem;
}
.upload-status li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem; padding: .35rem 0; }
.upload-status li + li { border-top: 1px solid var(--line); }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload-status progress { width: 90px; height: 8px; align-self: center; accent-color: var(--accent); }
.upload-message { grid-column: 1 / -1; color: var(--muted); }
.upload-ok .upload-message { color: var(--ok); }
.upload-warn .upload-message { color: var(--warn); }
.upload-fail .upload-message { color: var(--fail); }
@media (max-width: 600px) {
    .head-row { flex-direction: column; }
    .uploader { justify-items: start; }
    .uploader .help { text-align: left; }
}

/* Library */
.library { position: relative; }
.library > * + * { margin-top: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 240px; width: auto; min-height: 40px; }
.toolbar select { width: auto; min-height: 40px; padding: .4rem .6rem; }
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
@media (max-width: 500px) { .media-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
.tile { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--accent-soft); border-radius: 4px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.tile:hover img { transform: scale(1.03); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border-radius: 50%;
    background: rgba(36, 33, 29, .55);
    color: #fff;
}
.tile-badge .icon { width: 18px; height: 18px; }
.tile-caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 1.25rem .5rem .35rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, .55));
    color: #fff;
    font-size: .8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pager { display: flex; gap: .5rem; justify-content: center; }
.empty-state { text-align: center; padding: 2.5rem 1.25rem; }
.empty-state p { margin-inline: auto; max-width: 52ch; }
.drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(250, 247, 242, .9);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-weight: 700;
    font-size: 1.2rem;
    pointer-events: none;
}
.drop-overlay span { display: inline-flex; gap: .5rem; align-items: center; }
.dragging > .drop-overlay { display: grid; }

/* Photo detail */
.media-detail { display: grid; gap: 1rem; }
@media (min-width: 960px) { .media-detail { grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); align-items: start; } }
.focal-picker { position: relative; line-height: 0; }
.focal-picker img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; border-radius: 6px; background: var(--accent-soft); }
.focal-picker.is-interactive img { cursor: crosshair; }
.focal-picker.is-saving { opacity: .7; }
.focal-marker {
    position: absolute;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--accent), 0 1px 6px rgba(0, 0, 0, .4);
    pointer-events: none;
}
.focal-form { margin-top: .75rem; }
.focal-inputs { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.focal-inputs label { font-size: .85rem; }
.focal-inputs input { width: 110px; min-height: 36px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: .5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.renditions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.rendition { display: grid; gap: .4rem; align-content: start; font-size: .9rem; }
.rendition img { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--line); display: block; }
.danger-zone { display: flex; justify-content: flex-end; }
.danger-zone form { margin: 0; }
.danger-button { color: var(--fail); }

/* System checks */
.checks { width: 100%; border-collapse: collapse; }
.checks td, .checks th { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.checks tr.group th { padding-top: 1.25rem; font-family: var(--serif); font-size: 1.1rem; border-bottom-color: var(--ink); }
.checks tr:first-child th { padding-top: 0; }
@media (max-width: 600px) {
    .checks td { display: block; border: 0; padding: .15rem 0; }
    .checks tr:not(.group) { display: block; padding: .6rem 0; border-bottom: 1px solid var(--line); }
}

.pill {
    display: inline-block;
    padding: .1rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-fail { background: var(--fail-soft); color: var(--fail); }
