:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color-scheme: light;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --secondary: #85858c;
  --line: #e5e5ea;
  --blue: #007aff;
  --tint: #e8eff9;
  --input: #e5e5eb;
  --nav: rgba(248,248,250,.94);
  --error: #c63631;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
:root.theme-dark {
  color-scheme: dark;
  --bg: #1c1c1e;
  --card: #2a2a2d;
  --text: #dfdfe3;
  --secondary: #a0a0a8;
  --line: #3a3a3e;
  --blue: #72a9e7;
  --tint: #303b4b;
  --input: #303033;
  --nav: rgba(37,37,39,.96);
  --error: #ee928b;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { border: 0; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--blue); text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
input, textarea, select {
  width: 100%; min-width: 0; border: 0; border-radius: 11px;
  padding: 14px 16px; background: var(--card); color: var(--text);
  outline: none; font-size: 16px;
}
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 45%, transparent); }
input::placeholder, textarea::placeholder { color: var(--secondary); opacity: .9; }
textarea { resize: vertical; min-height: 116px; line-height: 1.45; }
input[type=file] { font-size: 13px; padding: 11px 12px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--blue); }
.app-shell { max-width: 860px; margin: 0 auto; padding: 24px 20px 108px; }
h1 { margin: 0 0 24px; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.8px; }
h2 { margin: 0 0 12px; font-size: 21px; line-height: 1.25; letter-spacing: -.3px; font-weight: 600; }
h3 { margin: 0; font-size: 14px; line-height: 1.3; font-weight: 500; }
p { margin: 0; }
.heading-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail { max-width: 620px; margin: auto; }
.detail-description { font-size: 16px; line-height: 1.45; margin: 18px 0 24px; color: var(--secondary); }
.search-wrap { position: relative; margin: -8px 0 14px; }
.search-wrap svg { position: absolute; width: 18px; height: 18px; top: 11px; left: 12px; color: var(--secondary); }
.search-wrap input { background: var(--input); padding: 10px 12px 10px 38px; border-radius: 10px; font-size: 16px; }
.filters { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 20px; }
.filters::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; background: transparent; color: var(--secondary); padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.chip.active { background: var(--card); color: var(--blue); }
.template-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 30px 24px; }
.template-card { display: block; min-width: 0; padding: 0; background: transparent; text-align: left; }
/* Covers already contain their own background. Never add a surface, inset, shadow or filter. */
.visual { width: 100%; border-radius: 14px; overflow: hidden; }
.visual > img { display: block; width: 100%; height: auto; }
.visual--live { display: flex; align-items: center; min-height: 150px; max-height: 260px; }
.visual--live > div { width: 100%; pointer-events: none; }
.visual--live .ph-block { font-size: 14px; }
.visual--live .ph-row { padding: 12px 14px; }
.visual--live .ph-sub { font-size: 11px; }
.card-info { padding: 12px 2px 0; }
.card-info h3 { font-size: 14px; font-weight: 500; letter-spacing: -.2px; }
.card-info p { font-size: 14px; line-height: 1.4; color: var(--secondary); margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding-bottom: env(safe-area-inset-bottom,0px); background: var(--nav); backdrop-filter: blur(24px); border-top: .5px solid var(--line); display: flex; justify-content: center; }
.nav-inner { width: 100%; max-width: 580px; display: flex; }
.nav-item { width: 33.333%; min-height: 55px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px 6px; background: transparent; color: var(--secondary); font-size: 10px; font-weight: 500; }
.nav-item svg { width: 23px; height: 23px; }
.nav-item.active { color: var(--blue); }
.nav-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--tint); color: var(--secondary); font-size: 11px; font-weight: 600; }
.nav-item.active .nav-avatar { outline: 1.5px solid var(--blue); outline-offset: 2px; }
.toolbar { min-height: 28px; margin: -6px 0 20px; }
.back { display: flex; align-items: center; gap: 2px; padding: 0; background: transparent; color: var(--blue); font-size: 17px; }
.back svg { width: 20px; height: 24px; }
.group-label { margin: 26px 16px 8px; color: var(--secondary); font-size: 13px; line-height: 1.3; font-weight: 400; }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 13px 16px; font-size: 16px; }
.row + .row { border-top: .5px solid var(--line); }
.row > span:first-child { flex: 1; }
.row .muted { font-size: 14px; color: var(--secondary); }
.minor, .section-footnote { font-size: 13px; line-height: 1.45; color: var(--secondary); }
.section-footnote { margin: 9px 16px 18px; }
.primary, .secondary { display: block; width: 100%; padding: 14px 16px; border-radius: 12px; text-align: center; font-size: 17px; font-weight: 500; line-height: 1.25; }
.primary { background: var(--blue); color: #fff; }
.theme-dark .primary { background: #3b689c; color: #f0f2f7; }
.secondary { background: var(--card); color: var(--blue); }
.primary svg { width: 18px; height: 18px; vertical-align: middle; margin-right: 5px; }
.inline-icon { width: 17px; height: 17px; vertical-align: -3px; margin-right: 3px; }
.sticky-action { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; padding: 12px max(20px,calc((100vw - 620px)/2)) calc(12px + env(safe-area-inset-bottom,0px)); background: var(--nav); backdrop-filter: blur(20px); border-top: .5px solid var(--line); }
.editor-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 28px; align-items: start; }
.editor-preview { position: sticky; top: 20px; min-width: 0; }
.editor-preview .group-label { margin-top: 0; }
.preview-surface { overflow: hidden; border-radius: 12px; }
.preview-surface iframe { display: block; width: 100%; min-height: 120px; border: 0; }
.segmented { display: flex; background: var(--input); padding: 3px; gap: 2px; border-radius: 9px; }
.segmented button { flex: 1; background: transparent; color: var(--secondary); padding: 7px 8px; border-radius: 7px; font-size: 13px; line-height: 1.2; }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px #0000000a; }
.option-line { display: flex; gap: 10px; margin-bottom: 24px; }
.option-line > * { flex: 1; }
.field { margin-bottom: 20px; }
.field label { display: block; margin: 0 16px 8px; color: var(--secondary); font-size: 13px; line-height: 1.3; }
.field small { display: block; margin: 7px 16px 0; color: var(--secondary); font-size: 12px; line-height: 1.4; }
.field-error, .form-error { color: var(--error) !important; }
.form-error { margin: 12px 0; font-size: 14px; line-height: 1.45; }
.form-error:empty { display: none; }
.item-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; }
.item-edit { flex: 1; min-width: 0; padding: 2px 0; background: transparent; text-align: left; }
.item-edit strong { display: block; font-weight: 400; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-edit small { display: block; margin-top: 3px; color: var(--secondary); font-size: 12px; }
.item-edit small:empty { display: none; }
.icon-button { display: grid; place-items: center; min-width: 38px; min-height: 38px; padding: 8px; background: transparent; color: var(--secondary); }
.icon-button svg { width: 18px; height: 18px; }
.danger { color: var(--error) !important; }
.advanced { margin-top: 24px; }
.advanced summary { color: var(--secondary); padding: 12px 16px; cursor: pointer; font-size: 14px; }
.advanced[open] summary { margin-bottom: 12px; }
.code-panel { background: var(--card); border-radius: 12px; overflow: hidden; margin-top: 22px; }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--input); font-size: 13px; }
.code-toolbar button { background: transparent; color: var(--blue); display: flex; align-items: center; gap: 5px; font-size: 13px; padding: 0; }
.code-toolbar svg { width: 16px; height: 16px; }
.code-panel pre { counter-reset: line; padding: 15px 0; margin: 0; overflow: auto; max-height: 440px; font: 12px/1.8 ui-monospace,SFMono-Regular,monospace; tab-size: 2; }
.code-line { display: block; padding-right: 18px; min-height: 21px; }
.code-line:before { counter-increment: line; content: counter(line); display: inline-block; width: 38px; padding-right: 12px; text-align: right; color: var(--secondary); opacity: .7; user-select: none; }
.bot-list { margin-bottom: 12px; }
.bot-card { display: flex; align-items: center; gap: 12px; padding: 15px 16px; }
.bot-card + .bot-card { border-top: .5px solid var(--line); }
.bot-avatar { width: 48px; height: 48px; flex: none; border-radius: 50%; object-fit: cover; background: var(--tint); color: var(--blue); display: grid; place-items: center; font-size: 20px; font-weight: 500; }
.bot-main { flex: 1; min-width: 0; }
.bot-main h3 { font-size: 17px; overflow-wrap: anywhere; }
.bot-main a { display: block; color: var(--secondary); font-size: 14px; margin-top: 3px; }
.add-bot { text-align: left; padding-left: 18px; }
.empty { text-align: center; padding: 66px 12px 32px; }
.empty-icon { display: grid; place-items: center; margin: 0 auto 20px; color: var(--secondary); }
.empty-icon svg { width: 42px; height: 42px; stroke-width: 1.2; }
.empty h2 { font-size: 20px; }
.empty p { color: var(--secondary); font-size: 15px; line-height: 1.45; margin: 9px auto 26px; max-width: 300px; }
.empty .primary, .empty .secondary { margin: 24px auto 0; max-width: 320px; }
.empty-text { color: var(--secondary); font-size: 15px; text-align: center; padding: 40px 0; grid-column: 1 / -1; }
.profile-head { text-align: center; padding: 8px 0 28px; }
.profile-head .bot-avatar { width: 74px; height: 74px; font-size: 28px; margin: 0 auto 14px; }
.profile-head h1 { font-size: 24px; letter-spacing: -.4px; margin-bottom: 6px; }
.profile-head p { color: var(--secondary); font-size: 14px; }
.stats { display: flex; padding: 16px 0; background: var(--card); border-radius: 12px; }
.stat { flex: 1; text-align: center; color: var(--secondary); font-size: 12px; }
.stat + .stat { border-left: .5px solid var(--line); }
.stat strong { display: block; color: var(--text); font-size: 23px; font-weight: 500; margin-bottom: 3px; }
.saved-row { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; background: transparent; padding: 0; }
.saved-symbol { width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--tint); color: var(--blue); display: grid; place-items: center; font-size: 16px; }
.saved-row strong { display: block; font-size: 16px; font-weight: 400; overflow-wrap: anywhere; }
.saved-row small { display: block; font-size: 12px; color: var(--secondary); margin-top: 3px; }
.media-list { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.media-tile { overflow: hidden; background: var(--card); border-radius: 10px; }
.media-tile img, .media-tile video { display: block; width: 100%; height: 90px; object-fit: cover; }
.media-tile footer { display: flex; align-items: center; justify-content: space-between; padding: 8px; color: var(--secondary); font-size: 11px; }
.media-tile button { padding: 4px; background: transparent; color: var(--secondary); }
.media-tile svg { width: 16px; height: 16px; }
.upload-status { color: var(--secondary); font-size: 13px; padding-top: 6px; }
.loading { padding: 60px 20px; text-align: center; color: var(--secondary); }
.error-page { padding-top: 70px; text-align: center; }
.error-page p { margin: 18px 0; color: var(--secondary); line-height: 1.5; }
#toast { position: fixed; left: 50%; bottom: 100px; z-index: 40; transform: translate(-50%,10px); opacity: 0; pointer-events: none; max-width: 90%; padding: 12px 18px; border-radius: 12px; color: var(--text); background: var(--card); box-shadow: 0 4px 22px #0002; font-size: 14px; transition: opacity .15s, transform .15s; }
#toast.visible { opacity: 1; transform: translate(-50%,0); }
dialog { width: min(440px,calc(100% - 32px)); max-height: 85dvh; border: 0; border-radius: 18px; padding: 24px 20px; overflow: auto; background: var(--bg); color: var(--text); box-shadow: 0 16px 60px #0002; }
dialog::backdrop { background: #0005; backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 24px; }
dialog .section-footnote { margin-left: 2px; margin-right: 2px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 24px; }
.dialog-actions > * { flex: 1; }
@media(max-width:620px) {
  .app-shell { padding: 22px 16px 100px; }
  h1 { margin-bottom: 24px; }
  .template-grid { grid-template-columns: 1fr; gap: 28px; }
  .filters { margin-right: -16px; padding-right: 16px; }
  .visual--live { min-height: 140px; }
  .editor-grid { display: flex; flex-direction: column-reverse; gap: 24px; }
  .editor-grid > * { width: 100%; }
  .editor-preview { position: static; }
  .editor-preview .group-label { margin-top: 0; }
  .option-line { margin-bottom: 20px; }
  .sticky-action { padding-left: 16px; padding-right: 16px; }
  .media-list { grid-template-columns: repeat(2,1fr); }
}
@media(prefers-reduced-motion:reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@supports(padding:max(0px)) { .app-shell { padding-top: max(22px,var(--tg-content-safe-area-inset-top,0px)); } }
