:root {
  --bg: #060a14; --bg2: #0c1322; --card: #0f182a; --line: rgba(143,155,176,.16); --fg: #e8eef7; --muted: #8f9bb0;
  --accent: #ffb347; --accent2: #38e8ff; --ok: #5dff9b; --bad: #ff4d6d; --shadow: 0 10px 40px rgba(0,0,0,.5);
  --safe-top: env(safe-area-inset-top); --safe-bot: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f3ee; --bg2: #ffffff; --card: #ffffff; --line: rgba(30,40,60,.12); --fg: #1b2230; --muted: #6b7486;
    --accent: #e07b00; --accent2: #0a8fb0; --ok: #12a150; --bad: #d62845; --shadow: 0 10px 40px rgba(30,40,60,.18); }
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--fg); font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hidden { display: none !important; }
#app { max-width: 640px; margin: 0 auto; }

/* auth */
#auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.authbox { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.authbox form { display: flex; flex-direction: column; gap: 14px; }
.authbox label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.logo { text-align: center; margin-bottom: 18px; }
.logo .kanji { display: block; font-family: serif; font-size: 42px; color: var(--accent); }
.logo b { letter-spacing: 8px; font-size: 18px; }
.primary { background: var(--accent); color: #111; font-weight: 700; padding: 14px; border-radius: 12px; }
.hint { color: var(--muted); font-size: 14px; }
.err { color: var(--bad); min-height: 1.3em; text-align: center; font-size: 14px; }

/* top */
#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 10px) 12px 8px; background: var(--bg); }
#tabs { flex: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { white-space: nowrap; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 15px; }
#tabs button.on { background: var(--card); color: var(--fg); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#tabs button em { font-style: normal; font-size: 12px; margin-left: 6px; color: var(--accent); }
#menu-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; flex: 0 0 auto; }
#me-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #111; }

/* add */
#addwrap { position: sticky; top: calc(var(--safe-top) + 58px); z-index: 4; padding: 4px 12px 10px; background: var(--bg); }
#add-form { display: flex; gap: 8px; }
#add { font-size: 17px; padding: 14px 16px; border-radius: 14px; background: var(--card); }
#add-go { width: 52px; border-radius: 14px; background: var(--accent); color: #111; font-size: 26px; font-weight: 700; }
#suggest { list-style: none; position: absolute; left: 12px; right: 12px; top: 100%; margin-top: -4px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
#suggest li { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-top: 1px solid var(--line); }
#suggest li:first-child { border-top: 0; }
#suggest li.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); }
#suggest li small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
#suggest li .new { color: var(--accent); font-weight: 700; }
#suggest li.on-list { opacity: .5; }

/* regulars */
#regulars { display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 10px; scrollbar-width: none; }
#regulars::-webkit-scrollbar { display: none; }
#regulars:empty { display: none; }
#regulars .lbl { color: var(--muted); font-size: 12px; align-self: center; white-space: nowrap; letter-spacing: 1px; }
#regulars button { white-space: nowrap; padding: 8px 12px; border-radius: 999px; border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); font-size: 14px; }
#regulars button:active { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* list */
#list { padding: 0 12px calc(var(--safe-bot) + 40px); }
.sec { margin: 10px 0 4px; }
.sec h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding: 8px 4px 6px; }
.sec h3 span { font-size: 20px; display: inline-flex; letter-spacing: 0; }
.sec h3 em { font-style: normal; margin-left: auto; font-size: 12px; }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 0 6px 0 14px; min-height: 58px; border-top: 1px solid var(--line); transition: opacity .25s, transform .25s; }
.row:first-child { border-top: 0; }
.row .tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); flex: 0 0 auto; display: grid; place-items: center; transition: all .2s; }
.row .tx { flex: 1; min-width: 0; padding: 10px 0; }
.row .tx b { display: block; font-weight: 600; font-size: 17px; }
.row .tx small { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who { width: 22px; height: 22px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #111; display: grid; place-items: center; flex: 0 0 auto; opacity: .85; }
.row .more { width: 44px; height: 44px; color: var(--muted); font-size: 20px; flex: 0 0 auto; }
.row.going { opacity: .3; transform: translateX(14px); }
.row.going .tick, .row.done .tick { background: var(--ok); border-color: var(--ok); }
.row.going .tick::after, .row.done .tick::after { content: "✓"; color: #111; font-weight: 900; font-size: 15px; }
.row.pending b::after { content: " ·"; color: var(--accent); }
.row.done .tx b { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.trolley h3 button { margin-left: auto; color: var(--accent); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty b { display: block; font-size: 42px; margin-bottom: 8px; }
#offline { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bot) + 12px); background: var(--card); border: 1px solid var(--accent);
  color: var(--accent); padding: 8px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); z-index: 6; }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fade .2s; }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; max-height: 88dvh; overflow-y: auto; background: var(--bg2);
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(var(--safe-bot) + 22px); box-shadow: var(--shadow); animation: up .22s ease-out; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
#sheet h2 { font-size: 20px; margin-bottom: 14px; }
#sheet h4 { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
#sheet .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
#sheet .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#sheet .btns button, .sbtn { padding: 14px; border-radius: 12px; border: 1px solid var(--line); font-weight: 600; text-align: left; display: flex; gap: 10px; align-items: center; width: 100%; }
#sheet .btns button.danger { color: var(--bad); }
#sheet .btns button.primary { background: var(--accent); color: #111; border: 0; justify-content: center; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.cats button { padding: 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; text-align: left; }
.cats button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.urow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.urow .who { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #111; }
.urow div { flex: 1; } .urow small { color: var(--muted); display: block; font-size: 12px; }
.urow button { font-size: 13px; color: var(--accent); padding: 6px 8px; }
.linkbox { background: var(--bg); border: 1px dashed var(--accent); border-radius: 12px; padding: 12px; word-break: break-all; font-size: 13px; margin: 8px 0; user-select: all; }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bot) + 18px); transform: translateX(-50%) translateY(30px); opacity: 0; pointer-events: none;
  background: var(--fg); color: var(--bg); padding: 12px 8px 12px 18px; border-radius: 14px; display: flex; gap: 12px; align-items: center; font-weight: 600;
  transition: all .25s; z-index: 30; max-width: 92vw; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { color: var(--accent); font-weight: 800; padding: 6px 10px; }
#toast.err { background: var(--bad); color: #fff; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- tile view (Bring!-style) ---------- */
:root { --tile: #c2453d; --tile-fg: #fff; --rec: #1a2436; --rec-fg: #c9d2e0; }
@media (prefers-color-scheme: light) { :root { --tile: #d9493f; --rec: #e6e1d8; --rec-fg: #3b4352; } }
#list.tiles { padding-bottom: calc(var(--safe-bot) + 60px); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 14px; background: var(--tile); color: var(--tile-fg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 8px 6px; text-align: center; overflow: hidden; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; transition: transform .15s, opacity .25s, background .25s; box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.tile:active { transform: scale(.94); }
.tile .ic { font-size: 46px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.tile b { font-size: 13.5px; font-weight: 700; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.tile small { font-size: 11.5px; opacity: .85; line-height: 1.1; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .who { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 800; font-style: normal; color: #111;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--tile); }
.tile.pending { opacity: .75; }
.tile.going { background: var(--ok); transform: scale(.9); opacity: .5; }
.tile.going::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 52px; font-weight: 900; color: #fff; }
.tile.rec { background: var(--rec); color: var(--rec-fg); box-shadow: none; }
.tile.rec .ic { filter: grayscale(.35); opacity: .9; }
.tile.rec.got { outline: 2px solid color-mix(in srgb, var(--ok) 70%, transparent); outline-offset: -2px; }
.tile.rec.got::before { content: "✓"; position: absolute; top: 5px; right: 8px; font-size: 13px; font-weight: 900; color: var(--ok); }
.recent h3 button { margin-left: auto; color: var(--accent); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.more-recent { display: block; width: 100%; margin-top: 8px; padding: 12px; border-radius: 12px; border: 1px dashed var(--line); color: var(--muted); font-weight: 600; }
.ed-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; } .ed-head h2 { margin: 0 !important; }
.ed-ic { font-size: 44px; width: 64px; height: 64px; border-radius: 16px; background: var(--tile); display: grid; place-items: center; }
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icons button { height: 44px; border-radius: 10px; border: 1px solid var(--line); font-size: 28px; display: grid; place-items: center; }
.icons button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.icons input { grid-column: span 3; padding: 8px 10px; font-size: 18px; }
.icons .auto { grid-column: span 2; font-size: 14px; font-weight: 700; }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg2 button { padding: 12px; border-radius: 12px; border: 1px solid var(--line); font-weight: 700; }
.seg2 button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* pictures: Noto 3D emoji / custom icons as images, sized by the surrounding font-size like text emoji */
img.pic, span.pic { display: inline-block; width: 1em; height: 1em; vertical-align: -0.16em; object-fit: contain; -webkit-user-drag: none; user-select: none; }
span.pic.em { width: auto; line-height: 1; }
.pic.sm { width: 1.2em; height: 1.2em; vertical-align: -0.28em; }
.ed-ic img.pic { width: 48px; height: 48px; }
.icons.lib { margin-bottom: 8px; }
