:root {
  --accent: #c2185b;
  --accent-text: #fff;
  --bg: #dde6f0;
  --surface: #fff;
  --text: #1b1f24;
  --muted: #7a8593;
  --line: rgba(0, 0, 0, 0.08);
  --bubble-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17212b;
    --surface: #222e3a;
    --text: #eef2f6;
    --muted: #8b98a6;
    --line: rgba(255, 255, 255, 0.08);
    --bubble-shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23000' stroke-opacity='.05' stroke-width='1.6'%3E%3Ccircle cx='28' cy='30' r='10'/%3E%3Cpath d='M18 30h20M28 20c4 6 4 14 0 20'/%3E%3Cpath d='M112 24l3 7 7 3-7 3-3 7-3-7-7-3 7-3z'/%3E%3Ccircle cx='120' cy='112' r='14'/%3E%3Cellipse cx='120' cy='112' rx='24' ry='6' transform='rotate(-20 120 112)'/%3E%3Cpath d='M40 118l2 5 5 2-5 2-2 5-2-5-5-2 5-2z'/%3E%3Ccircle cx='76' cy='76' r='2.5'/%3E%3Ccircle cx='146' cy='60' r='2'/%3E%3Ccircle cx='70' cy='146' r='2'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */
.topbar {
  flex: none;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  z-index: 2;
}
.topbar__title { padding: 12px 16px 8px; text-align: center; }
.topbar__name { font-weight: 700; font-size: 17px; }
.topbar__sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub:empty { display: none; }

.links {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}
.links::-webkit-scrollbar { display: none; }
.link-btn {
  flex: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.link-btn:active, .link-btn:hover { background: var(--accent); color: var(--accent-text); }

.banner {
  padding: 8px 16px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- feed ---------- */
.feed {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 12px 16px;
  -webkit-overflow-scrolling: touch;
}

.post {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
  box-shadow: var(--bubble-shadow);
  border-left: 4px solid var(--accent);
  cursor: pointer;
}
.post__label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.post__text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; font-size: 15px; }
.post.is-open .post__text { -webkit-line-clamp: unset; }

.day {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.day span {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 14px;
  font-weight: 500;
}

.c {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 10px;
}
.c.is-new { animation: pop 0.25s ease-out; }
.c.is-focus .c__bubble { box-shadow: 0 0 0 3px var(--accent); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.avatar {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  align-self: flex-start;
}

.c__bubble {
  position: relative;
  max-width: min(84%, 520px);
  min-width: 120px;
  background: var(--surface);
  border-radius: var(--radius);
  border-top-left-radius: 6px;
  padding: 8px 12px 6px;
  box-shadow: var(--bubble-shadow);
  cursor: pointer;
  transition: box-shadow 0.4s;
}
.c__name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.c__name .badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 6px;
  padding: 1px 6px;
}
.c__quote {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 6px;
  padding: 3px 8px;
  margin: 4px 0 2px;
  font-size: 13px;
}
.c__quote b { color: var(--accent); display: block; }
.c__quote span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c__text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; margin-top: 2px; }
.c__text a { color: var(--accent); }
.c__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; min-height: 22px; }
.like {
  border: 0;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.like.is-empty { background: transparent; opacity: 0.45; padding-left: 0; }
.like.is-on { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.c__time { color: var(--muted); font-size: 12px; margin-left: auto; }

.state { text-align: center; color: var(--muted); padding: 48px 24px; }
.state__icon { font-size: 44px; margin-bottom: 8px; }
.state__title { font-weight: 700; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 10px; }
.dash__head { font-weight: 700; margin: 4px 4px 2px; }
.dash__item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--bubble-shadow);
  border: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
}
.dash__body { flex: 1; min-width: 0; }
.dash__channel { font-size: 12px; color: var(--muted); }
.dash__text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; }
.dash__count { flex: none; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 14px; }

/* ---------- composer ---------- */
.composer {
  flex: none;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  padding: 8px 10px calc(8px + var(--safe-bottom));
  z-index: 2;
}
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--accent);
  border-radius: 22px;
  padding: 10px 16px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  max-height: 140px;
  outline: none;
  line-height: 1.35;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.send:disabled { opacity: 0.4; cursor: default; }
.send:not(:disabled):active { transform: scale(0.92); }

.replybar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid var(--accent);
  padding: 2px 4px 2px 10px;
  margin: 0 2px 8px;
}
.replybar__body { flex: 1; min-width: 0; font-size: 13px; }
.replybar__name { color: var(--accent); font-weight: 700; }
.replybar__text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replybar__close { border: 0; background: transparent; font-size: 16px; color: var(--muted); padding: 6px 8px; cursor: pointer; }

.jump {
  position: absolute;
  right: 14px;
  bottom: calc(84px + var(--safe-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
}
.jump__count {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* ---------- action sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); animation: fade 0.15s; }
.sheet__panel {
  position: relative;
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 8px calc(12px + var(--safe-bottom));
  animation: up 0.2s ease-out;
}
.sheet__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 14px 16px;
  font-size: 16px;
  text-align: left;
  border-radius: 12px;
  cursor: pointer;
}
.sheet__btn:active, .sheet__btn:hover { background: var(--line); }
.sheet__btn.is-danger { color: #d93025; }
.sheet__question { padding: 14px 16px 8px; color: var(--muted); font-size: 15px; text-align: center; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- consultation modal ---------- */
.modal { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); animation: fade 0.15s; }
.modal__card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px;
  padding: 22px 18px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: pop 0.2s ease-out;
}
.modal__close { position: absolute; top: 10px; right: 10px; border: 0; background: transparent; font-size: 18px; color: var(--muted); padding: 6px 10px; cursor: pointer; }
.modal__title { font-weight: 800; font-size: 20px; text-align: center; margin: 0 24px 10px; color: var(--accent); }
.modal__text { margin: 0 0 16px; font-size: 15px; line-height: 1.45; text-align: center; }
.modal__question { font-weight: 700; margin-bottom: 10px; }
.modal__done { text-align: center; }
.modal__icon { font-size: 48px; margin: 4px 0 8px; }

.options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
}
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option__dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.option.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.option.is-on .option__dot { border-color: var(--accent); }
.option.is-on .option__dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.primary {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.primary:disabled { opacity: 0.45; cursor: default; }
.phone {
  width: 100%;
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  font-size: 17px;
  margin-bottom: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 20;
  max-width: 90%;
  text-align: center;
  animation: fade 0.15s;
}
