:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #f5f6f8);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #181b1f);
  --muted: var(--tg-theme-hint-color, #707680);
  --button: var(--tg-theme-button-color, #20242a);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --line: #e2e5e9;
  --green: #147952;
  --green-soft: #e4f3ec;
  --blue: #2867ad;
  --blue-soft: #e8f1fb;
  --amber: #936100;
  --amber-soft: #fff1d2;
  --coral: #aa493a;
  --coral-soft: #faeae6;
  --violet: #6650a8;
  --violet-soft: #eee9fb;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.app-frame { width: min(920px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 18px calc(86px + var(--safe-bottom)); }

.app-header { height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.identity { min-width: 0; display: flex; align-items: center; gap: 11px; }
.avatar { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #1f2328; color: #fff; font-size: 13px; font-weight: 750; }
.kicker { display: block; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { overflow: hidden; margin: 4px 0 0; font-size: 19px; line-height: 1.15; white-space: nowrap; text-overflow: ellipsis; }
h2 { margin: 4px 0 0; font-size: 20px; line-height: 1.2; }
h3 { margin-bottom: 0; font-size: 13px; }
.icon-button { flex: none; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); }
.icon-button svg { width: 18px; }
.icon-button.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { display: none; }
.view.active { display: block; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 9px; }
.search-box { height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); }
.search-box svg { flex: none; width: 16px; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-box input::placeholder { color: var(--muted); }

.summary-band { height: 80px; margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.summary-band div { min-width: 0; padding: 16px 14px; border-right: 1px solid var(--line); }
.summary-band div:last-child { border-right: 0; }
.summary-band span { display: block; overflow: hidden; color: var(--muted); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.summary-band strong { display: block; margin-top: 5px; font-size: 20px; }

.stage-tabs { margin: 16px -18px 0; padding: 0 18px 5px; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.stage-tabs::-webkit-scrollbar { display: none; }
.stage-tab { flex: none; height: 32px; padding: 0 11px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 650; }
.stage-tab span { min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--bg); font-size: 9px; }
.stage-tab.active { border-color: #20242a; background: #20242a; color: #fff; }
.stage-tab.active span { background: rgba(255,255,255,.16); color: #fff; }

.list-heading, .view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.list-heading { margin: 19px 0 11px; }
.view-heading { height: 66px; align-items: center; }
.list-count, .month-label { color: var(--muted); font-size: 11px; }
.content-list { display: grid; gap: 9px; }
.content-card { width: 100%; min-height: 132px; padding: 15px; display: grid; grid-template-columns: minmax(0, 1fr) 24px; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.content-card:active { transform: scale(.995); }
.card-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.stage-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--muted); }
.stage-dot.idea { background: var(--violet); }
.stage-dot.script { background: var(--blue); }
.stage-dot.shooting { background: var(--coral); }
.stage-dot.editing { background: var(--amber); }
.stage-dot.ready { background: var(--green); }
.stage-dot.published { background: #59616c; }
.meta-label { color: var(--muted); font-size: 9px; font-weight: 650; text-transform: uppercase; }
.content-card h3 { margin-bottom: 7px; font-size: 14px; line-height: 1.35; }
.content-card p { display: -webkit-box; overflow: hidden; margin-bottom: 12px; color: var(--muted); font-size: 10px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-foot { min-height: 22px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.channel-chip { min-height: 20px; padding: 0 7px; display: inline-flex; align-items: center; border-radius: 4px; background: var(--bg); color: var(--muted); font-size: 8px; font-weight: 650; }
.progress-label { margin-left: auto; color: var(--muted); font-size: 9px; }
.card-arrow { width: 24px; height: 24px; align-self: center; display: grid; place-items: center; border-radius: 50%; background: var(--bg); color: var(--muted); }
.card-arrow svg { width: 14px; }
.loading-state, .empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); text-align: center; }
.loading-state p, .empty-state p { margin: 0; font-size: 11px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; }

.calendar-strip { height: 72px; display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.day-cell { display: grid; place-items: center; align-content: center; gap: 6px; border-right: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.day-cell:last-child { border-right: 0; }
.day-cell strong { font-size: 13px; color: var(--text); }
.day-cell.today strong { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #20242a; color: #fff; }
.timeline { border-top: 1px solid var(--line); }
.timeline-row { min-height: 72px; display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.timeline-date { color: var(--muted); font-size: 9px; }
.timeline-date strong { display: block; color: var(--text); font-size: 14px; }
.timeline-copy strong { display: block; margin-bottom: 4px; font-size: 11px; }
.timeline-copy small { color: var(--muted); font-size: 9px; }

.analytics-total { height: 110px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.analytics-total span, .analytics-total small { display: block; color: var(--muted); font-size: 9px; }
.analytics-total strong { display: block; margin: 7px 0 5px; font-size: 29px; }
.analytics-section { margin-top: 21px; }
.analytics-section h3 { margin-bottom: 11px; }
.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) 24px; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; }
.bar-track { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.format-cloud { display: flex; gap: 7px; flex-wrap: wrap; }
.format-chip { min-height: 31px; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 9px; }
.format-chip strong { font-size: 10px; }

.settings-list { border-top: 1px solid var(--line); }
.setting-row { min-height: 72px; display: grid; grid-template-columns: 34px minmax(0, 1fr) 10px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.setting-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; background: var(--surface); color: var(--muted); }
.setting-icon svg { width: 16px; }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { margin-bottom: 4px; font-size: 11px; }
.setting-row small { color: var(--muted); font-size: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-dot.success { background: var(--green); }
.wide-button { width: 100%; height: 42px; margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 7px; background: var(--button); color: var(--button-text); font-size: 11px; font-weight: 700; }
.wide-button svg { width: 16px; }
.notice { margin-top: 20px; padding: 14px; display: flex; gap: 11px; border-radius: 7px; background: var(--blue-soft); color: #244f7d; }
.notice.warning { background: var(--amber-soft); color: #6f4c00; }
.notice svg { width: 17px; flex: none; }
.notice strong { display: block; margin-bottom: 4px; font-size: 10px; }
.notice p { margin-bottom: 0; font-size: 9px; line-height: 1.5; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(920px, 100%); min-height: calc(64px + var(--safe-bottom)); padding: 6px 10px var(--safe-bottom); display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(18px); transform: translateX(-50%); }
.nav-button { min-width: 0; height: 52px; display: grid; place-items: center; align-content: center; gap: 3px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 8px; }
.nav-button svg { width: 18px; }
.nav-button.active { background: var(--bg); color: var(--text); }

dialog { width: min(680px, 100%); height: min(820px, 92dvh); max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 8px 8px 0 0; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(20,24,29,.48); }
.sheet-handle { width: 38px; height: 4px; margin: 8px auto 2px; border-radius: 99px; background: var(--line); }
.dialog-header { min-height: 62px; padding: 8px 14px; display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.dialog-title-wrap { min-width: 0; }
.dialog-title-wrap h2 { overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.dialog-stage { padding: 11px 16px; display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.stage-step { flex: none; min-height: 25px; padding: 0 8px; display: inline-flex; align-items: center; border: 0; border-radius: 4px; background: var(--bg); color: var(--muted); font-size: 8px; cursor: pointer; }
.stage-step:hover { background: var(--line); color: var(--text); }
.stage-step.current { background: #20242a; color: #fff; }
.stage-step:disabled { cursor: wait; opacity: .55; }
.dialog-scroll { height: calc(92dvh - 180px); padding: 18px 16px 92px; overflow-y: auto; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.detail-section { padding: 17px 0; border-top: 1px solid var(--line); }
.detail-section:first-of-type { border-top: 0; }
.detail-section h3 { margin-bottom: 9px; }
.detail-text { margin: 0; color: var(--text); font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.detail-text p { margin: 0 0 8px; }
.detail-text p:last-child { margin-bottom: 0; }
.detail-text ul { margin: 0; padding-left: 18px; }
.detail-text li + li { margin-top: 7px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 10px; line-height: 1.45; }
.check-mark { width: 17px; height: 17px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; color: transparent; }
.check-row.done .check-mark { border-color: var(--green); background: var(--green); color: #fff; }
.check-mark svg { width: 12px; }
.dialog-actions { position: absolute; left: 0; right: 0; bottom: 0; min-height: calc(68px + env(safe-area-inset-bottom)); padding: 10px 14px max(10px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 9px; border-top: 1px solid var(--line); background: var(--surface); }
.primary-button, .secondary-button { height: 42px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 7px; font-size: 10px; font-weight: 700; }
.primary-button { border: 1px solid var(--button); background: var(--button); color: var(--button-text); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.primary-button:disabled, .secondary-button:disabled { opacity: .4; cursor: default; }
.primary-button svg, .secondary-button svg { width: 15px; }
.small-dialog { height: auto; max-height: 70dvh; }
.filter-options { padding: 14px; display: grid; gap: 7px; }
.filter-option { height: 40px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 10px; }
.filter-option.active { border-color: var(--green); color: var(--green); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(76px + var(--safe-bottom)); width: min(360px, calc(100% - 28px)); padding: 12px 14px; border-radius: 7px; background: #20242a; color: #fff; box-shadow: 0 12px 34px rgba(0,0,0,.24); font-size: 10px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8e382d; }

@media (min-width: 700px) {
  .app-frame { padding-inline: 26px; }
  .stage-tabs { margin-inline: 0; padding-inline: 0; }
  .content-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-card { min-height: 148px; }
  dialog { margin: auto; border-radius: 8px; }
  .sheet-handle { display: none; }
  .dialog-scroll { height: calc(min(820px, 92dvh) - 170px); }
}

@media (max-width: 360px) {
  .app-frame { padding-inline: 14px; }
  .summary-band div { padding-inline: 10px; }
  h1 { font-size: 17px; }
}
