:root { --bg: #f6f6f4; --card: #fff; --ink: #1c1c1c; --muted: #6b6b6b; --line: #e3e3df; --accent: #d63c5e; --ok: #2e8b57; --warn: #c77700; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
header { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 18px; }
nav { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
nav::-webkit-scrollbar { display: none; }
nav > * { flex: 0 0 auto; white-space: nowrap; }
nav select { width: auto; max-width: 45vw; }
main { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 900px; margin: 0 auto; padding: 12px 12px 24px; display: flex; flex-direction: column; }
main > * { flex: 0 0 auto; }
button, select, input, textarea { font: inherit; color: inherit; -webkit-appearance: none; appearance: none; }
button { padding: 9px 14px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; }
button.small { padding: 5px 10px; min-height: 32px; font-size: 14px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; }
button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b6b6b' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input[type="checkbox"] { -webkit-appearance: checkbox; appearance: checkbox; width: 20px; height: 20px; padding: 0; }
input[type="date"], input[type="time"] { display: block; min-height: 44px; line-height: 1.3; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; min-height: 1.3em; }
@supports (-webkit-touch-callout: none) {
  input[type="date"].empty::before { content: attr(placeholder); color: #8a8a8a; }
  input[type="date"].empty:focus::before { content: none; }
}
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
.row { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.title { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
h2 { margin: 0; font-size: 19px; }
.muted { color: var(--muted); font-size: 14px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eee; font-size: 12px; margin: 0 4px 4px 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; color: #fff; background: var(--warn); white-space: nowrap; }
.badge.ok { background: var(--ok); }
.badge.muted { background: var(--muted); }
.badge.err { background: var(--accent); }
.list { display: flex; flex-direction: column; }
.item { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item.clickable { cursor: pointer; }
.item .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item .name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .preview { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .note { font-size: 14px; color: var(--accent); }
.alert { background: #fff3f5; border: 1px solid #f3c6d0; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.alert.ok { background: #eef8f1; border-color: #bfe3cb; }
.item .name { overflow-wrap: anywhere; }
.item .actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; background: #ececea; border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: #ffe3e9; border-bottom-right-radius: 4px; }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.login { max-width: 420px; margin: 40px auto; text-align: center; }
.login .or { margin: 20px 0 8px; color: var(--muted); }
.notice { color: var(--ok); font-size: 14px; }
.error { color: var(--accent); font-size: 14px; }
a.button { display: inline-block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); background: var(--card); text-align: center; }
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.full { width: 100%; }
@media (min-width: 640px) {
  header { flex-direction: row; align-items: center; padding: 12px 20px; }
  .topbar { flex: 0 0 auto; }
  nav { flex: 1; }
  main { padding: 24px 20px; }
  .card { padding: 16px 20px; }
  .row { flex-direction: row; align-items: end; }
  .row > * { flex: 1; }
  .row > .fixed { flex: 0 0 auto; }
  .msg { max-width: 70%; }
}
.chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat .title, .chat .suggestions { flex: 0 0 auto; }
.chat .chat-thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 8px 0; padding-right: 2px; }
.chat .composer { flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-end; padding: 8px 0 max(0px, env(safe-area-inset-bottom)); }
.chat .composer.ended { flex-direction: column; align-items: stretch; gap: 8px; }
.title .actions { display: flex; gap: 6px; }
.chat .composer textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; }
.chat .composer button { min-height: 44px; }
.dots { display: inline-flex; gap: 4px; padding: 6px 2px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.saved { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,.15); font-size: 13px; }
.saved .chip { display: block; margin-top: 4px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.suggestions p { width: 100%; margin: 0; }
button.chip { border-radius: 999px; text-align: left; white-space: normal; }
.waiting { flex: 0 0 auto; background: #fff8e6; border: 1px solid #f1dfb0; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.waiting .q { cursor: pointer; padding: 6px 0; border-top: 1px solid #f1dfb0; margin-top: 6px; }
.details { flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 10px; margin: 6px 0; }
.chat .alert { flex: 0 0 auto; }
.composer.ended .row { flex-direction: row; }
.composer.ended .row > button { flex: 1; }
