:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --text: #1a1a22;
  --muted: #6b6b78;
  --border: #e2e2e8;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111116;
    --surface: #1a1a21;
    --surface-2: #23232c;
    --text: #ececf1;
    --muted: #9a9aa8;
    --border: #2e2e39;
    --accent: #818cf8;
    --accent-text: #111116;
    --accent-soft: #25264a;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
pre { background: var(--surface-2); padding: .75rem; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem max(16px, calc((100vw - 960px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.top nav { display: flex; align-items: center; gap: 1rem; }
.top nav a:not(.button) { color: var(--muted); text-decoration: none; }
.top nav a.active:not(.button) { color: var(--text); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
main.narrow { max-width: 420px; margin-top: 10vh; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 16px; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--surface-2); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.small, .button.small { padding: .3rem .7rem; font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.icon { padding: .2rem .45rem; font-size: .85rem; line-height: 1; }

label { display: block; font-weight: 500; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=datetime-local], textarea, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .35rem 0; }
.check input { margin: 0; width: 16px; height: 16px; }
.field + .field { margin-top: 14px; }
.counter { float: right; font-weight: 400; font-size: .8rem; color: var(--muted); }
.counter.over { color: var(--bad); font-weight: 600; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .3rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; border-radius: 0; padding: .6rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.post-list { display: grid; gap: 12px; }
.post-row { display: flex; gap: 14px; align-items: flex-start; }
.post-row .thumb { width: 72px; height: 90px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.post-row .body { flex: 1; min-width: 0; }
.post-row .text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.post-row .meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .4rem; }
.post-row .actions { display: flex; flex-direction: column; gap: .4rem; }

.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; }
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--bad); }
.badge.warn { color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.composer { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.composer aside { position: sticky; top: 80px; }
@media (max-width: 800px) { .composer { grid-template-columns: 1fr; } .composer aside { position: static; } }

.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.photo { position: relative; border-radius: 8px; overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 5; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .n { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; border-radius: 6px; padding: 0 .4rem; }
.photo .tools { position: absolute; bottom: 6px; left: 6px; right: 6px; display: flex; justify-content: space-between; }
.photo .tools button { background: rgba(0,0,0,.6); color: #fff; border: 0; }
.photo .warn { position: absolute; top: 6px; right: 6px; background: var(--warn); color: #000; font-size: .7rem; border-radius: 6px; padding: 0 .35rem; }
.photo.uploading { opacity: .5; }

.platforms { display: flex; flex-wrap: wrap; gap: .5rem; }
.platform-toggle { display: flex; align-items: center; gap: .45rem; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; font-weight: 500; margin: 0; }
.platform-toggle input { margin: 0; }
.platform-toggle.on { border-color: var(--accent); background: var(--accent-soft); }
.platform-toggle.off { opacity: .55; cursor: not-allowed; }

.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.section > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.section > summary::-webkit-details-marker { display: none; }
.section[open] > summary { margin-bottom: 12px; }
.creator { display: flex; align-items: center; gap: .6rem; margin-bottom: 12px; }
.creator img { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); }
.consent { font-size: .82rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .1rem .55rem; font-size: .85rem; }

.problems { border: 1px solid var(--bad); border-radius: 8px; padding: .6rem .8rem; color: var(--bad); font-size: .9rem; }
.problems ul { margin: .3rem 0 0; padding-left: 1.1rem; }

.preview { white-space: pre-wrap; font-size: .88rem; background: var(--surface-2); border-radius: 8px; padding: .6rem .7rem; max-height: 220px; overflow: auto; }

.account { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.account + .account { border-top: 1px solid var(--border); }
.account .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); flex: none; object-fit: cover; }
.account .who { flex: 1; min-width: 0; }

.key-reveal { background: var(--accent-soft); border-radius: 8px; padding: .75rem; margin: .75rem 0; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

.legal { max-width: 720px; }
.legal h2 { margin-top: 1.75rem; }
.legal li { margin: .35rem 0; }
