:root {
  --bg: #eef3fb;
  --card: #ffffff;
  --text: #1b2333;
  --muted: #5d6980;
  --border: #dde2ec;
  --accent: #3a6df0;
  --accent-text: #ffffff;
  --danger: #c4373b;
  --ok: #1d8a4d;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d;
    --card: #1a202b;
    --text: #e7ebf3;
    --muted: #9aa5b9;
    --border: #2b3342;
    --accent: #6b93ff;
    --accent-text: #0b0f17;
    --danger: #ff7b7f;
    --ok: #5bd18f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); }

header.top {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; height: 58px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
header.top .brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; text-decoration: none; color: var(--text);
}
header.top .brand svg { width: 30px; height: 21px; color: var(--accent); }
header.top nav { display: flex; gap: 6px; align-items: center; font-size: .95rem; }
.main-nav > a { white-space: nowrap; }
.main-nav > a:not(.button) {
  color: var(--text); text-decoration: none; padding: 7px 12px; border-radius: 999px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.main-nav > a:not(.button):hover { background: var(--bg); }
.main-nav > a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center;
}
.write-btn { margin-left: 4px; }
.me-menu { position: relative; margin-left: 4px; }
.me-menu summary { list-style: none; cursor: pointer; display: flex; border-radius: 50%; }
.me-menu summary::-webkit-details-marker { display: none; }
.me-menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.me-menu .menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 220px; z-index: 10;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .18); display: flex; flex-direction: column;
}
.me-menu .menu > a, .me-menu .menu > button {
  padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; text-align: left; font-weight: 500;
}
.me-menu .menu > a:hover, .me-menu .menu > button:hover { background: var(--bg); }
.menu-who { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
@media (max-width: 640px) {
  header.top { padding: 0 10px; }
  header.top .brand span { display: none; }
  .main-nav > a:not(.button) { padding: 7px 8px; }
  .write-btn { padding: 5px 12px; font-size: 1.1rem; }
  .write-label { display: none; }
}

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

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}
.card h1, .card h2 { margin-top: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }

label { display: block; font-weight: 600; font-size: .92rem; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=number] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.small { padding: 5px 12px; font-size: .85rem; }
button.link { border: none; background: none; padding: 0; color: var(--accent); font-weight: 400; }
button:disabled { opacity: .55; cursor: default; }
.wide { width: 100%; }

.stack > * + * { margin-top: 12px; }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.message { min-height: 1.5em; font-size: .92rem; margin-top: 12px; }
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.list li:first-child { border-top: none; }
.list .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.pending { color: var(--accent); border-color: var(--accent); }

.invite-result { word-break: break-all; background: var(--bg); padding: 12px; border-radius: 10px; margin-top: 12px; font-family: ui-monospace, monospace; font-size: .85rem; }
[hidden] { display: none !important; }
.spaced { margin-top: 24px; }

.small { font-size: .85rem; }
a.button { text-decoration: none; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.small { padding: 5px 12px; font-size: .85rem; }
textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; line-height: 1.55; }
select { width: auto; }
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---- Avatars ---- */
.avatar { display: inline-block; border-radius: 50%; object-fit: cover; flex: none; background: var(--border); }
.avatar.s32 { width: 32px; height: 32px; font-size: .9rem; }
.avatar.s36 { width: 36px; height: 36px; font-size: 1rem; }
.avatar.s40 { width: 40px; height: 40px; font-size: 1.05rem; }
.avatar.s48 { width: 48px; height: 48px; font-size: 1.2rem; }
.avatar.s56 { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar.s96 { width: 96px; height: 96px; font-size: 2.2rem; }
.avatar.s160 { width: 160px; height: 160px; font-size: 4rem; }
.avatar.initial { display: inline-grid; place-items: center; color: #fff; font-weight: 800; font-family: system-ui, sans-serif; line-height: 1; }
.hue0 { background: linear-gradient(135deg, #5b8cff, #3a5bd9); }
.hue1 { background: linear-gradient(135deg, #ff7eb3, #e2457f); }
.hue2 { background: linear-gradient(135deg, #34d399, #0f9f6e); }
.hue3 { background: linear-gradient(135deg, #fbbf24, #e8870b); }
.hue4 { background: linear-gradient(135deg, #a78bfa, #7347e8); }
.hue5 { background: linear-gradient(135deg, #22d3ee, #0b8fb3); }
.hue6 { background: linear-gradient(135deg, #fb7185, #d63a4b); }
.hue7 { background: linear-gradient(135deg, #94a3b8, #56657c); }

/* ---- People lists ---- */
.people-list { list-style: none; padding: 0; margin: 0 0 10px; }
.people-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.person { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.person > span { display: flex; flex-direction: column; min-width: 0; }
.person > span > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.big strong { font-size: 1.1rem; }
.people-list .actions { display: flex; gap: 6px; }

/* ---- Home ---- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.home-side { position: sticky; top: 78px; }
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-side { position: static; order: -1; }
  .home-side .card:not(.me-card):not(#requests-card) { display: none; }
}
.feed-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.greeting { margin: 0; font-size: 1.8rem; letter-spacing: -.02em; }
.tabs { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.tabs button { border: none; background: none; padding: 6px 14px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.feed .card { padding: 18px 20px; margin-bottom: 14px; }
.post-by { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.post-by .who { font-weight: 700; color: var(--text); text-decoration: none; }
.post-by .small { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
a.quiet { color: inherit; text-decoration: none; }
.mood { font-style: italic; }
.pill.lock { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.post-title { margin: 0 0 6px; font-size: 1.25rem; line-height: 1.25; }
.post-title a { color: var(--text); text-decoration: none; }
.excerpt { margin: 0 0 10px; color: color-mix(in srgb, var(--text) 85%, var(--muted)); overflow-wrap: anywhere; }
.thumb img { display: block; width: 100%; max-height: 340px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }
.post-foot { display: flex; justify-content: space-between; font-size: .9rem; }
.post-foot a { text-decoration: none; }
.empty { text-align: center; padding: 36px 20px; }

/* ---- Dialog ---- */
.site-dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--card); color: var(--text); width: min(440px, calc(100vw - 32px)); max-height: 80vh; padding: 16px 20px; }
.site-dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; }
.dialog-head button { border: none; padding: 4px 10px; }

/* ---- Writer ---- */
.writer h1 { margin-bottom: 12px; }
.title-input { font-size: 1.4rem !important; font-weight: 700; border: none !important; background: transparent !important; padding: 6px 0 !important; }
.title-input:focus { outline: none; border-bottom: 2px solid var(--accent) !important; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.toolbar > button, .tool-upload { padding: 5px 12px; font-size: .9rem; min-width: 38px; }
.tool-upload { font-weight: 600; }
.toolbar .spacer { flex: 1; }
.small-tabs button { padding: 4px 12px; font-size: .85rem; }
.preview-box { min-height: 300px; border: 1px dashed var(--border); border-radius: 10px; padding: 14px; }
.preview-box.mp-rich { --mp-radius: 12px; --mp-accent: var(--accent); --mp-soft: var(--bg); }
.visibility { border: none; padding: 0; margin: 14px 0 0; }
.visibility legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.visibility .check { margin: 6px 0; font-size: .98rem; }

/* ---- Top 8 editor ---- */
.top8 { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .top8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); min-width: 0;
}
.empty-slot { border-style: dashed; justify-content: center; min-height: 128px; }
.slot-num { position: absolute; top: 6px; left: 8px; font-size: .75rem; font-weight: 800; color: var(--muted); }
.slot-name { font-size: .85rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-tools { display: flex; gap: 4px; }
.slot-tools button { padding: 2px 8px; }

/* ---- Customize ---- */
main.custom-main { max-width: 1320px; }
.custom-grid { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 24px; align-items: start; }
.custom-controls h1 { margin-top: 0; }
.custom-controls .card { padding: 20px; }
.custom-controls h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.custom-preview { position: sticky; top: 78px; }
.preview-frame-wrap { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--card); box-shadow: 0 10px 30px rgb(0 0 0 / .1); }
.preview-label { padding: 8px 14px; font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--border); }
#preview { display: block; width: 100%; height: calc(100vh - 150px); border: 0; background: #fff; }
@media (max-width: 960px) {
  .custom-grid { grid-template-columns: 1fr; }
  .custom-preview { position: static; order: -1; }
  #preview { height: 60vh; }
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.two .check { margin-bottom: 10px; }
.avatar-row, .bg-row { display: flex; gap: 16px; align-items: center; }
.avatar-row .stack, .bg-row .stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.bg-thumb { width: 120px; height: 80px; border-radius: 10px; border: 1px dashed var(--border); display: grid; place-items: center; overflow: hidden; flex: none; }
.bg-thumb img { width: 100%; height: 100%; object-fit: cover; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.theme-card { flex-direction: column; padding: 8px; border-radius: 14px; gap: 6px; font-weight: 600; }
.theme-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch {
  position: relative; display: block; width: 100%; height: 68px; border-radius: 8px;
  background: var(--sw-bg); overflow: hidden; border: 1px solid rgb(0 0 0 / .08);
}
.swatch::before {
  content: ""; position: absolute; inset: 12px 14px 0; background: var(--sw-panel);
  border-radius: var(--sw-radius) var(--sw-radius) 0 0;
}
.sw-head { position: absolute; left: 14px; right: 14px; top: 12px; height: 12px; background: var(--sw-head); border-radius: var(--sw-radius) var(--sw-radius) 0 0; }
.sw-line { position: absolute; left: 22px; right: 30px; top: 34px; height: 5px; border-radius: 3px; background: var(--sw-text); opacity: .7; }
.sw-line.short { top: 45px; right: 52px; }
.sw-dot { position: absolute; right: 22px; top: 42px; width: 14px; height: 14px; border-radius: 50%; background: var(--sw-accent); }
.theme-name { font-size: .88rem; }

.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.color-row { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 500; }
.color-row input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; flex: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.5; tab-size: 2; }
.css-help { margin-top: 10px; }
.css-help summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.css-help ul { padding-left: 18px; }
.css-help li { margin: 4px 0; }
.css-help [data-snippet] { margin: 4px 4px 0 0; }

.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.upload { margin: 0; }
.upload-img { padding: 0; border-radius: 10px; overflow: hidden; width: 100%; aspect-ratio: 1; }
.upload-img img { width: 100%; height: 100%; object-fit: cover; }
.upload figcaption { font-size: .75rem; color: var(--muted); margin-top: 4px; }

.save-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 16px; margin: 0 -4px; border: 1px solid var(--border); border-radius: 16px 16px 0 0;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(8px);
}
.save-bar .message { margin: 0 auto 0 0; }
