:root {
  --bg: #fff; --fg: #0c0c0d; --muted: #737373; --line: #dbdbdb; --soft: #efefef; --soft2: #f6f6f6;
  --accent: #0095f6; --accent-fg: #fff; --danger: #ed4956; --tag: #00376b; --shade: rgba(0, 0, 0, .45);
  --radius: 10px; --gap: 2px; --tile: .75;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --fg: #f5f5f5; --muted: #a8a8a8; --line: #363636; --soft: #262626; --soft2: #121212;
    --tag: #e0f1ff; --shade: rgba(0, 0, 0, .65); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --fg: #f5f5f5; --muted: #a8a8a8; --line: #363636; --soft: #262626; --soft2: #121212;
  --tag: #e0f1ff; --shade: rgba(0, 0, 0, .65); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 var(--font);
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic .fill, .ic circle[r="1.3"] { fill: currentColor; stroke: none; }
.ic.sm { width: 18px; height: 18px; }
.ic.xs { width: 14px; height: 14px; stroke-width: 2.2; }
.ic.xl { width: 48px; height: 48px; stroke-width: 1.4; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.8) blur(14px);
  border-bottom: 1px solid var(--line);
}
.acct-btn { display: flex; align-items: center; gap: 4px; border: 0; background: none; font-size: 20px; font-weight: 700; padding: 6px 4px; min-width: 0; }
.acct-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; gap: 2px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 50%; }
.icon-btn:not(:disabled):hover { background: var(--soft2); }

.wrap { max-width: 640px; margin: 0 auto; }

/* profile */
.profile {
  display: grid; grid-template-columns: auto 1fr; gap: 12px 20px; align-items: center; padding: 16px 16px 12px;
}
.p-avatar { border: 0; padding: 0; background: none; border-radius: 50%; }
.avatar { width: 86px; height: 86px; border-radius: 50%; object-fit: cover; display: block; background: var(--soft); }
.avatar.blank { display: grid; place-items: center; font-size: 34px; font-weight: 600; color: var(--muted); }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.p-user { font-size: 18px; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.p-stats { display: flex; gap: 16px; }
.p-stats span { display: flex; flex-direction: column; line-height: 1.25; font-size: 13px; }
.p-stats b { font-weight: 600; font-size: 16px; }
.p-bio { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 1px; white-space: pre-line; overflow-wrap: anywhere; }
.p-bio:empty { display: none; }
.p-link { color: var(--tag); font-weight: 600; }
.profile .btn.wide { grid-column: 1 / -1; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 16px;
  border: 0; border-radius: 8px; background: var(--soft); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:not(:disabled):hover { filter: brightness(.96); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.ghost { background: none; }
.btn.ghost:not(:disabled):hover { background: var(--soft2); filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.danger-text { color: var(--danger); }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.wrap-row { flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding: 0 8px; position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 10; background: var(--bg); }
.tab { display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 12px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: .02em; border-top: 1px solid transparent; margin-top: -1px; }
.tab[aria-selected="true"] { color: var(--fg); border-top-color: var(--fg); }
.tabs-sp { flex: 1; }
.chip-btn { display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 16px; background: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip-btn[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); user-select: none; -webkit-user-select: none; }
.grid.is-empty { display: block; }
.tile {
  position: relative; aspect-ratio: var(--tile); overflow: hidden; background: var(--soft); outline-offset: -2px;
  -webkit-touch-callout: none; touch-action: manipulation;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile:hover img { filter: brightness(.94); }
.b-tr { position: absolute; top: 6px; right: 6px; color: #fff; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .55)); display: flex; }
.b-tr .ic { stroke-width: 2; }
.plan {
  position: absolute; left: 5px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; max-width: calc(100% - 10px);
  padding: 2px 6px 2px 4px; border-radius: 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(6px);
}
.plan.inline { position: static; background: var(--soft); color: var(--muted); margin-left: auto; backdrop-filter: none; }
body.clean .plan, body.clean .tile .b-tr.hide-clean { display: none; }
body.squint .grid img { filter: blur(7px) saturate(1.1); }
body.squint .grid .tile { overflow: hidden; }
.sort-ghost { opacity: .25; }
.chosen { box-shadow: inset 0 0 0 3px var(--accent); }
.dragging { opacity: .95 !important; transform: scale(1.06); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); z-index: 100; }
body.dragging-on { cursor: grabbing; }
.missing { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, var(--soft), var(--soft) 6px, var(--soft2) 6px, var(--soft2) 12px); }

.empty { text-align: center; padding: 36px 24px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h2 { margin: 8px 0 0; font-size: 22px; }
.empty p { margin: 0; max-width: 34ch; }
.empty .btn { min-width: 240px; }
.empty .btn.primary { margin-top: 10px; min-height: 44px; }
.empty-art { display: grid; grid-template-columns: repeat(3, 34px); gap: 3px; }
.empty-art i { aspect-ratio: .75; border-radius: 3px; background: var(--soft); }
.empty-art i:nth-child(1), .empty-art i:nth-child(5) { background: color-mix(in srgb, var(--accent) 30%, var(--soft)); }

.ig-empty { width: 100%; max-width: 340px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; text-align: left; }
.ig-field { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft2); padding: 0 4px 0 12px; }
.ig-field:focus-within { border-color: var(--muted); background: var(--bg); }
.ig-field > span { color: var(--muted); font-size: 16px; }
.ig-field input { border: 0 !important; background: none !important; padding: 11px 0; min-width: 0; flex: 1; }
.ig-field .btn { flex: none; }
.ig-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--soft2); border: 1px solid var(--line); }
.ig-card p, .ig-pub p { margin: 0; }
.ig-pub { display: flex; flex-direction: column; gap: 10px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.nag { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--soft2); border: 1px solid var(--line); font-size: 13px; }
.nag span { flex: 1 1 200px; }

/* feed */
.feed { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.fpost { cursor: pointer; }
.fpost header { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.fmedia { position: relative; width: 100%; background: var(--soft); overflow: hidden; }
.slides { display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; height: 100%; scroll-snap-align: start; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dots { display: flex; justify-content: center; gap: 4px; padding: 8px 0 0; min-height: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.fcap { margin: 6px 12px 0; white-space: normal; overflow-wrap: anywhere; }
.tag { color: var(--tag); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 0; margin: 0; }

/* add button */
.fab {
  position: fixed; z-index: 30; right: max(16px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; height: 54px; padding: 0 22px 0 18px; border: 0; border-radius: 27px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.fab:active { transform: scale(.97); }
body.modal-on .fab { display: none; }

/* drop overlay */
.drop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, var(--bg) 70%); border: 3px dashed var(--accent); pointer-events: none; text-align: center; font-weight: 600; font-size: 17px; }

/* toast */
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); width: max-content; padding: 11px 12px 11px 16px;
  border-radius: 12px; background: #262626; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.t-act { border: 0; background: none; color: #4cb5f9; font-weight: 700; padding: 6px 4px; white-space: nowrap; }
body.modal-on .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* sheets (dialog) */
.sheet {
  border: 0; padding: 0; margin: auto; width: min(560px, 100% - 32px); max-height: min(92vh, 900px);
  border-radius: 16px; background: var(--bg); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  overflow: auto; overscroll-behavior: contain;
}
.sheet[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.sheet::backdrop { background: var(--shade); }
@keyframes pop { from { opacity: 0; transform: translateY(12px); } }
.sheet.small { width: min(400px, 100% - 32px); }
.editor-sheet { width: min(980px, 100% - 32px); }
.sh-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px 12px 6px 6px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.sh-head > .sh-title:first-child { padding-left: 12px; }
body.modal-on { overflow: hidden; }
.sh-title { font-weight: 700; font-size: 16px; padding: 0 4px; }
.sh-head .sp { flex: 1; }
.sh-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.confirm-q { margin: 4px 0 8px; font-size: 16px; }

/* editor */
.editor { display: grid; grid-template-columns: 1fr; }
.ed-left, .ed-right { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ed-right { border-top: 1px solid var(--line); }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--soft); align-self: flex-start; }
.seg.full { display: flex; align-self: stretch; }
.seg button { flex: 1; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 4px 14px; border: 0; border-radius: 8px; background: none; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.neigh { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); width: 100%; max-width: 420px; margin: 0 auto; }
.sheet:focus { outline: none; }
.n-tile { position: relative; aspect-ratio: var(--tile); overflow: hidden; background: var(--soft); opacity: .55; cursor: pointer; transition: opacity .15s; }
.n-tile:hover { opacity: .8; }
.n-tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; user-select: none; -webkit-user-select: none; }
.n-tile.me { opacity: 1; cursor: default; box-shadow: 0 0 0 2px var(--accent); z-index: 1; touch-action: none; }
.n-tile.me.can-x { cursor: ew-resize; } .n-tile.me.can-y { cursor: ns-resize; }
.n-tile.me.grab { cursor: grabbing; }
.hint { margin: 0; font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hint:empty { display: none; }
.in-editor { cursor: default; }
.in-editor .fmedia { border-radius: 4px; max-height: 62vh; margin: 0 auto; }
.strip-wrap { display: flex; flex-direction: column; gap: 6px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.s-item { position: relative; flex: none; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--soft); cursor: grab; touch-action: pan-x; }
.s-item img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.s-cover { position: absolute; left: 4px; top: 4px; min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.s-x { position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; padding: 0; }
.s-add { flex: none; width: 64px; height: 64px; border: 1.5px dashed var(--line); border-radius: 8px; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
textarea, input:not([type=checkbox]) {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--soft2); padding: 10px 12px; font-size: 16px; resize: none;
}
textarea:focus, input:focus { outline: none; border-color: var(--muted); background: var(--bg); }
.counts { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: -4px; }
.counts .over { color: var(--danger); font-weight: 700; }
.field-row { display: flex; flex-direction: column; gap: 6px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions .btn.primary { min-height: 48px; }
.actions { padding-bottom: 12px; }

/* forms */
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form .row.two > label { flex: 1; min-width: 0; }
.av-row { display: flex; align-items: center; gap: 14px; }
.acct-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.acct { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 10px; background: none; text-align: left; }
.acct:hover, .acct.on { background: var(--soft2); }
.acct span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.acct b { overflow: hidden; text-overflow: ellipsis; }
.acct small { color: var(--muted); }
.menu { gap: 4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; width: 100%; }
.menu p { margin: 4px 0; display: flex; gap: 6px; align-items: flex-start; }
.m-item { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border: 0; border-radius: 10px; background: none; text-align: left; font-weight: 500; }
.m-item:hover { background: var(--soft2); }
.m-item span { display: flex; flex-direction: column; }
.m-item small { color: var(--muted); font-weight: 400; font-size: 12px; }

@media (min-width: 760px) {
  .profile { grid-template-columns: auto 1fr; padding: 28px 24px 20px; gap: 14px 40px; }
  .avatar { width: 120px; height: 120px; }
  .profile .p-avatar { grid-row: span 3; }
  .p-bio, .profile .btn.wide { grid-column: 2; }
  .profile .btn.wide { justify-self: start; width: auto; }
  .p-user { font-size: 20px; }
  .editor { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); }
  .editor-sheet { max-height: min(90vh, 940px); overflow: hidden; }
  .editor-sheet .editor { overflow: hidden; min-height: 0; flex: 1; }
  .ed-left, .ed-right { overflow-y: auto; overscroll-behavior: contain; }
  .ed-right { border-top: 0; border-left: 1px solid var(--line); }
  .fab { right: max(24px, calc(50% - 320px - 140px)); }
}

/* phones: sheets come up from the bottom, the editor is full screen */
@media (max-width: 759px) {
  .sheet { width: 100%; max-width: none; margin: auto 0 0; max-height: 92vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet[open] { animation: up .22s ease-out; }
  .sheet.small { width: 100%; }
  .editor-sheet { height: 100%; max-height: 100%; border-radius: 0; margin: 0; padding-top: env(safe-area-inset-top); }
  .sh-head { top: 0; padding-top: 14px; }
  .sh-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--line); }
  .sheet { transition: transform .18s ease-out; }
  .sheet.pulling { transition: none; }
  .chip-btn span { display: none; }
  .chip-btn { width: 36px; padding: 0; justify-content: center; }
  .tab { padding: 0 10px; }
  .in-editor .fmedia { max-height: 56vh; }
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* privacy page */
.doc-wrap { padding: 24px 16px 48px; max-width: 680px; line-height: 1.55; }
.doc-wrap h1 { font-size: 26px; } .doc-wrap h2 { font-size: 17px; margin-top: 26px; }
.doc-wrap a { color: var(--accent); }
body.doc { padding-bottom: 0; }
