:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #111418; --muted: #5b6370;
  --line: #e4e7ec; --field: #f6f7f9;
  --accent: #0f766e; --accent-press: #0b5d56; --accent-soft: #e3f3f0; --on-accent: #ffffff;
  --warn: #9a4a00; --warn-soft: #fff3e3; --warn-line: #f3c27c;
  --err: #b42318; --err-soft: #fdecea;
  --ok: #067647; --ok-soft: #e6f6ee;
  --blue: #1d4ed8; --blue-soft: #e8eefc;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.05);
  --r: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --card: #1b1e24; --text: #f2f4f7; --muted: #a3abb8;
    --line: #2c313a; --field: #14161b;
    --accent: #34b8a8; --accent-press: #2a9c8e; --accent-soft: #173431; --on-accent: #0b1514;
    --warn: #f6b45a; --warn-soft: #2f2414; --warn-line: #6f4c1b;
    --err: #f97066; --err-soft: #3a1c1a;
    --ok: #47cd89; --ok-soft: #13301f;
    --blue: #84a9ff; --blue-soft: #1a2440;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 19px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 14px 16px 32px; }
.wrap.with-bottom { padding-bottom: calc(120px + var(--safe-b)); }
.title { font-size: 32px; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; margin: 14px 4px 18px; }
.title.small { font-size: 28px; margin-top: 4px; }
.section { font-size: 22px; font-weight: 700; margin: 30px 4px 12px; }
.lead { font-size: 20px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 17px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 12px; }
.big-text { font-size: 23px; font-weight: 700; margin: 10px 0 6px; }
.err-text { color: var(--err); font-weight: 600; margin: 10px 0 0; }

.card { background: var(--card); border-radius: var(--r); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.label { font-size: 16px; font-weight: 600; color: var(--muted); margin: 0 0 8px 2px; }

.input { width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px;
  font-size: 19px; background: var(--field); color: var(--text); }
.input:focus, .field input:focus, .field textarea:focus, .search-box input:focus { outline: 3px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.big-input { font-size: 28px; letter-spacing: .25em; text-align: center; min-height: 64px; }
textarea.input { min-height: 34dvh; resize: vertical; line-height: 1.45; }
.composer textarea.input { min-height: 30dvh; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.btn { appearance: none; border: 0; border-radius: 16px; font-weight: 650; font-size: 19px;
  min-height: 60px; padding: 12px 18px; cursor: pointer; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; user-select: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.primary:disabled { opacity: .4; }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.soft:active { filter: brightness(.95); }
.btn.plain { background: transparent; color: var(--muted); }
.btn.huge { min-height: 64px; font-size: 21px; border-radius: 18px; }
.btn.small { min-height: 48px; font-size: 17px; width: auto; padding: 8px 16px; border-radius: 12px; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 17px; padding: 10px 4px; cursor: pointer; }
.links { display: flex; justify-content: space-between; margin-top: 6px; }
.links .link:only-child, .links #manual-btn { margin-left: auto; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 20px; width: 44px; height: 44px; cursor: pointer; border-radius: 12px; }

.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 72%, transparent); }
.bottom .inner { max-width: 560px; margin: 0 auto; }
.bottom .btn { box-shadow: 0 8px 24px rgba(15,118,110,.25); }

.topbar { display: flex; align-items: center; min-height: 52px; }
.back { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--accent);
  font-size: 19px; font-weight: 600; padding: 10px 8px 10px 0; cursor: pointer; }

/* thumbnails */
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs:not(:empty) { margin-top: 12px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 17px; padding: 0; cursor: pointer; }

/* chips */
.chips { display: flex; gap: 8px; }
.wrap-chips { flex-wrap: wrap; }
.scroll-chips { overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 2px 16px; }
.scroll-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; min-height: 46px; padding: 8px 16px; font-size: 17px; font-weight: 550; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.chip span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.add { border-style: dashed; color: var(--accent); }
.chip .x { opacity: .6; font-size: 15px; padding-left: 2px; }
.quick { margin: 8px 0 0; }
.quick .chip { min-height: 40px; font-size: 16px; padding: 6px 13px; background: var(--field); }

/* fields */
.group-title { font-size: 20px; font-weight: 700; margin: 24px 4px 10px; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 16px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.field input, .field textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px;
  font-size: 19px; background: var(--field); color: var(--text); min-height: 56px; }
.field textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.field.missing input, .field.missing textarea { border-color: var(--warn-line); background: var(--warn-soft); }
.field.missing label::after { content: " · впишите"; color: var(--warn); }
.field.optional.missing input { border-color: var(--line); background: var(--field); }
.field.optional.missing label::after { content: " · если есть"; color: var(--muted); font-weight: 400; }
.hint { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 16px; flex-wrap: wrap; }
.step-btn { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; min-width: 52px; min-height: 44px;
  font-size: 22px; font-weight: 600; color: var(--accent); cursor: pointer; }

.entity-line { margin-top: 14px; font-size: 17px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }

.banner { border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; font-size: 17px; line-height: 1.4; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.banner.err { background: var(--err-soft); color: var(--err); }

details.src summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 17px; list-style: none; }
details.src summary::-webkit-details-marker { display: none; }
details.src summary::before { content: "▸ "; }
details.src[open] summary::before { content: "▾ "; }
details.src pre { white-space: pre-wrap; word-break: break-word; font: 16px/1.45 inherit; font-family: inherit; color: var(--muted); margin: 12px 0 0; }

/* search */
.search-box { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 0 14px; margin-bottom: 12px; color: var(--muted); }
.search-box input { flex: 1; border: 0; background: none; font-size: 18px; min-height: 54px; outline: none; color: var(--text); min-width: 0; }

/* job list */
.day { font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 6px 8px; }
.job { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer; display: block; width: 100%; text-align: left; }
.job:active { filter: brightness(.98); }
.job .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.job .name { font-size: 19px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.job .time { color: var(--muted); font-size: 15px; white-space: nowrap; padding-top: 3px; }
.job .sub { color: var(--muted); font-size: 16px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .bottom-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.job .bottom-row .btn { margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 650; border-radius: 999px; padding: 5px 12px; }
.pill.wait { background: var(--blue-soft); color: var(--blue); }
.pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.error { background: var(--err-soft); color: var(--err); }
.tag { font-size: 14px; font-weight: 600; border-radius: 8px; padding: 3px 9px; background: var(--field); color: var(--muted); border: 1px solid var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* wait / done */
.wait-card { padding: 36px 18px; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.done-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 6px auto 4px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: 0; padding-top: 0; }
.file-row:last-child { padding-bottom: 0; }
.file-row .n { flex: 1; min-width: 0; font-size: 17px; word-break: break-word; }
.ftype { font-size: 13px; font-weight: 800; padding: 4px 8px; border-radius: 8px; background: var(--err-soft); color: var(--err); }
.ftype.docx { background: var(--blue-soft); color: var(--blue); }
.quote { font-style: italic; color: var(--muted); font-size: 17px; white-space: pre-wrap; margin: 4px 6px 18px; }

/* install */
.install-row { display: flex; align-items: center; gap: 14px; }
.app-icon { border-radius: 12px; }

/* sheets */
.sheet-bg { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.45); display: flex; flex-direction: column;
  justify-content: flex-end; padding: 16px 12px calc(12px + var(--safe-b)); }
.sheet { background: var(--card); border-radius: 24px; padding: 22px; max-width: 560px; margin: 0 auto; width: 100%; }
.sheet .btn + .btn { margin-top: 10px; }
.steps { margin: 0; padding-left: 26px; font-size: 19px; } .steps li { margin-bottom: 14px; }
.sheet-arrow { text-align: center; color: #fff; font-size: 40px; line-height: 1; margin-top: 8px; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }

.toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -20px);
  background: var(--text); color: var(--bg); padding: 14px 20px; border-radius: 16px; font-size: 17px; font-weight: 600; opacity: 0;
  transition: .25s; pointer-events: none; z-index: 30; width: max-content; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.mt-group { margin-top: 24px; }
