/* Apple's system font, system colours and iOS text styles. Inset grouped lists,
   one tint colour for anything you can tap, red only for problems. */
:root {
  --bg: #F2F2F7;            /* systemGroupedBackground */
  --cell: #FFFFFF;          /* secondarySystemGroupedBackground */
  --label: #000000;
  --label2: rgba(60, 60, 67, .6);
  --label3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .29);
  --fill: rgba(118, 118, 128, .12);   /* tertiarySystemFill */
  --thumb: #FFFFFF;
  --tint: #007AFF; --red: #FF3B30; --orange: #FF9500; --green: #34C759;
  --bar: rgba(242, 242, 247, .8);
  --press: rgba(0, 0, 0, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --cell: #1C1C1E; --label: #FFFFFF; --label2: rgba(235, 235, 245, .6); --label3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .65); --fill: rgba(118, 118, 128, .24); --thumb: #636366;
    --tint: #0A84FF; --red: #FF453A; --orange: #FF9F0A; --green: #30D158;
    --bar: rgba(22, 22, 24, .8); --press: rgba(255, 255, 255, .08);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
html.locked, html.locked body { overflow: hidden; }
body { margin: 0; font: 17px/1.29 var(--font); letter-spacing: -0.022em; color: var(--label); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 4px; }

/* iOS text styles */
.large { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.011em; margin: 0; }
.headline { font-size: 17px; line-height: 22px; font-weight: 600; }
.subhead { font-size: 15px; line-height: 20px; letter-spacing: -0.016em; }
.footnote { font-size: 13px; line-height: 18px; letter-spacing: -0.006em; }
.secondary { color: var(--label2); }

.wrap { max-width: 44rem; margin: 0 auto; padding: 0 16px calc(48px + var(--safe-b)); }

/* Navigation: buttons row, large title, then the search bar that sticks. */
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding-top: var(--safe-t); }
.textbtn { border: 0; background: none; color: var(--tint); font-size: 17px; padding: 10px 0; min-height: 44px; cursor: pointer; touch-action: manipulation; }
.textbtn:active { opacity: .35; }
.textbtn.strong { font-weight: 600; }
.branch { appearance: none; -webkit-appearance: none; field-sizing: content; max-width: 70%; border: 0; color: var(--tint); font-size: 17px; padding: 10px 18px 10px 0; min-height: 44px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23007AFF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0 center / 11px; }
@media (prefers-color-scheme: dark) {
  .branch { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%230A84FF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
}
.title-row { padding: 2px 0 8px; }

.bar { position: sticky; top: 0; z-index: 10; margin: 0 -16px; padding: 0 16px 10px; }
.bar.stuck { padding-top: var(--safe-t); background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--sep); }
.bar .inline { display: none; align-items: center; justify-content: center; position: relative; height: 44px; }
.bar.stuck .inline { display: flex; }
.bar .inline .textbtn { position: absolute; right: 0; top: 0; }
.search { position: relative; }
.search input { width: 100%; height: 36px; border: 0; border-radius: 10px; background: var(--fill); padding: 0 32px 0 32px; font-size: 17px; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--label2); }
.search input::-webkit-search-cancel-button { display: none; }
.search .glass { position: absolute; left: 9px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--label2); pointer-events: none; }
.search .clear { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.search .clear svg { width: 17px; height: 17px; color: var(--label3); }
.filtered { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 4px 0; }
.filtered .textbtn { padding: 0; min-height: 0; font-size: 15px; }

/* Inset grouped lists */
.section { margin-top: 22px; }
.section-head { padding: 0 16px 7px; font-size: 13px; line-height: 18px; letter-spacing: -0.006em; text-transform: uppercase; color: var(--label2); }
.section.attention .section-head { color: var(--red); }
.list { list-style: none; margin: 0; padding: 0; background: var(--cell); border-radius: 10px; overflow: hidden; }
.list > li { position: relative; }
.list > li + li::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; height: 0.5px; background: var(--sep); z-index: 1; }
.cellbtn { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; width: 100%; padding: 11px 16px; border: 0; background: none; text-align: left; cursor: pointer; touch-action: manipulation; }
.cellbtn:active { background: var(--press); }
.cellbtn .l1 { display: flex; gap: 6px; min-width: 0; }
.cellbtn .l1 .num { flex: none; }
.cellbtn .l1 .name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cellbtn .trail { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; justify-self: end; }
.cellbtn .l2, .cellbtn .l3 { grid-column: 1 / span 2; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 7px; height: 12px; color: var(--label3); flex: none; }
.st-wait { color: var(--orange); }
.st-bad { color: var(--red); }
.warn { color: var(--red); }
.new { animation: appear 250ms ease-out; }
@keyframes appear { from { opacity: 0; } }

/* Printer cell */
.printer .cellbtn { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; align-items: center; }
.printer .icon { width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; background: #8E8E93; color: #fff; grid-row: 1 / span 2; }
.printer .icon.ok { background: var(--green); } .printer .icon.bad { background: var(--red); } .printer .icon.wait { background: var(--orange); }
.printer .icon svg { width: 18px; height: 18px; }
.printer .l1, .printer .l2 { grid-column: 2; }
.printer .l2 { white-space: normal; }
.printer .trail { grid-column: 3; grid-row: 1 / span 2; }
.problem { padding: 11px 16px; color: var(--red); font-size: 15px; }

.empty { padding: 28px 16px; text-align: center; color: var(--label2); }
.empty .headline { color: var(--label); margin-bottom: 4px; }
.empty .textbtn { margin-top: 6px; }

/* Sheets (iOS page sheet) */
.layer { position: fixed; inset: 0; z-index: 30; }
.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); opacity: 0; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 40rem; max-height: calc(100dvh - 10px - var(--safe-t));
  display: flex; flex-direction: column; background: var(--bg); border-radius: 10px 10px 0 0; transform: translate3d(0, 100%, 0); will-change: transform; outline: none; }
.grab { padding: 5px 0 0; display: grid; place-items: center; touch-action: none; cursor: grab; }
.grab span { width: 36px; height: 5px; border-radius: 3px; background: var(--label3); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; padding: 0 16px; touch-action: none; cursor: grab; }
.sheet-head h2 { grid-column: 2; margin: 0; font-size: 17px; line-height: 22px; font-weight: 600; text-align: center; white-space: nowrap; }
.sheet-head .done { grid-column: 3; justify-self: end; font-weight: 600; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(28px + var(--safe-b)); }
.sheet-body > .section:first-child { margin-top: 12px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 16px; min-height: 44px; }
.row .v { color: var(--label2); text-align: right; min-width: 0; }
.row.stack { display: grid; gap: 2px; }
.row.stack .v { text-align: left; color: var(--label); }
.row.stack .k { color: var(--label2); font-size: 15px; }
.row a { color: var(--tint); text-decoration: none; }
.item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 8px; padding: 11px 16px; align-items: baseline; }
.item .q { color: var(--label2); }
.item .opt { color: var(--label2); font-size: 15px; }
.item .p { color: var(--label2); }
.action { display: block; width: 100%; border: 0; background: none; text-align: left; color: var(--tint); padding: 11px 16px; min-height: 44px; cursor: pointer; touch-action: manipulation; }
.action:active { background: var(--press); }
.action:disabled { color: var(--label3); }
.foot { padding: 7px 16px 0; font-size: 13px; line-height: 18px; color: var(--label2); }
.steps { margin: 0; padding: 11px 16px 11px 36px; display: grid; gap: 8px; font-size: 15px; line-height: 20px; }
.steps b { font-weight: 600; }
.urlrow { display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.urlrow code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 13px/18px ui-monospace, "SF Mono", Menlo, monospace; color: var(--label2); user-select: all; }
.urlrow .textbtn { padding: 0; min-height: 0; }
.field { display: grid; gap: 2px; padding: 11px 16px; }
.field > span { font-size: 13px; color: var(--label2); }
.field input, .field textarea, .field select { width: 100%; border: 0; background: transparent; padding: 0; font-size: 17px; color: var(--label); }
.field textarea { min-height: 66px; resize: vertical; }
.field select { -webkit-appearance: none; appearance: none; color: var(--tint); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; min-height: 44px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; flex: none; cursor: pointer; transition: background-color 200ms ease; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 3px 1px rgba(0, 0, 0, .06); transition: transform 200ms ease; }
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { transform: translateX(20px); }

/* Segmented control (Filters sheet) */
.seg { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { flex: 1 1 0; min-width: 0; height: 28px; border: 0; border-radius: 7px; background: none; font-size: 13px; letter-spacing: -0.006em; font-weight: 500; cursor: pointer; touch-action: manipulation; white-space: nowrap; position: relative; }
.seg button::before { content: ""; position: absolute; inset: -8px 0; }
.seg button[aria-pressed="true"] { background: var(--thumb); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.segrow { padding: 10px 16px; display: grid; gap: 8px; }

/* Sign in */
.signin { max-width: 20rem; margin: 16vh auto 0; padding: 0 16px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.appicon { width: 64px; height: 64px; border-radius: 15px; background: #FBF5EB; display: grid; place-items: center; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, .08); }
.appicon svg { width: 38px; color: #6C4B30; }
.signin form { display: grid; gap: 12px; width: 100%; }
.signin input { height: 44px; border: 0; border-radius: 10px; background: var(--cell); text-align: center; font-size: 17px; letter-spacing: .2em; }
.filled { height: 50px; border: 0; border-radius: 12px; background: var(--tint); color: #fff; font-size: 17px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.filled:active { opacity: .7; }
.err { color: var(--red); font-size: 15px; min-height: 20px; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column-reverse; gap: 8px; width: min(22rem, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; font-size: 15px; line-height: 20px;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 8px 30px rgba(0, 0, 0, .15), 0 0 0 0.5px var(--sep);
  opacity: 0; transform: translateY(8px) scale(.96); transition: opacity 250ms cubic-bezier(0.23, 1, 0.32, 1), transform 250ms cubic-bezier(0.23, 1, 0.32, 1); pointer-events: auto; }
.toast.in { opacity: 1; transform: none; }
.toast .i { width: 8px; height: 8px; border-radius: 50%; background: var(--tint); flex: none; }
.toast.success .i { background: var(--green); }
.toast.error .i { background: var(--red); }

/* Paper preview */
.paperwrap { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; padding: 4px 0 8px; }
.paperwrap .paper { width: 17.5rem !important; }

@media (prefers-reduced-motion: reduce) {
  .new { animation: none; }
  .layer .sheet { transform: none !important; opacity: 0; transition: opacity 200ms ease; }
  .layer .scrim { transition: opacity 200ms ease; }
  .layer.shown .sheet, .layer.shown .scrim { opacity: 1 !important; }
  .toast { transform: none; transition: opacity 200ms ease; }
}
@media (prefers-reduced-transparency: reduce) { .bar.stuck, .toast { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { :root { --label2: rgba(60, 60, 67, .85); --sep: rgba(60, 60, 67, .6); } }
