:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f5f3f7);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --surface-strong: #19161f;
  --text: var(--tg-theme-text-color, #18151d);
  --muted: var(--tg-theme-hint-color, #77717d);
  --accent: var(--tg-theme-button-color, #7c4dff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--text) 10%, transparent);
  --green: #24a877;
  --amber: #d58a1f;
  --red: #d94b5d;
  --radius: 22px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html { width: 100%; max-width: 100vw; min-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; touch-action: pan-y; }
body { position: relative; width: 100%; max-width: 100vw; min-width: 100%; margin: 0; overflow-x: hidden; overscroll-behavior-x: none; overscroll-behavior-y: none; touch-action: pan-y; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.app-shell { width: 100%; max-width: min(680px, 100vw); min-width: 0; min-height: 100vh; min-height: 100dvh; margin: 0 auto; overflow-x: clip; padding: env(safe-area-inset-top) 18px calc(102px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 2px 20px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(18px); }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; color: #fff; font-weight: 800; font-size: 22px; background: linear-gradient(145deg, #9b6dff, #5530c7); box-shadow: 0 10px 28px rgba(99, 60, 201, .25); }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1; }
.eyebrow { margin: 0 0 5px; color: var(--muted); text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 800; }
.status-pill { margin-left: auto; padding: 8px 11px; border-radius: 999px; font-size: 12px; font-weight: 750; background: rgba(36, 168, 119, .12); color: var(--green); }
.status-pill.muted { color: var(--muted); background: var(--surface); }
.view { display: none; animation: rise .2s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: .3; transform: translateY(5px); } }
.hero-card { min-height: 180px; border-radius: 28px; padding: 24px; display: flex; align-items: center; justify-content: space-between; overflow: hidden; color: #fff; background: radial-gradient(circle at 90% 10%, #9f7aff 0, transparent 40%), linear-gradient(135deg, #211b2a, #111016); box-shadow: 0 18px 40px rgba(26, 18, 39, .18); }
.hero-card h2 { margin: 0 0 8px; font-size: clamp(28px, 7vw, 38px); max-width: 380px; }
.hero-card .eyebrow, .hero-card .subtle { color: rgba(255,255,255,.68); }
.subtle { margin: 0; font-size: 14px; }
.hero-orb { width: 84px; height: 84px; flex: 0 0 auto; border-radius: 50%; border: 1px solid rgba(255,255,255,.32); display: grid; place-items: center; box-shadow: 0 0 40px rgba(156,117,255,.55); }
.hero-orb span { width: 34px; height: 34px; border-radius: 50%; background: #a98aff; box-shadow: 0 0 24px #a98aff; }
.hero-orb.active span { background: #49d9a2; box-shadow: 0 0 24px #49d9a2; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.metric, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric { padding: 17px; display: flex; flex-direction: column; min-height: 118px; }
.metric span, .metric small, .service-list small, .toggle-card small, .coming-soon small { color: var(--muted); }
.metric strong { font-size: 30px; margin: auto 0 2px; letter-spacing: -.04em; }
.metric small { font-size: 11px; }
.card { padding: 20px; margin: 12px 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; }
.section-head h3, .schedule-card h3, .card h3 { margin: 0; font-size: 20px; }
.ghost-button { border: 0; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-radius: 12px; padding: 9px 12px; font-weight: 700; }
.service-list > div { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.service-list > div:last-child { border: 0; padding-bottom: 0; }
.service-list strong, .service-list small { display: block; }
.service-list b { font-size: 12px; color: var(--muted); }
.service-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 14%, transparent); }
.service-dot.on { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent); }
.schedule-card p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.progress { height: 7px; background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 8px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #b18cff); }
.section-title { padding: 10px 2px 8px; }
.section-title h2 { font-size: 32px; margin: 0 0 8px; letter-spacing: -.04em; }
.section-title > p:last-child { margin: 0; color: var(--muted); line-height: 1.45; }
.stack { display: grid; gap: 10px; }
#task-list { gap: 0; overflow: hidden; border-radius: 18px; box-shadow: 0 5px 18px color-mix(in srgb, var(--text) 6%, transparent); }
.toggle-card { display: flex; justify-content: space-between; align-items: center; }
.toggle-card strong, .toggle-card small { display: block; }
.toggle-card small { margin-top: 5px; }
.switch input { position: absolute; width: 1px; max-width: 1px; min-width: 1px; height: 1px; margin: 0; padding: 0; opacity: 0; }
.switch { width: auto; max-width: none; flex: 0 0 auto; }
.switch span { width: 54px; height: 32px; display: block; padding: 4px; background: color-mix(in srgb, var(--text) 16%, transparent); border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; width: 24px; height: 24px; display: block; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(22px); }
.form-card { display: grid; width: 100%; max-width: 100%; gap: 18px; overflow: hidden; }
label { display: block; width: 100%; max-width: 100%; min-width: 0; font-weight: 750; font-size: 13px; }
input, textarea, select { width: 100%; max-width: 100%; border: 1px solid var(--border); color: var(--text); background: color-mix(in srgb, var(--bg) 65%, var(--surface)); border-radius: 14px; padding: 14px; margin-top: 8px; outline: none; font-size: 16px; font-weight: 400; }
input[type="datetime-local"] { display: block; width: 100%; max-width: 100%; min-width: 0; inline-size: 100%; max-inline-size: 100%; min-inline-size: 0; -webkit-appearance: none; appearance: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); }
textarea { resize: vertical; line-height: 1.45; }
label > small { display: block; text-align: right; color: var(--muted); margin-top: 4px; }
.read-only-row, .settings-list > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.read-only-row span, .settings-list span { color: var(--muted); }
#vacation-form { width: 100%; max-width: 100%; min-width: 0; overflow-x: clip; padding-bottom: 92px; }
#vacation-form input, #vacation-form textarea, #vacation-form select { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; font-weight: 300 !important; font-synthesis: none; -webkit-text-stroke: 0 transparent; text-shadow: none; letter-spacing: 0; }
#vacation-reply { min-height: 132px; resize: none; }
.reply-field { display: grid; min-width: 0; }
.reply-field-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.reply-field-footer small { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.reply-save-button { min-height: 38px; border: 0; border-radius: 12px; padding: 9px 16px; color: var(--accent-text); background: var(--accent); font-size: 13px; font-weight: 700; box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 22%, transparent); }
.reply-save-button:disabled { opacity: .42; box-shadow: none; }
#vacation-form > .primary-button { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 9; width: min(644px, calc(100% - 36px)); transform: translateX(-50%); padding: 15px 18px; font-weight: 700; box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 38%, transparent); }
.primary-button { width: 100%; border: 0; border-radius: 16px; padding: 16px; background: var(--accent); color: var(--accent-text); font-weight: 800; box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 26%, transparent); }
.primary-button:disabled { opacity: .5; cursor: wait; }
.notice { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; padding: 16px; border-radius: 16px; background: color-mix(in srgb, var(--amber) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent); }
.notice span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.notice.danger { border-color: color-mix(in srgb, var(--red) 34%, transparent); }
.notice.safe { background: color-mix(in srgb, var(--green) 9%, var(--surface)); border-color: color-mix(in srgb, var(--green) 28%, transparent); }
.helper { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.filter-row { display: flex; overflow-x: auto; gap: 8px; padding: 5px 0 12px; scrollbar-width: none; }
.chip { white-space: nowrap; border: 1px solid var(--border); color: var(--muted); background: var(--surface); padding: 9px 13px; border-radius: 999px; }
.chip.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.dialog-card, .task-card, .journal-card, .report-card, .calendar-card { padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.dialog-top, .item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-card h3, .task-card h3 { margin: 0; font-size: 16px; }
.dialog-card p { color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.task-comment { color: var(--muted); margin: 11px 0 0; padding: 10px 12px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 7%, transparent); line-height: 1.4; font-size: 12px; }
.dialog-card small, .task-card small, .journal-card small, .report-card small { color: var(--muted); }
.priority { padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.priority.urgent { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.priority.important { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); }
.priority.normal { color: var(--muted); background: color-mix(in srgb, var(--text) 7%, transparent); }
.reason { display: block; margin-top: 8px; font-size: 11px; color: var(--muted); }
.task-chat { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 12px; align-items: center; min-height: 82px; padding: 12px 10px; border-bottom: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.task-chat:first-child { border-radius: 18px 18px 0 0; }
.task-chat:last-child { border-bottom: 0; border-radius: 0 0 18px 18px; }
.task-chat:only-child { border-radius: 18px; }
.task-chat:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent); outline-offset: 2px; }
.task-avatar { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 15px; font-weight: 750; letter-spacing: -.02em; }
.avatar-0 { background: #3698ca; } .avatar-1 { background: #7868ca; } .avatar-2 { background: #49a783; }
.avatar-3 { background: #e26435; } .avatar-4 { background: #66a913; } .avatar-5 { background: #18aaa5; }
.task-chat-content { min-width: 0; }
.task-chat-head { display: flex; align-items: baseline; gap: 8px; }
.task-chat-head h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; }
.task-chat-head time { margin-left: auto; flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.task-chat-preview { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; font-weight: 400; }
.task-chat-preview strong { color: var(--text); font-weight: 550; }
.task-chat-meta { min-height: 18px; margin-top: 5px; display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: 10px; font-weight: 650; }
.task-chat-meta b { margin-left: auto; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; border-radius: 999px; color: #fff; background: var(--accent); font-size: 10px; font-weight: 700; }
.owner-reply { display: grid; gap: 4px; margin-top: 10px; padding: 10px 12px; border-radius: 11px; background: color-mix(in srgb, var(--green) 7%, transparent); }
.owner-reply strong { color: var(--green); font-size: 11px; }
.owner-reply span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-actions { display: flex; gap: 8px; margin-top: 13px; }
.card-actions button { border: 0; border-radius: 11px; padding: 9px 11px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 750; font-size: 12px; }
.card-actions .danger-link { color: var(--red); background: color-mix(in srgb, var(--red) 9%, transparent); }
.calendar-filter { margin-top: 8px; }
.calendar-card h3 { margin: 4px 0 5px; font-size: 17px; }
.calendar-card p { color: var(--muted); line-height: 1.45; margin-bottom: 0; }
.calendar-kind { color: var(--accent); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.message-preview { margin-top: 12px; padding: 12px; border-left: 3px solid var(--accent); border-radius: 10px; color: var(--muted); background: color-mix(in srgb, var(--accent) 7%, transparent); white-space: pre-wrap; line-height: 1.4; }
.coming-soon { display: flex; flex-direction: column; gap: 7px; border-style: dashed; }
.coming-soon span { color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.timeline { margin: 15px 0 20px; padding-left: 10px; }
.timeline > div { position: relative; padding: 0 0 22px 26px; border-left: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.timeline > div:last-child { padding-bottom: 0; }
.timeline span { position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); }
.timeline strong, .timeline small { display: block; }
.timeline small { color: var(--muted); margin-top: 4px; }
.report-card button { margin-top: 12px; border: 0; border-radius: 11px; padding: 10px 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); font-weight: 750; }
.settings-list { display: grid; gap: 16px; }
.settings-list > div:first-child { border-top: 0; padding-top: 0; }
.settings-list strong { text-align: right; }
.bottom-nav { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(680px, 100%); display: grid; grid-template-columns: repeat(5, 1fr); padding: 9px 10px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(24px); border-top: 1px solid var(--border); z-index: 10; }
.bottom-nav button { border: 0; color: var(--muted); background: transparent; font-size: 10px; font-weight: 750; display: grid; place-items: center; gap: 3px; }
.bottom-nav button span { font-size: 20px; line-height: 1; }
.bottom-nav button.active { color: var(--accent); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 20; display: flex; align-items: flex-end; padding: 14px; }
.sheet-card { width: min(652px, 100%); margin: 0 auto calc(env(safe-area-inset-bottom)); padding: 8px; border-radius: 24px; background: var(--surface); box-shadow: 0 -20px 50px rgba(0,0,0,.18); }
.sheet-card:not(.calendar-form) > button { width: 100%; display: flex; justify-content: space-between; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); padding: 16px; text-align: left; font-weight: 700; }
.sheet-card .cancel { justify-content: center; color: var(--accent); border: 0; }
.calendar-form { max-height: calc(100vh - 28px); overflow-y: auto; display: grid; gap: 11px; padding: 18px; }
.calendar-form .section-head { align-items: center; }
.calendar-form .section-head h3 { margin: 0; }
.calendar-form input, .calendar-form textarea, .calendar-form select { font-weight: 400; line-height: 1.35; }
.calendar-form input[type="datetime-local"] { text-align: left; }
.calendar-form .primary-button { display: block; width: 100%; border: 0; border-radius: 16px; padding: 15px; background: var(--accent); color: var(--accent-text); text-align: center; font-weight: 700; box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 26%, transparent); }
.icon-button { width: 38px !important; height: 38px; display: grid !important; place-items: center; padding: 0 !important; border: 0 !important; border-radius: 50%; background: color-mix(in srgb, var(--text) 7%, transparent) !important; font-size: 24px; color: var(--text) !important; }
.toast { position: fixed; left: 50%; bottom: calc(144px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: calc(100% - 36px); max-width: 560px; padding: 13px 16px; border-radius: 14px; color: #fff; background: #26212d; box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 30; text-align: center; font-weight: 700; }
.hidden { display: none !important; }
.skeleton { height: 90px; border-radius: 18px; background: linear-gradient(90deg, var(--surface), color-mix(in srgb, var(--text) 5%, var(--surface)), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton.tall { height: 140px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (min-width: 700px) { .app-shell { padding-left: 24px; padding-right: 24px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
