/* App shell additions that the artifact didn't need: sign-in, no-farm screen, account button, roles. */
body.booting #shell, body.booting .gate { visibility: hidden; }

.gate[hidden], #shell[hidden] { display: none !important; }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; box-sizing: border-box; }
.gate-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 28px 24px; }
.gate-card h1 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 1.7rem; }
.gate-card .sub { color: var(--muted); margin: 0; }
.gate-icon { align-self: center; border-radius: 16px; }
.gate-form { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-top: 6px; }
.gate-form label { font-size: 14px; font-weight: 600; }
.gate-form input { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 16px;
  width: 100%; min-width: 0; box-sizing: border-box; } /* never wider than the phone: an input's natural width overflowed it */
.gate-form .btn, .gate-card > .btn { min-height: 44px; justify-content: center; }
.gate-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.gate-or::before, .gate-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.gate-form[hidden] { display: none; }
.gate-form .code-input { font-size: 26px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.code-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }

/* Shown from the first paint until a screen is ready: while the app loads, a link or code signs in,
   and the farm opens. Fades in after a moment so a quick start doesn't flash it. */
body.booting #loading { visibility: visible; }
#loading .loading-card { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; animation: fp-fade .3s ease .25s both; }
.loading-name { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 1.7rem; margin: 0; }
#loading-text { margin: 0; color: var(--muted); font-size: 16px; }
.loading-stuck { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; }
.loading-stuck[hidden] { display: none; }
.loading-stuck p { margin: 0; color: var(--muted); font-size: 15px; }
.loading-stuck .btn { min-height: 44px; }
.btn .spinner.small { width: 16px; height: 16px; border-width: 2px; margin-right: 8px; display: inline-block; vertical-align: -3px; }
.btn[aria-busy=true] { opacity: .85; cursor: progress; }
.btn.is-done, .btn.is-done:hover { background: var(--ok); border-color: var(--ok); color: #fff; }
.save-status { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.save-status.ok { color: var(--ok); font-weight: 600; }
.save-status.dirty { color: var(--warn); font-weight: 600; }
.save-status.err { color: var(--bad); font-weight: 600; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: fp-spin .9s linear infinite; }
@keyframes fp-spin { to { transform: rotate(360deg); } }
@keyframes fp-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } #loading .loading-card { animation: none; } }

/* Choose a farm (several farms, none remembered) */
.farm-pick { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.farm-pick button { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 12px; justify-content: flex-start; text-align: left; }
.farm-pick .fp-initial { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 600; }
.farm-pick .fp-role { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 400; }
.fpk { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.fpk [hidden] { display: none !important; }
.fpk-q { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); font-size: 16px; }
.fpk-empty { margin: 0; text-align: center; }
.fpk-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fpk-pager .btn { min-height: 40px; }
.fpk-pager .btn:disabled { opacity: .45; cursor: default; }
.fpk-page { color: var(--muted); font-size: 14px; }
.fpk-admin { align-self: center; color: var(--accent-ink); font-weight: 600; font-size: 14px; padding: 6px 0; }

/* Only owners see farm settings; viewers see no editing controls (rules enforce both). */
body.not-owner .needs-owner { display: none !important; }

.farm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.farm-list button { width: 100%; text-align: left; min-height: 44px; }
.farm-list .on { border-color: var(--accent); font-weight: 600; }
.placeholder-view { padding: 48px 16px; text-align: center; color: var(--muted); }

/* No logo uploaded yet: hide the logo box rather than show a solid block. */
.no-logo .brand-logo { display: none; }
/* Quick-add bars stay hidden until a module adds buttons to them. */
.mobile-bar:empty { display: none !important; }

/* Admin page */
.admin-sec { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.admin-sec h3 { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }
.admin-slot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.admin-slot h4 { margin: 0; font-size: 14px; }
.admin-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.admin-thumb { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.admin-thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--line); }
.admin-thumb figcaption { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; padding: 4px 4px 4px 8px; color: var(--muted); }
.admin-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-upload input[type=text], .admin-upload input:not([type]) { flex: 1 1 180px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }

/* Uploaded logo as an image (instead of the two-tone mask used by imported logos) */
.logo-img .brand-logo > span { display: none; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Farm settings */
.set-sec { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.set-sec h3 { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }
.set-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.set-mods { display: grid; gap: 8px; }
.set-mods .check-row { align-items: flex-start; }
.set-mods small { display: block; color: var(--muted); font-weight: 400; }
.set-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.set-img { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.set-img .pv { aspect-ratio: 16 / 9; background: var(--deep) center / cover no-repeat; }
.set-img .pv.logo { background-color: var(--panel); background-size: contain; }
.set-img .meta { padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.set-img .meta b { font-size: 13px; }
.set-img .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.set-lists textarea { min-height: 110px; }
.set-mods input[type=checkbox] { flex: none; width: 22px; height: 22px; margin-top: 2px; }

/* People */
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; }
.person-name { flex: 1 1 140px; display: flex; flex-direction: column; min-width: 0; }
.person-name small { color: var(--muted); font-size: 12px; }
.person select { min-height: 40px; }
.link-pick { display: flex; gap: 8px; align-items: center; }
.link-pick select { max-width: 170px; font-size: 14px; }

/* Sign-up steps */
.ob-card { text-align: left; max-width: 520px; }
.ob-card h1 { text-align: left; }
.ob-step { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ob-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.ob-bar span { display: block; height: 100%; background: var(--accent); }
.ob-fields { display: flex; flex-direction: column; gap: 10px; }
.ob-fields .gate-form { margin-top: 0; }
.ob-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.ob-actions .btn { min-height: 44px; }
.ob-mods { max-height: 50dvh; overflow: auto; padding-right: 4px; }
.ob-inv-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
.ob-inv-row select { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 8px; }
.ob-inv-row .btn { min-height: 44px; }
@media (max-width: 420px) { .ob-inv-row { grid-template-columns: 1fr 1fr; } .ob-inv-row .gate-form:first-child { grid-column: 1 / -1; } }
.ob-look { flex-direction: row; flex-wrap: wrap; }
.ob-look .btn { min-height: 44px; }
.ob-look .sec-note { flex-basis: 100%; }
.ob-wrap { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 8px; }
.ob-foot { text-align: center; margin: 0; }
.ob-terms { margin: 4px 0 0; text-align: left; }

/* About, Privacy, Terms */
#signin { align-content: center; gap: 14px; }
.legal-links { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.legal-links a, .ob-terms a, .terms-note a, .acct-legal a { color: var(--accent-ink, var(--accent)); font-weight: 600; }
.legal-screen { min-height: 100dvh; padding: 12px 16px 32px; box-sizing: border-box; background: var(--bg); }
.legal-screen[hidden] { display: none !important; }
.legal-wrap { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.legal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 8px; border-bottom: 1px solid var(--line, rgba(0,0,0,.1)); }
.legal-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.legal-brand img { border-radius: 10px; }
.legal-brand .app-name { font-family: Fraunces, Georgia, serif; font-size: 1.35rem; font-weight: 600; }
.legal-back { min-height: 44px; font-size: 15px; }
.legal { padding: 20px 18px; line-height: 1.6; overflow-wrap: anywhere; }
.legal h2 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 1.6rem; margin: 0 0 12px; line-height: 1.25; }
.pricing-cta { margin: 22px 0 6px; }
.pricing-cta .btn { min-height: 48px; padding: 12px 22px; font-size: 16px; }
.legal h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 1.2rem; margin: 22px 0 6px; }
.legal h2:focus { outline: none; }
.legal p { margin: 0 0 12px; }
.legal ul, .legal ol { margin: 0 0 14px; padding-left: 22px; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--accent); }

/* One-time terms notice for people who joined before the terms existed */
.terms-note { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 8px auto 0; max-width: 1148px;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.terms-note p { margin: 0; }
.terms-note .btn { flex: none; min-height: 40px; }
@media (max-width: 700px) { .terms-note { margin: 8px 12px 0; } }

/* Account sheet: help and info */
.acct-h { margin: 18px 0 8px; }
.acct-help { display: flex; flex-direction: column; gap: 8px; }
.acct-help .btn { justify-content: center; min-height: 44px; text-align: center; }
.acct-legal { text-align: center; font-size: 14px; color: var(--muted); padding-top: 4px; }

/* Feedback */
.fb-head { display: flex; flex-direction: column; gap: 6px; }
.fb-head .sec-note { margin: 0; }
.fb-answer textarea { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel); color: var(--fg); font: inherit; font-size: 16px; }
.fb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fb-item { display: flex; flex-direction: column; gap: 6px; }
.fb-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.fb-title { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.fb-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); white-space: pre-wrap; }
.fb-status { flex: none; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg); }
.fb-planned { background: color-mix(in srgb, var(--accent-2) 30%, var(--panel)); }
.fb-done { background: color-mix(in srgb, #2E7D4F 25%, var(--panel)); }
.fb-notnow { color: var(--muted); }
.fb-shot-row { flex-direction: row !important; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-shot img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); }
.fb-admin-list { display: flex; flex-direction: column; gap: 10px; }
.fb-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.fb-filters select { min-height: 40px; }
.fb-answer { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; }
.fb-answer select { min-height: 40px; }
.fb-answer textarea { min-height: 40px; width: 100%; box-sizing: border-box; }
@media (max-width: 560px) { .fb-answer { grid-template-columns: 1fr auto; } .fb-answer textarea { grid-column: 1 / -1; grid-row: 2; } }
.adm-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-tabs .chip { text-decoration: none; color: var(--fg); min-height: 40px; display: inline-flex; align-items: center; padding: 6px 16px; }
.adm-tabs .chip.on { color: #fff; }
[data-view=admin] #adm-platform { display: flex; flex-direction: column; }
[data-view=admin] #adm-platform[hidden], #adm-feedback[hidden] { display: none; }

/* Admin: All farms */
.adm-farm-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-farm-tools input { flex: 1 1 200px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 16px; }
.adm-farm-tools select { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 15px; }
.adm-farm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.adm-farm { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel); }
.adm-farm-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.adm-farm-top h4 { margin: 0; font-size: 16px; }
.adm-farm-top .sec-note { margin: 2px 0 0; }
.adm-farm-top .btn { flex: none; min-height: 40px; }
.adm-farm-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 14px; }
.adm-farm-meta dt { color: var(--muted); }
.adm-farm-meta dd { margin: 0; overflow-wrap: anywhere; }
.adm-idx-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.adm-idx-head .sec-note { margin: 0; flex: 1 1 200px; }
.adm-idx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#adm-platform .fpk-pager { margin-top: 4px; }

/* Admin view of a farm: a bar inside the sticky top nav, so it stays on screen */
.admin-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 6px 14px; font-size: 14px; font-weight: 600; background: var(--deep); color: #fff; }
.admin-bar.viewing { padding: 8px 14px; }
.admin-bar.editing { background: var(--bad); }
.admin-bar p { margin: 0; }
.admin-bar .bar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-bar .btn { min-height: 36px; background: #fff; color: var(--fg); border-color: transparent; }

/* Farm settings: support changes */
.support-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.support-log li { border-top: 1px solid var(--line); padding-top: 6px; }
.support-log .sec-note { display: block; }

/* Contact page */
.ct-form { margin: 8px 0 12px; }
.ct-form > * { grid-column: 1 / -1; }
.ct-form .err:empty { display: none; }
.ct-form .btn { min-height: 44px; }
.ct-form input[readonly] { color: var(--muted); }
.ct-count:empty { display: none; }
.ct-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Admin: Site pages */
.sp-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.sp-pick .chip { min-height: 40px; padding: 6px 16px; }
.sp-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp-body { width: 100%; box-sizing: border-box; min-height: 60vh; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.sp-body[hidden], .sp-preview[hidden], .sp-editor[hidden], #sp-hint[hidden], #sp-again-row[hidden] { display: none; }
/* The visual editor (public/vendor/toastui-editor): 16px text so iOS doesn't zoom. On a phone the toolbar
   puts what doesn't fit behind its own "more" button. */
.sp-editor { min-height: 320px; }
.sp-editor.busy { opacity: .5; pointer-events: none; }
.sp-editor .toastui-editor-defaultUI { border-color: var(--line); border-radius: 8px; }
.sp-editor .toastui-editor-defaultUI .ProseMirror, .sp-editor .toastui-editor-contents { font-size: 16px; line-height: 1.55; }
.sp-editor .toastui-editor-contents h1, .sp-editor .toastui-editor-contents h2 { border-bottom: 0; }
.sp-editor .toastui-editor-dark.toastui-editor-defaultUI { background: var(--panel); }
#sp-hint { margin: 0; }
.sp-preview { max-height: 70vh; overflow: auto; }
.sp-save { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp-save input:not([type=checkbox]) { flex: 1 1 220px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); font-size: 16px; }
.sp-save .btn { min-height: 44px; }
.sp-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-hist li { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.sp-hist p { margin: 2px 0 0; }
.sp-version { max-height: 55vh; overflow: auto; padding: 0 4px; line-height: 1.5; }

/* Admin: Messages */
.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg-open { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.msg.unread .msg-open { border-left: 4px solid var(--accent); }
.msg.unread b { font-weight: 700; }
.msg-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.msg-st { cursor: default; font-size: 12px; }
.msg-st-new, .msg-st-open { background: var(--accent); border-color: var(--accent); color: #fff; }
.msg-st-pending { border-color: var(--warn); color: var(--fg); font-weight: 600; }
.msg-st-resolved, .msg-st-closed { color: var(--muted); }
.msg-snip { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; }
.msg-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.msg-actions select { min-height: 44px; }
.msg-actions .btn { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }

.ct-powered { margin: -4px 0 4px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* Admin bar on phones: one slim line with outlined buttons (white on the dark bar in both color schemes) */
.admin-bar .btn { color: #1F2420; }
@media (max-width: 700px) {
  .admin-bar, .admin-bar.viewing { flex-wrap: nowrap; gap: 8px; min-height: 36px; padding: 3px 10px; font-size: 13px; }
  .admin-bar p { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-bar .ab-long { display: none; }
  .admin-bar .bar-btns { flex: none; flex-wrap: nowrap; gap: 6px; }
  .admin-bar .btn.small { min-height: 30px; padding: 3px 12px; font-size: 13px; line-height: 1.2; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.75); }
  .admin-bar .btn.small:active { background: rgba(255,255,255,.18); }
}

/* About, Privacy, Terms and Contact inside the signed-in app: under the top nav, in place of the page */
.legal-in-shell #app, .legal-in-shell #views, .legal-in-shell #app-foot, .legal-in-shell #bar-main { display: none !important; }
.legal-in-shell .legal-screen { min-height: 0; background: none; }
.legal-in-shell .legal-brand { display: none; }
.legal-in-shell .legal-head { justify-content: flex-start; padding: 0; border-bottom: 0; }
/* noOk sheets: .btn's display otherwise beats [hidden] and leaves a stray Save */
.modal-actions .btn[hidden] { display: none; }

/* Demo farm visitors: the same bar as admin view, in the brand rust */
.demo-bar { background: #8A3B12; }
