/* Base layout of the interface (taken from the click prototype public/entwuerfe/stile/basis.css). */
:root {
  --ground: #F7F5F0; --sidebar: #F0ECE3; --surface: #FFFFFF; --list: #FBFAF7;
  --line: #E2DDD1; --border: #D8D2C4; --text: #1E1E1C; --muted: #5E5A52;
  --accent: #0F766E; --on-accent: #FFFFFF; --accent-soft: #E3F1EF;
  --skel: #DDD7CA; --skel-light: #ECE8DF; --avatar: #E6E1D6;
  --r: 10px; --r-large: 14px;
  --body-font: system-ui, sans-serif; --heading-font: var(--body-font);
  --shadow: 0 1px 2px rgba(0,0,0,.08);
  font-family: var(--body-font);
  accent-color: var(--accent);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.brand { font-family: var(--heading-font); font-weight: 600; font-size: 22px; }
kbd { font-family: ui-monospace, monospace; font-size: 11px; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }

.hint { position: fixed; right: 12px; bottom: 12px; z-index: 50; background: #111; color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 8px; opacity: .92; display: flex; gap: 6px; align-items: center; }
.hint a { color: #fff; text-decoration: none; padding: 2px 7px; border-radius: 5px; border: 1px solid rgba(255,255,255,.3); }
.hint a[aria-current] { background: #fff; color: #111; }

/* Layout */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 24px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100dvh; }
.sidebar .brand { padding: 0 12px 16px; }
.command-button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; margin: 0 0 14px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer; }
.nav { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.nav:hover { background: rgba(127,127,127,.1); }
.nav[aria-current] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.nav svg { flex-shrink: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.capture { white-space: nowrap; margin-top: 14px; min-height: 44px; border: 0; border-radius: var(--r); background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; }
.spacer { flex-grow: 1; }
.topbar { display: none; }

/* Contacts: list + detail */
.contacts { display: grid; grid-template-columns: clamp(380px, 33vw, 480px) 1fr; min-height: 100dvh; }
.list { background: var(--list); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-head { padding: 24px 20px 12px; display: grid; gap: 14px; position: sticky; top: 0; background: var(--list); z-index: 1; }
.search { height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.skel-list { display: grid; padding: 0 10px 20px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--r); border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer; }
.row:hover { background: var(--surface); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--avatar); flex-shrink: 0; }
.bars { display: grid; gap: 8px; flex-grow: 1; }
.b1 { display: block; height: 12px; border-radius: 6px; background: var(--skel); width: var(--a, 60%); }
.b2 { display: block; height: 9px; border-radius: 5px; background: var(--skel-light); width: var(--b, 35%); }

.detail { background: var(--surface); padding: 32px 40px; display: flex; flex-direction: column; gap: 24px; }
.detail-head { display: flex; align-items: center; gap: 20px; }
.avatar-large { width: 72px; height: 72px; border-radius: 50%; background: var(--avatar); flex-shrink: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.timeline { display: grid; }
.entry { display: flex; gap: 16px; }
.entry .track { display: flex; flex-direction: column; align-items: center; width: 28px; }
.entry .node { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); flex-shrink: 0; }
.entry .stroke { width: 2px; flex-grow: 1; background: var(--skel-light); }
.entry .bars { padding: 4px 0 26px; }
.back { display: none; }

/* Other views */
.page { padding: 32px 40px; display: grid; gap: 24px; align-content: start; max-width: 1200px; }
.page h1 { font-family: var(--heading-font); font-size: 32px; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-large); padding: 20px; display: grid; gap: 14px; align-content: start; }
.card h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600; }
.card .row { padding: 8px 0; }

/* Contact care */
.care-list { padding: 8px 20px; }
.care-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.care-row:last-child { border-bottom: 0; }
.reason-tag { display: block; width: 150px; height: 22px; border-radius: 11px; background: var(--accent-soft); }
.care-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.care-actions .btn { min-height: 40px; padding: 0 14px; }

/* Templates with editor */
.templates-page { max-width: none; }
.templates { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.template-list { padding: 16px; gap: 6px; }
.category { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 4px 2px; }
.template-row { padding: 10px; }
.editor { padding: 22px; gap: 16px; }
.editor-head { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.field select { min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--ground); }
.toolbar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 6px; border: 1px solid var(--border); border-radius: var(--r); background: var(--ground); }
.toolbar button { min-width: 40px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.toolbar button:hover { background: var(--accent-soft); }
.separator { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.template-vars { display: flex; gap: 6px; flex-wrap: wrap; }
.template-vars span { font-family: ui-monospace, monospace; font-size: 12px; padding: 4px 8px; border-radius: 6px; border: 1px dashed var(--border); color: var(--muted); cursor: grab; }
.block { display: grid; gap: 10px; padding: 16px; border-radius: var(--r); border: 1px solid var(--line); }
.block.variable { border: 2px dashed var(--accent); background: var(--accent-soft); }
.block-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.block-type { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.block.variable .block-type { color: var(--accent-text, var(--accent)); }
.block .muted { font-size: 13px; }
.attachments { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.attachment { font-size: 13px; padding: 8px 12px; border-radius: var(--r); background: var(--ground); border: 1px solid var(--line); }
.attachment-new { display: inline-flex; align-items: center; min-height: 36px; font-size: 13px; }

/* Global search */
.hit { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: 8px; }
.hit:hover { background: var(--accent-soft); }
.hit .avatar { width: 30px; height: 30px; }
.hit .bars { gap: 5px; min-width: 120px; }
.source { font-size: 11px; font-weight: 600; letter-spacing: .03em; padding: 3px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.source.q-inbox { border-style: dashed; }
.source.q-directory { border-color: var(--muted); }
.source.q-google { border-color: transparent; background: var(--ground); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.duplicate-hint { flex-basis: 100%; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-left: 40px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent-soft); font-size: 13px; }
.duplicate-hint .btn { min-height: 32px; padding: 0 12px; }

/* Data care */
.counter { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
.tabs { flex-wrap: wrap; column-gap: 24px; }
.tabs .counter { margin-left: 6px; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Outbox */
.outbox { padding: 6px 20px; }
.outbox-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; grid-template-areas: "prio text zeit" "prio status aktion"; gap: 8px 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.outbox-row .prio { grid-area: prio; align-self: start; }
.outbox-row .bars { grid-area: text; }
.outbox-row .status { grid-area: status; }
.outbox-row .time { grid-area: zeit; justify-self: end; }
.outbox-row .outbox-actions { grid-area: aktion; }
.outbox-row:last-child { border-bottom: 0; }
.outbox-row.series .bars { gap: 6px; }
.prio { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 10px; justify-self: start; white-space: nowrap; border: 1px solid var(--border); color: var(--muted); }
.prio.p1 { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.prio.p2 { border-color: var(--accent); color: var(--accent-text, var(--accent)); }
.status { font-size: 13px; }
.status.recall, .status.scheduled { color: var(--accent-text, var(--accent)); }
.status.error { color: #FF8A80; }
.time { font-size: 13px; color: var(--muted); }
.outbox-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.limits div { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); }
.send-time legend { margin-bottom: 8px; }
.tile small { display: block; font-weight: 400; }
.custom-time { flex-wrap: wrap; grid-column: span 2; }
.datetime { flex-basis: 100%; width: 100%; min-width: 0; box-sizing: border-box; min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--ground); color: var(--text); color-scheme: inherit; }
.small-text { font-size: 13px; margin: -8px 0 0; }
.time-presets { display: grid; gap: 8px; }
.time-preset { display: grid; grid-template-columns: 220px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); }
.new-time-preset { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: 12px; align-items: end; padding-top: 6px; }
.new-time-preset .field select, .new-time-preset .field input { min-height: 44px; }
.send-at { margin-bottom: 16px; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stages li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.stages li strong { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--skel-light); font-size: 12px; flex-shrink: 0; }
.stages li.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.stages li.active strong { background: var(--accent); color: var(--on-accent); }
@media (max-width: 1023px) { .stages { grid-template-columns: 1fr 1fr; } }
.progress { display: grid; gap: 6px; font-size: 13px; color: var(--muted); min-width: 260px; }
.progress-bar { display: block; height: 6px; border-radius: 3px; background: var(--skel-light); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pair:last-child { border-bottom: 0; }
.pair-side { display: flex; gap: 10px; align-items: center; }
.pair-side .source { justify-self: start; }
.pair-middle { display: grid; justify-items: center; gap: 2px; }
.equals { font-size: 22px; color: var(--accent-text, var(--accent)); }
.confidence { font-size: 12px; font-weight: 700; }
.pair-reason { grid-column: 1 / -1; font-size: 13px; }
.pair-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.pair-actions .btn { min-height: 38px; }
.import-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.import-option { display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px dashed var(--border); border-radius: var(--r); cursor: pointer; }
.import-option .btn { justify-self: start; display: inline-flex; align-items: center; }

/* Duplicate comparison */
.compare { display: grid; gap: 2px; }
.compare-head, .compare-row { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 10px; align-items: center; }
.compare-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.compare-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.compare-row.usage { font-size: 13px; }
.field-name { font-size: 13px; color: var(--muted); }
.recommended { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 9px; background: var(--accent); color: var(--on-accent); margin-left: 6px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border: 2px solid var(--border); border-radius: var(--r); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.choice .b1 { flex-grow: 1; max-width: var(--a); }

.more { width: min(420px, calc(100vw - 24px)); }
.more form { gap: 4px; }
.more .btn { margin-top: 10px; }
.mail-preview { display: grid; gap: 10px; padding: 16px; border-radius: var(--r-large); border: 1px solid var(--line); background: var(--ground); }
.mail-meta { font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tile input[type="radio"] { border-radius: 50%; }

/* Dialogs */
dialog { border: 0; border-radius: 16px; padding: 24px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 14px; }
dialog h2 { margin: 0; font-family: var(--heading-font); }
.field { display: grid; gap: 6px; }
.field input, .field textarea { min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--ground); }
.photo { min-height: 120px; border: 2px dashed var(--border); border-radius: var(--r-large); display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.commands { width: min(620px, calc(100vw - 32px)); padding: 10px; margin-top: 12vh; }
.commands form { gap: 2px; }
.command-input { height: 52px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 17px; margin-bottom: 6px; }
.command-input:focus { outline: none; }
.command-group { font-size: 12px; color: var(--muted); padding: 10px 12px 4px; }
.command { min-height: 42px; text-align: left; padding: 0 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.command:hover, .command:focus-visible { background: var(--accent-soft); }
.commands .row { padding: 6px 12px; }

/* Wizard with large selection tiles (touch): tap = on/off, multiple choice, "Apply and continue" at the bottom */
.wizard { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 28px; }
.wizard form { gap: 18px; }
.wizard-head { display: grid; gap: 4px; }
.wizard-head h2 { font-size: 22px; }
.step { font-size: 13px; color: var(--accent); font-weight: 600; }
.muted { margin: 0; color: var(--muted); font-size: 14px; }
.tiles { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--r-large); background: var(--surface); cursor: pointer; font-weight: 500; user-select: none; -webkit-tap-highlight-color: transparent; transition: border-color .12s, background-color .12s, transform .08s; }
.tile:active { transform: scale(.98); }
.tile input:is([type="checkbox"], [type="radio"]) { appearance: none; flex-shrink: 0; width: 26px; height: 26px; margin: 0; border: 2px solid var(--border); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.tile input:is([type="checkbox"], [type="radio"])::after { content: ""; width: 7px; height: 12px; border: solid var(--on-accent); border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); opacity: 0; }
.tile input:checked { background: var(--accent); border-color: var(--accent); }
.tile input:checked::after { opacity: 1; }
.tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile.other { border-style: dashed; color: var(--muted); }
.wizard-foot { display: flex; gap: 10px; justify-content: space-between; padding-top: 6px; position: sticky; bottom: -28px; background: var(--surface); padding-bottom: 4px; }
.btn.large { min-height: 56px; padding: 0 28px; font-size: 17px; flex-grow: 1; max-width: 360px; }

/* Phone */
.bottom-nav { display: none; }
@media (max-width: 1023px) {
  body .app { grid-template-columns: 1fr; padding-top: 0; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body .sidebar { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--sidebar); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  body .contacts { grid-template-columns: 1fr; min-height: auto; }
  .detail { display: none; padding: 20px 16px; }
  body.detail-open .detail { display: flex; }
  body.detail-open .list { display: none; }
  .back { display: inline-flex; align-items: center; align-self: flex-start; }
  .page { padding: 20px 16px; }
  .list-head { position: static; padding: 16px; }
  .bottom-nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav :is(a, button) { min-height: 64px; border: 0; background: none; display: grid; place-items: center; font-size: 11px; color: var(--muted); cursor: pointer; }
  .bottom-nav :is(a, button)[aria-current] { color: var(--accent); font-weight: 600; }
  .bottom-nav .plus span { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 24px; }
  .templates, .editor-head { grid-template-columns: 1fr; }
  .pair { grid-template-columns: 1fr; }
  .time-preset { grid-template-columns: 1fr auto; }
  .time-preset .muted { grid-column: 1 / -1; }
  .new-time-preset { grid-template-columns: 1fr; }
  .outbox-row { grid-template-columns: 1fr auto; grid-template-areas: "prio zeit" "text text" "status status" "aktion aktion"; }
  .outbox-actions { justify-content: flex-start; }
  .pair-middle { justify-items: start; grid-auto-flow: column; gap: 8px; align-items: center; }
  .compare-head, .compare-row { grid-template-columns: 1fr 1fr; }
  .compare-head > span:first-child { display: none; }
  .field-name { grid-column: 1 / -1; }
  .duplicate-hint { margin-left: 0; }
  .care-row { flex-wrap: wrap; }
  .care-actions { width: 100%; justify-content: flex-start; }
  .hint { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); right: 8px; font-size: 0; gap: 4px; padding: 5px; }
  .hint a { font-size: 12px; }
}
