@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/assets/fonts/InterVariable.woff2") format("woff2"); }

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ink: #1d1d1f;
  --ink-2: #515154;
  --ink-3: #86868b;
  --paper: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --line: #d2d2d7;
  --line-2: #e8e8ed;
  --accent: #0071e3;
  --accent-2: #0060c2;
  --accent-soft: #e9f2fd;
  --on-accent: #ffffff;
  --good: #1d8a41;
  --good-soft: #e6f6ea;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --bad: #d70015;
  --bad-soft: #fdecec;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --shadow: 0 2px 8px rgba(0, 0, 0, .05), 0 16px 40px -20px rgba(0, 0, 0, .25);
  --focus: 0 0 0 4px rgba(0, 113, 227, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { letter-spacing: -0.015em; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 980px;
  background: var(--surface); color: var(--ink);
  font-weight: 500; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
a.btn { text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .focusable:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { width: 36px; padding: 0; border-radius: 50%; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="url"], input[type="tel"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; margin: 0; }
.row { display: flex; gap: 12px; }
.row > .field { flex: 1; min-width: 0; }
.error-text { color: var(--bad); font-size: 13px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 980px; background: rgba(29, 29, 31, .92); backdrop-filter: blur(12px); color: #fff; font-size: 14px; box-shadow: var(--shadow); max-width: min(90vw, 480px); }
.toast.bad { background: var(--bad); }

/* Message bubbles are shared by both pages */
.msg { display: flex; flex-direction: column; max-width: 68ch; }
.msg-body {
  padding: 10px 14px; border-radius: 20px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; font-size: 16px;
}
.msg-meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; padding: 0 4px; display: flex; gap: 6px; align-items: baseline; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .msg-body { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg.mine .msg-body a { color: inherit; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg.theirs .msg-body { background: #e9e9eb; color: var(--ink); border: 0; border-bottom-left-radius: 6px; }
.msg.note .msg-body { background: var(--warn-soft); border: 1px dashed #e4c07a; color: #5b3d00; font-size: 15px; }
.msg.system { align-self: center; max-width: 80%; text-align: center; }
.msg.system .msg-body { background: transparent; color: var(--ink-3); font-size: 13px; padding: 4px 8px; }
.msg-body a { text-decoration: underline; }
.msg-img { border-radius: 12px; max-height: 320px; width: auto; max-width: 100%; min-width: 96px; min-height: 72px; display: block; background: var(--surface-2); object-fit: contain; }
.msg-body.has-image { padding: 4px; background: var(--surface); border: 1px solid var(--line-2); }
.msg.mine .msg-body.has-image { background: var(--surface); }
.msg-caption { padding: 6px 8px 4px; }
.msg-body.has-image .msg-caption { color: var(--ink); }
.msg-file { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.msg-file .file-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--accent); }
.msg.mine .msg-file .file-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.msg-file .file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-file .file-size { font-size: 12px; opacity: .8; }
.day-sep { align-self: center; font-size: 12px; color: var(--ink-3); padding: 8px 0 2px; }
.typing { display: inline-flex; gap: 3px; align-items: center; padding: 10px 12px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .7; } }

/* Step and appointment cards */
.msg.card { max-width: 100%; width: 100%; }
.msg.card .msg-body { background: var(--surface); color: var(--ink); padding: 0; border-radius: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px -12px rgba(0, 0, 0, .25); overflow: hidden; white-space: normal; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 0; }
.card-num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.card-num.done { background: var(--good); color: #fff; }
.card-num svg { width: 16px; height: 16px; }
.card-status svg { width: 18px; height: 18px; flex: none; }
.card-kicker { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.card-title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.card-text { padding: 10px 14px 0; line-height: 1.45; white-space: pre-wrap; }
.card-detail { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 10px 14px 0; font-size: 15px; }
.card-detail dt { color: var(--ink-3); }
.card-detail dd { margin: 0; font-weight: 500; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; }
.card-actions .btn { min-height: 40px; font-size: 15px; }
.card-status { padding: 10px 14px 14px; font-size: 14px; color: var(--good); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.card-status.muted { color: var(--ink-3); font-weight: 400; }


/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; z-index: 50; }
@media (max-width: 640px) {
  .modal-backdrop { padding: 8px; align-items: end; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: calc(100vh - 16px); }
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 24px;
}
.modal.wide { width: min(880px, 100%); }
.modal h2 { font-size: 20px; font-weight: 600; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
