:root {
  color-scheme: light;
  --ink: #343147;
  --muted: #625e70;
  --brand: #655081;
  --brand-dark: #4f3b6c;
  --line: #e0d9e7;
  --paper: #fbf9fd;
  --lavender: #eee7f6;
  --peach: #f9e7dc;
  --mint: #e7f0e7;
  --focus: #7753a4;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
h1, h2, p, ul { margin: 0; }
h1 { font-size: clamp(1.6rem, 5vw, 2.35rem); line-height: 1.14; letter-spacing: -.035em; }
h2 { font-size: 1.13rem; line-height: 1.25; }
p { color: var(--muted); }
button, input, textarea, select { font: inherit; color: inherit; }
button, select, input[type="file"] { cursor: pointer; }
button { min-height: 44px; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.top { background: #fffdf9; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-inner, .shell { width: min(100%, 47rem); margin-inline: auto; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 14px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--brand-dark); font-weight: 800; font-size: 1.25rem; letter-spacing: -.05em; }
.brand img { object-fit: contain; }
select, input[type="search"], textarea {
  border: 1px solid #afa4ba; border-radius: 12px; background: #fff;
  padding: 10px 12px; width: 100%; min-height: 44px;
}
.language { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 64px; height: 44px; padding-inline: 10px; border: 1px solid var(--line); border-radius: 12px; font-size: .82rem; font-weight: 700; color: var(--brand-dark); background: #fff; }
.language select { position: absolute; inset: 0; height: 100%; opacity: 0; }
.language:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.chevron { width: 7px; height: 7px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: translateY(-2px) rotate(45deg); }
.shell { padding: 10px 14px 40px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: 14px; background: #faefd7; margin-bottom: 13px; font-size: .85rem; }
.notice strong { color: #62451d; }
.notice p { color: #58482f; }
.notice-icon { flex: 0 0 21px; height: 21px; border: 1px solid currentColor; color: #735020; text-align: center; border-radius: 50%; font-weight: 700; }
.pairing { background: #fff; border: 1px solid var(--line); border-radius: 23px; overflow: hidden; }
.pair-art { height: clamp(145px, 31vh, 240px); display: grid; grid-template: minmax(0,1fr) / minmax(0,1fr); place-items: center; background: #eee6f5; padding: 12px; }
.pair-art img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.pair-body { display: grid; gap: 14px; padding: 23px 19px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 33%); align-items: center; background: var(--lavender); border-radius: 19px; padding: 15px 14px; gap: 4px; }
.workspace-copy { display: grid; justify-items: start; gap: 8px; }
.workspace img { width: 100%; max-height: 122px; object-fit: contain; }
.workspace p { font-size: .87rem; }
.group-tag { background: #fffafc; border-radius: 8px; padding: 4px 8px; color: var(--brand-dark); font-size: .78rem; font-weight: 750; }
.connection { display: flex; align-items: center; gap: 10px; background: var(--mint); border-radius: 12px; padding: 10px 12px; }
.connection small { display: block; color: var(--muted); }
.transport { margin-block: 0 8px; font-size: .86rem; line-height: 1.3; }
.status-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #376b4b; }
.status-dot.warn { background: #9d6124; }
.card { padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.composer, .settings-card { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 700; font-size: .91rem; }
textarea { resize: vertical; min-height: 64px; }
.children { display: flex; gap: 6px; flex-wrap: wrap; }
.child { min-height: 44px; border: 1px solid #d7cbe1; border-radius: 10px; background: #faf7fc; font-size: .85rem; padding: 6px 9px; }
.child[aria-pressed="true"] { background: var(--lavender); border-color: var(--brand); color: var(--brand-dark); font-weight: 750; }
.pickers { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.picker { position: relative; min-height: 84px; border-radius: 12px; padding: 8px 5px; display: grid; place-items: center; align-content: center; gap: 4px; text-align: center; font-size: .78rem; font-weight: 700; overflow-wrap: anywhere; color: var(--brand-dark); }
.picker input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.picker:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.peach { background: var(--peach); }.lavender { background: var(--lavender); }.mint { background: var(--mint); }
.picker-icon, .tab-icon { position: relative; display: inline-block; width: 20px; height: 18px; border: 2px solid currentColor; border-radius: 4px; }
.icon-camera::after { content: ""; position: absolute; inset: 3px 4px; border: 2px solid; border-radius: 50%; }
.icon-gallery::after { content: ""; position: absolute; inset: 5px 3px 2px; background: currentColor; clip-path: polygon(0 100%, 46% 2%, 72% 60%, 90% 35%, 100% 100%); }
.icon-document { width: 15px; border-radius: 3px; }
.icon-document::after { content: ""; position: absolute; inset: 4px 2px; border-block: 1px solid; }
.icon-history { width: 18px; border-radius: 50%; }
.icon-history::after { content: ""; position: absolute; inset: 2px 6px 5px 6px; border-inline-start: 2px solid; border-bottom: 2px solid; }
.icon-settings { width: 18px; border-radius: 6px; transform: rotate(45deg); }
.icon-settings::after { content: ""; position: absolute; inset: 3px; border: 1px solid; border-radius: 50%; }
.files, .history-items { display: grid; gap: 8px; padding: 0; list-style: none; }
.files:empty, .history-items:empty { display: none; }
.file, .history-item { display: grid; align-items: center; gap: 9px; background: #f8f4fa; border-radius: 10px; padding: 6px 8px; }
.file { grid-template-columns: 44px minmax(0, 1fr) 44px; }
.file-preview { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--lavender); color: var(--brand); }
.file img { width: 100%; height: 100%; object-fit: cover; grid-area: 1 / 1; }
.file-name { display: block; overflow-wrap: anywhere; font-size: .88rem; font-weight: 650; }
.file small, .hint { color: var(--muted); font-size: .8rem; }
.remove { border: 0; background: transparent; font-size: 1.3rem; border-radius: 8px; color: var(--brand); }
.primary, .secondary { border-radius: 12px; padding: 9px 14px; font-weight: 700; border: 1px solid transparent; overflow-wrap: anywhere; }
.primary { color: white; background: var(--brand); }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.secondary { color: var(--brand-dark); background: #fff; border-color: #aaa0b5; }
.danger { justify-self: start; color: #843e4a; }
.wide { width: 100%; }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.error { color: #8a3346; font-size: .84rem; }
.queue { margin-top: 10px; display: grid; gap: 8px; scroll-margin-bottom: 40px; }
progress { width: 100%; accent-color: var(--brand); height: 11px; }
#history > h1, #settings > h1 { margin: 7px 0 15px; }
.history-item { padding: 11px; gap: 2px; }
.tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); position: fixed; z-index: 2; bottom: 0; left: 0; right: 0; margin-inline: auto; width: min(100%,47rem); background: #fffdfb; border: 1px solid var(--line); border-radius: 17px 17px 0 0; padding: 5px 7px calc(5px + env(safe-area-inset-bottom)); }
.tabs button { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 55px; border: 0; background: transparent; border-radius: 11px; color: var(--muted); font-size: .76rem; font-weight: 650; overflow-wrap: anywhere; }
.tabs [aria-current="page"] { color: var(--brand-dark); background: var(--lavender); }
dialog { width: min(90vw, 420px); border: 1px solid var(--line); border-radius: 18px; color: var(--ink); padding: 20px; }
dialog p { margin-block: 10px 18px; }
dialog::backdrop { background: #30223a70; }
@media (min-width: 620px) {
  .top-inner, .shell { padding-inline: 24px; }
  .pairing { display: grid; grid-template-columns: 45% minmax(0,1fr); }
  .pair-art { height: auto; min-height: 240px; }
  .pair-body { align-content: center; padding: 24px; }
  .card { padding: 19px; }
}

.queue-items { display: grid; gap: 9px; padding: 0; list-style: none; }
.queue-item { display: grid; gap: 6px; padding: 10px; border-radius: 11px; background: #f8f4fa; }
.queue-item p { font-size: .89rem; }
.queue-item .inline-actions button { font-size: .85rem; }

.file-preview > .picker-icon { grid-area: 1 / 1; }

/* M-003R upload app */
input[type="text"], input[type="url"] { border: 1px solid #afa4ba; border-radius: 12px; background: #fff; padding: 10px 12px; width: 100%; min-height: 44px; }
.install-body { display: grid; gap: 6px; }
.notice .install-body p { color: #58482f; }
.queue-item[data-status="done"] { background: var(--mint); }
.queue-item[data-status="failed"] { background: #fbecee; }
.workspace-copy p { font-size: .82rem; }

/* C-003 compact capture */
.optional { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.optional input { font-size: .9rem; }
.notice.compact { display: block; margin-bottom: 8px; }
.queue h2 { font-size: 1rem; }
.queue-item[data-status="stopped"] { background: #faefd7; }
.danger-fill { background: #8a3346; }
.danger-fill:hover:not(:disabled) { background: #6f2738; }
.dialog-actions { justify-content: flex-end; }
dialog h2 { font-size: 1.05rem; }
/* C-004: lost-capture notice and the opt-in diagnostics panel */
#capture-lost { flex-direction: column; align-items: stretch; }
.diagnostics { margin-top: 16px; }
.diagnostics h2 { font-size: 1rem; margin: 0 0 6px; }
.diagnostics p { font-size: .85rem; color: var(--muted); }
.diagnostics pre { max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: .7rem; background: var(--lavender); padding: 8px; border-radius: 8px; user-select: text; }
/* C-005 optional child tagging: compact chips, wrap on narrow screens, bounded height for large groups */
.tagging { display: grid; gap: 6px; }
.tagging-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.tagging h2 { font-size: .92rem; margin-right: auto; }
#tagging-count { font-weight: 650; color: var(--brand-dark); }
.link-button { min-height: 44px; border: 0; background: transparent; color: var(--brand-dark); font-weight: 700; text-decoration: underline; padding: 0 4px; }
.tagging .children { max-height: min(40vh, 260px); overflow-y: auto; padding: 2px; }
.tagging .child { min-width: 44px; touch-action: manipulation; }
.tagging .child[aria-pressed="true"]::before { content: "✓ "; }
.tagging input[type="search"] { font-size: .9rem; }
#tagging-status { font-size: .82rem; }
/* D-009: group name in the header and the permanent installation entry point (hidden in the installed app). */
.brand { min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.install-later { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--brand-dark); font: inherit; font-size: 1.5rem; font-weight: 700; line-height: 1; }
.install-later:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
