:root {
  --green: #1f6f43; --green-d: #17573a; --ink: #1d2721; --muted: #66726b; --line: #dfe5e1;
  --bg: #f3f6f4; --card: #fff; --soft: #eaf2ed; --danger: #a1262d; --warn: #fff5e6;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(20,40,30,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e6ece8; --muted: #9aa8a0; --line: #2c3a32; --bg: #121815; --card: #1a221e; --soft: #1f2d25; --warn: #3a2e1a;
    --shadow: 0 1px 2px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--green); }
@media (prefers-color-scheme: dark) { a { color: #6fc497; } }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.dim { opacity: .55; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  background: var(--green); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 1.1rem; white-space: nowrap; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #fff; color: var(--green); font-weight: 800; }
.mark.big { width: 56px; height: 56px; font-size: 1.8rem; border-radius: 14px; background: var(--green); color: #fff; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { color: #e3f1e9; text-decoration: none; padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.top nav a:hover { background: rgba(255,255,255,.12); }
.top nav a.on { background: rgba(255,255,255,.2); color: #fff; }
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.me summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.22); font-weight: 700; }
.me .menu { position: absolute; right: 0; top: 42px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; }
.me .menu a, .me .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.me .menu a:hover, .me .menu button:hover { background: var(--soft); }
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 12px; }
  .top nav { order: 3; flex-basis: 100%; }
  .me .who { display: none; }
  .me { margin-left: auto; }
}

/* Cards, forms, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 480px; margin: 40px auto; }
label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .92rem; }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=search], input[type=number], select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: transparent; }
input.short { max-width: 140px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 700; margin-bottom: 8px; font-size: .92rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0 0 8px; }
label.check.strong { font-weight: 600; }
label.check input { width: 17px; height: 17px; accent-color: var(--green); flex: none; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.full { width: 100%; padding: 12px; font-size: 1rem; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
form.inline { display: inline; }
.error { background: color-mix(in srgb, var(--danger) 12%, var(--card)); color: var(--danger); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-weight: 600; }
.flash { background: var(--soft); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }
.hint { color: var(--muted); font-size: .88rem; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Sign in */
.auth { max-width: 400px; margin: 6vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { margin: 12px 0 2px; font-weight: 500; }
.auth-brand p { color: var(--muted); margin: 0; }
.auth .card h1 { font-size: 1.3rem; }

/* Home tiles */
.home-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.home-head p { margin: 0; }
.home-head input[type=search] { max-width: 280px; margin: 0; }
.group h2 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 18px 12px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 6px 10px; border-radius: 16px;
  text-decoration: none; color: var(--ink); text-align: center; transition: background .15s; }
.tile:hover { background: var(--soft); }
.tile:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.tile .icon { width: 76px; height: 76px; border-radius: 22px; font-size: 2.1rem; }
.tile:hover .icon { filter: brightness(1.08); }
.tile .txt { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.tile strong { font-size: .95rem; font-weight: 600; line-height: 1.25; }
.tile .tag, .tile .new-badge { margin-top: 5px; align-self: center; }
@media (max-width: 480px) {
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 14px 6px; }
  .tile .icon { width: 64px; height: 64px; border-radius: 18px; font-size: 1.8rem; }
  .tile strong { font-size: .85rem; }
}
.icon { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 11px; background: var(--c); color: #fff; font-size: 1.35rem; font-weight: 700; }
.icon.sm { width: 34px; height: 34px; font-size: 1rem; border-radius: 8px; }
.icon.xs { width: 22px; height: 22px; font-size: .75rem; border-radius: 6px; display: inline-grid; }
.tag { font-size: .7rem; background: var(--soft); color: var(--muted); padding: 2px 7px; border-radius: 99px; }
.empty { padding: 40px 20px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--soft); }
tr:last-child td { border-bottom: 0; }
tr.warn td { background: var(--warn); }
td a.small { word-break: break-all; }

/* Admin forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 36px; }
.form-grid .actions { grid-column: 1 / -1; display: flex; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 16px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.picklist { max-height: 380px; overflow: auto; padding: 4px 2px; }
.off .picklist, #apps-box.off label.check { opacity: .4; pointer-events: none; }
.admin-note { display: none; } #apps-box.off .admin-note { display: block; font-weight: 600; color: var(--ink); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { margin: 0; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; }
.swatch span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--c); border: 3px solid transparent; }
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--card) inset; }
.swatch.custom input { position: static; opacity: 1; width: 30px; height: 30px; padding: 0; border: 0; background: none; }
.swatch.custom input:disabled { opacity: .35; }
.swatch.custom span { display: none; }
.danger-zone { margin-top: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.notice { border-left: 5px solid var(--green); margin: 14px 0 20px; }
.notice h2 { margin-top: 0; }
.creds { display: flex; gap: 22px; flex-wrap: wrap; margin: 12px 0; }
.creds div { display: flex; flex-direction: column; }
.creds code { font-size: 1.1rem; background: var(--soft); padding: 4px 10px; border-radius: 6px; margin-top: 3px; user-select: all; }

.new-badge { display: inline-block; align-self: flex-start; font-size: .7rem; font-weight: 700; background: #e8a33a; color: #3a2600; padding: 2px 8px; border-radius: 99px; margin-top: 6px; vertical-align: middle; }
td .new-badge { margin-top: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 6px; }
.pick { width: 40px; height: 40px; font-size: 1.3rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.pick:hover { border-color: var(--green); }
.pick.on { border: 2px solid var(--green); background: var(--soft); }
.warn-text { color: #a8641a; }
/* Get the app */
.install { max-width: 900px; margin: 0 auto; }
.install-hero { display: flex; gap: 20px; align-items: center; margin: 8px 0 20px; }
.install-hero img { border-radius: 22px; flex: none; }
.install-hero h1 { margin: 0 0 4px; }
.install-main { text-align: center; padding: 26px 20px; margin-bottom: 18px; }
.install-main h2 { margin: 0 0 6px; }
.btn.big { padding: 14px 28px; font-size: 1.05rem; margin-top: 8px; }
.platforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.plat h3 { margin: 0 0 8px; }
.plat ol { padding-left: 20px; margin: 0 0 8px; }
.plat li { margin-bottom: 6px; }
.plat.mine { border: 2px solid var(--green); }
.plat.mine h3::after { content: 'This device'; font-size: .7rem; font-weight: 700; background: var(--green); color: #fff; padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: middle; }
.plat .or { color: var(--muted); font-size: .85rem; margin: 6px 0; }
.kbd { display: inline-block; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: var(--bg); font-size: .9em; }
@media (max-width: 560px) { .install-hero { flex-direction: column; text-align: center; } }
.mark-img { width: 32px; height: 32px; border-radius: 8px; display: block; box-shadow: 0 0 0 1.5px rgba(255,255,255,.7); }
.mark-img.big { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto; box-shadow: none; }

/* ---------- Phones & tablets ---------- */
/* 16px text in boxes stops iPhones zooming in when you tap a field */
input, select, textarea { font-size: 16px !important; }
.top { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
main { padding-bottom: max(60px, env(safe-area-inset-bottom)); }
@media (max-width: 720px) {
  main { padding: 18px 14px 60px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  /* Menu: four equal tabs that always fit */
  .top nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; overflow: visible; }
  .top nav a { text-align: center; padding: 8px 4px; font-size: .88rem; }
  /* Bigger tap targets */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .btn.sm { min-height: 40px; padding: 8px 14px; font-size: .9rem; }
  label.check { min-height: 40px; margin: 0; padding: 4px 0; }
  label.check input { width: 22px; height: 22px; }
  .hint a, p.center > a, p > a[href^="/admin"], .small a { display: inline-block; padding: 8px 2px; }
  .bar { align-items: flex-start; }
  .btns { width: 100%; }
  .btns .btn, .btns form, .btns form .btn { flex: 1; }
  .form-grid .actions { position: sticky; bottom: 0; background: var(--card); margin: 0 -16px -16px; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-radius: 0 0 var(--radius) var(--radius); }
  .form-grid .actions .btn { flex: 1; }
  .danger-zone { flex-direction: column; align-items: stretch; }
  .swatch span, .swatch.custom input { width: 38px; height: 38px; }
  .pick { width: 46px; height: 46px; }
  .creds { gap: 12px; }
  .creds code { font-size: 1rem; word-break: break-all; }
  /* Tables become stacked cards */
  .stack table, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack thead { display: none; }
  .stack tr { padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  .stack tr:last-child { border-bottom: 0; }
  .stack td { border: 0; padding: 3px 0; display: flex; gap: 10px; align-items: baseline; }
  .stack td[data-label]:not([data-label=""])::before { content: attr(data-label); flex: 0 0 96px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .stack td[data-label=""] { display: block; }
  .stack td.right { text-align: left; padding-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
  .stack td.right .btn, .stack td.right form { flex: 1; }
  .stack td.right form .btn { width: 100%; }
  .stack td .icon.sm { margin-bottom: 4px; }
  .stack td a.small { word-break: break-all; }
}
@media (max-width: 360px) {
  .top nav a { font-size: .8rem; padding: 8px 2px; }
  .brand span b + * , .brand { font-size: 1rem; }
}
button.link { padding: 10px; min-height: 40px; }
@media (max-width: 720px) {
  .stack td { display: block; position: relative; padding: 4px 0 4px 106px; min-height: 26px; }
  .stack td[data-label]:not([data-label=""])::before { position: absolute; left: 0; top: 6px; width: 96px; }
  .stack td[data-label=""] { padding-left: 0; }
  .stack td.right { padding-left: 0; display: flex; }
}
/* iPhone add-to-home-screen guide */
.ios-guide h2 { margin: 0 0 4px; font-size: 1.25rem; }
.ios-steps { list-style: none; padding: 0; margin: 16px 0 4px; counter-reset: s; }
.ios-steps li { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); counter-increment: s; }
.ios-steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .85rem; }
.step-ico { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--soft); color: #0a84ff; display: grid; place-items: center; }
.notice-box { background: var(--warn); border-radius: 10px; padding: 12px; margin-top: 12px; }
.notice-box .btn { margin-top: 10px; }
.share-arrow { position: fixed; left: 50%; bottom: calc(8px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; animation: nudge 1.1s ease-in-out infinite; pointer-events: none;
  background: var(--green); color: #fff; font-weight: 700; font-size: .9rem; border-radius: 99px; padding: 6px 14px 6px 16px; display: flex; white-space: nowrap; align-items: center; gap: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.share-arrow[hidden] { display: none !important; }
body.ios-mode main { padding-bottom: 110px; }
.ios-guide .card { margin-top: 4px; }
.ios-guide .notice-box { margin: 12px 0 4px; }
@keyframes nudge { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 10px); } }
@media (prefers-reduced-motion: reduce) { .share-arrow { animation: none; } }
[hidden] { display: none !important; }
