:root {
  --paper: #faf8f4; --card: #ffffff; --ink: #24211d; --muted: #6f685e; --line: #e4dfd6;
  --accent: #8a3b24; --warn-bg: #fbf0dc; --warn-ink: #7a5412; --ok-bg: #e7f1e3; --ok-ink: #2f5d2a;
  --glass: rgba(250, 248, 244, .78); color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161412; --card: #211e1b; --ink: #f2efe9; --muted: #a79f94; --line: #36322c;
    --accent: #e8926c; --warn-bg: #3a2d14; --warn-ink: #ecc77d; --ok-bg: #1f3320; --ok-ink: #a4d39c;
    --glass: rgba(22, 20, 18, .76);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; }
a { color: inherit; }
h1, h2, .brand, .work-title { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 32px; border-bottom: 1px solid var(--line); background: var(--paper);
  position: sticky; top: 0; z-index: 5; }
.brand { font-size: 24px; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand img { width: 30px; height: 30px; display: block; }
nav { display: flex; gap: 18px; align-items: center; font-size: 15px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); }
nav a.on { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
main { max-width: 1240px; margin: 0 auto; padding: 32px; }
.intro h1 { font-size: 40px; margin: 8px 0 4px; }
.intro p { color: var(--muted); margin: 0 0 24px; max-width: 60ch; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; align-items: center; }
select, input[type=search], textarea { font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
input[type=search] { min-width: 240px; flex: 1; max-width: 360px; }
button { font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 14px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.count { color: var(--muted); font-size: 14px; }
.grid { columns: 3 280px; column-gap: 28px; }
.work { display: block; break-inside: avoid; margin-bottom: 32px; text-decoration: none; }
.work img { display: block; width: 100%; height: auto; background: var(--line); }
.work-title { font-size: 19px; margin-top: 10px; font-style: italic; }
.work-meta { color: var(--muted); font-size: 14px; }
.detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 40px; align-items: start; }
.detail img { width: 100%; height: auto; display: block; }
.detail h1 { font-size: 32px; margin: 0; font-style: italic; }
.detail .artist { font-size: 19px; margin: 4px 0 18px; }
.facts { margin: 0; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: 6px; margin: 0 0 20px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.stat b { display: block; font: 400 28px Georgia, serif; }
.stat span { color: var(--muted); font-size: 14px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--paper); }
td img { width: 48px; height: 48px; object-fit: cover; display: block; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 13px; white-space: nowrap; background: var(--line); }
.pill.available, .pill.public { background: var(--ok-bg); color: var(--ok-ink); }
.pill.flag, .pill.needs { background: var(--warn-bg); color: var(--warn-ink); }
.flag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.flag-list li { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.flag-list small { color: var(--muted); display: block; }
.empty { color: var(--muted); padding: 40px 0; }
.small { font-size: 14px; color: var(--muted); }
@media (max-width: 760px) {
  .top { padding: 14px 16px; } main { padding: 20px 16px; }
  .detail { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .intro h1 { font-size: 32px; } input[type=search] { min-width: 0; width: 100%; max-width: none; }
}
.form { display: grid; gap: 14px; margin-top: 24px; align-content: start; }
.form.narrow { max-width: 420px; margin-top: 0; }
.form h2 { margin: 0; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.form input:not([type=checkbox]), .form select, .form textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.form button { justify-self: start; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
fieldset[hidden] { display: none; }
legend { font-size: 14px; color: var(--muted); padding: 0 4px; }
.error { color: var(--accent); margin: 0; font-size: 15px; }
.error:empty { display: none; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 40px; margin-top: 8px; }
.plain { margin: 0; padding-left: 18px; }
.message { white-space: pre-wrap; overflow-wrap: anywhere; }

.phone, .phone-only { display: none; }
.check-line { display: flex; align-items: center; gap: 8px; }
.sheets { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; align-items: start; max-width: 860px; }
.sheet { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.sheet h2 { font-size: 20px; }
.sheet .small { margin: 0 0 8px; }
.sheet .notice { margin: 0; }
.sheet .notice p { margin: 0 0 6px; }
.form-part { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-part label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions .small { margin: 0; }
.form input:not([type=checkbox]), .form select { min-height: 44px; }
.asks-link { font-size: 14px; white-space: nowrap; }
.talks { margin: 20px 0; }
.talks h2 { font-size: 20px; margin: 0 0 8px; }
.team { display: flex; flex-direction: column; }
.toast:empty { display: none; }
.toast { color: var(--ok-ink); font-size: 14px; margin: 12px 0 0; }
.fold > summary { font: 400 22px Georgia, serif; cursor: pointer; }
.menu { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a { display: block; padding: 14px 16px; text-decoration: none; }

@media (max-width: 760px) {
  .wide, .wide-only { display: none; }
  .phone { display: inline; }
  .phone-only { display: flex; }

  /* Tabs along the bottom, within thumb reach */
  .top { position: static; padding: 10px 16px; }
  .brand { font-size: 20px; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; gap: 0; flex-wrap: nowrap; align-items: stretch;
    background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); font-size: 13px; }
  nav:empty { display: none; }
  nav a { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 2px; text-align: center; }
  nav a.on { color: var(--accent); font-weight: 600; text-decoration: none; box-shadow: inset 0 2px 0 var(--accent); }
  main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .intro h1 { font-size: 28px; margin-top: 0; }
  .intro p { margin-bottom: 16px; }

  /* Comfortable tapping */
  button, .form input:not([type=checkbox]), .form select, .filters select, input[type=search] { min-height: 44px; font-size: 16px; }
  .form button { justify-self: stretch; }
  .form label.check, .check-line { min-height: 44px; }
  input[type=checkbox] { width: 22px; height: 22px; flex: none; }

  /* Two columns of art instead of one very long page */
  .grid { columns: 2; column-gap: 12px; }
  .work { margin-bottom: 20px; }
  .work-title { font-size: 16px; margin-top: 6px; line-height: 1.25; }
  .work-meta { font-size: 13px; }

  /* Inventory: find a work first, totals second */
  .team .intro { order: 1; }
  .team .filters { order: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .team .filters input[type=search] { grid-column: 1 / -1; }
  .team .filters select { min-width: 0; width: 100%; }
  .team .count { text-align: right; }
  .team .stats { order: 3; display: flex; overflow-x: auto; gap: 8px; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .team .stat { flex: 0 0 auto; padding: 6px 12px; }
  .team .stat b { font-size: 19px; }
  .team .stat span { font-size: 12px; white-space: nowrap; }
  .team .table-wrap { order: 4; }
  .team .notice { order: 5; margin: 12px 0 0; }

  /* Tables become cards, so nothing runs off the screen */
  .table-wrap { overflow: visible; background: none; border: 0; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody tr { display: grid; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; margin-bottom: 8px; gap: 2px 12px; align-items: center; }
  tbody tr:last-child { margin-bottom: 0; }
  tbody td { padding: 0; border: 0; min-width: 0; }
  .works-table tbody tr { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .works-table td.thumb { grid-row: 1 / span 4; align-self: start; }
  .works-table td.thumb img { width: 72px; height: 72px; }
  .works-table td.name { grid-column: 2 / -1; font-family: Georgia, serif; font-style: italic; font-size: 16px; line-height: 1.25; }
  .works-table td.by { grid-column: 2 / -1; font-size: 14px; }
  .works-table td.size { grid-column: 2; font-size: 13px; color: var(--muted); }
  .works-table td.price { grid-column: 3; font-size: 13px; text-align: right; }
  .works-table td.status { grid-column: 2; }
  .works-table td.shown { grid-column: 3; text-align: right; }
  .works-table td.asks:not(:empty) { grid-column: 2 / -1; margin-top: 4px; }
  .works-table td.asks:empty { display: none; }
  .people-table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  .people-table td.name { font-weight: 600; }
  .people-table td.name { grid-area: 1 / 1; }
  .people-table td.role { grid-area: 1 / 2; text-align: right; }
  .people-table td.mail { grid-area: 2 / 1 / 3 / -1; font-size: 14px; overflow-wrap: anywhere; }
  .people-table td.access { grid-area: 3 / 1; }
  .people-table td.state { grid-area: 3 / 2; text-align: right; }

  /* Record: the controls come before the long list of facts */
  .record { gap: 12px; }
  .record > img { width: auto; max-width: 100%; max-height: 34vh; margin: 0 auto; }
  .record-side { display: flex; flex-direction: column; }
  .record-side h1 { font-size: 26px; }
  .record-side .artist { margin-bottom: 12px; }
  .record-side .form { order: 1; margin: 0 0 20px; }
  .record-side .facts { order: 2; }
  .record-side .caption { order: 3; }
  .toast { position: fixed; left: 16px; right: 16px; z-index: 11; margin: 0; padding: 10px 14px; text-align: center;
    bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--paper); border-radius: 8px; }

  /* Accounts: forms stay folded until needed */
  .columns { gap: 12px; margin-top: 16px; }
  .fold { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
  .fold > summary { font-size: 18px; }
  .fold .form { margin-top: 12px; }
  .form.narrow { max-width: none; }
}
.reply { border-left: 3px solid var(--accent); padding-left: 10px; margin-top: 8px; }
.reply p { margin: 2px 0 0; }

/* Feels like an app rather than a web page */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
a, button, summary { touch-action: manipulation; }
nav, button, summary, .back, .brand { -webkit-user-select: none; user-select: none; }
img { -webkit-touch-callout: default; }
.tab-icon { display: none; }
.badge { min-width: 18px; padding: 0 5px; border-radius: 9px; background: #d93a2b; color: #fff; font: 600 11px/18px -apple-system, sans-serif; text-align: center; margin-left: 6px; }
.badge[hidden] { display: none; }
.welcome img { display: block; width: 72px; height: 72px; margin-bottom: 8px; }
#pull { height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#pull span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--muted); opacity: .5; }
#pull.ready span { opacity: 1; }
#pull.spin { height: 44px !important; }
#pull.spin span { animation: turn .7s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.loading::before { content: ""; position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 20; transform-origin: left;
  background: var(--accent); animation: progress 1.2s ease-out .15s both; }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(.85); } }

@media (max-width: 760px) {
  /* The blur sits on a layer behind the header. On the header itself it would trap the fixed tab bar inside it. */
  .top { position: sticky; top: 0; z-index: 9; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: none; }
  .top::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  .brand img { width: 26px; height: 26px; }

  nav { background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  nav a { position: relative; flex-direction: column; gap: 2px; min-height: 54px; font-size: 11px; font-weight: 500; }
  nav a.on { box-shadow: none; font-weight: 500; }
  nav a:active { opacity: .55; }
  .tab-icon { display: block; width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  nav a.on .tab-icon { stroke-width: 2.1; }
  .badge { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; }

  .intro h1 { font-size: 32px; letter-spacing: -.01em; }
  .welcome { text-align: center; padding-top: 24px; }
  .welcome img { margin: 0 auto 8px; }
  .back { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; margin: -4px 0 8px; color: var(--accent); text-decoration: none; }
  .back::before { content: ""; width: 9px; height: 9px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }

  /* Art runs to the screen edges */
  .detail:not(.record) > img { width: calc(100% + 32px); max-width: none; margin: -4px -16px 0; }

  /* Lists read like iOS settings rows */
  tbody tr, .flag-list li, .menu a, .work { transition: transform .12s ease, opacity .12s ease; }
  tbody tr:active, .flag-list li:active, .work:active { transform: scale(.98); opacity: .8; }
  .menu a { position: relative; padding-right: 34px; min-height: 48px; display: flex; align-items: center; }
  .menu a:active { background: var(--line); }
  .menu a::after, .people-table td.mail::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
    border-top: 2px solid var(--muted); border-right: 2px solid var(--muted); transform: rotate(45deg); opacity: .6; }
  .people-table td.mail::after { display: none; }
  .menu, .flag-list li, tbody tr, .fold, .sheet { border-radius: 12px; }
  button:active { opacity: .7; }

  #app.slide-in { animation: slide-in .24s cubic-bezier(.2, .8, .2, 1); }
  #app.slide-back { animation: slide-back .24s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes slide-in { from { opacity: .4; transform: translateX(28px); } }
@keyframes slide-back { from { opacity: .4; transform: translateX(-28px); } }
@media (prefers-reduced-motion: reduce) {
  #app.slide-in, #app.slide-back, .loading::before { animation: none; }
  tbody tr, .flag-list li, .work { transition: none; }
}
