/* Components. One look for each thing: buttons, fields, cards, badges,
   notices, tabs, dialogs, toasts, pickers. Tables are in table.css. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-1); }
.card + .card { margin-top: 16px; }
.card > h2:first-child { margin-top: -2px; }
.card .cardhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card .cardhead h2 { margin: 0; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
  font: inherit; font-weight: 560; font-size: .92rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--bad); border-color: var(--line-strong); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
button.small, .btn.small { height: 30px; padding: 0 10px; font-size: .85rem; }
button.icon { width: 36px; padding: 0; }
button.icon.small { width: 30px; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

label.f { display: block; font-size: .85rem; font-weight: 560; color: var(--ink-2); }
label.f > span { display: block; margin-bottom: 5px; }
label.f small { display: block; margin-top: 5px; font-weight: 400; }
input, select, textarea { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=email], input[type=number], input[type=password], input[type=tel], input[type=url],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { height: auto; min-height: 110px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: .82rem; min-height: 420px; tab-size: 2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0 8px 0 0; vertical-align: -3px; }
.check { display: inline-flex; align-items: center; min-height: 32px; color: var(--ink); font-size: .95rem; font-weight: 400; }
.inputicon { position: relative; }
.inputicon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.inputicon input { padding-left: 36px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 620; white-space: nowrap; background: var(--surface-3); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--ink); margin-bottom: 14px; }
.notice > svg { flex: none; margin-top: 2px; color: var(--info); }
.notice.warn { background: var(--warn-soft); } .notice.warn > svg { color: var(--warn); }
.notice.bad { background: var(--bad-soft); } .notice.bad > svg { color: var(--bad); }
.notice.ok { background: var(--ok-soft); } .notice.ok > svg { color: var(--ok); }
.notice p:last-child { margin: 0; }

.empty { text-align: center; padding: 44px 16px; color: var(--ink-3); }
.empty svg { color: var(--ink-3); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 4px; }
.empty p { max-width: 30rem; margin: 0 auto 14px; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { height: 40px; border: 0; border-radius: 0; background: transparent; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { background: transparent; color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { height: 30px; border: 0; background: transparent; color: var(--ink-2); padding: 0 12px; font-size: .86rem; }
.seg button:hover { background: var(--surface-3); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg .count { color: var(--ink-3); font-weight: 500; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 22px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-3); font-size: .85rem; }
.stat small { display: block; margin-top: 2px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .86rem; }
.chip button { height: 22px; width: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); }
td.nowrap { white-space: nowrap; }
.chip button:hover { background: var(--surface-3); color: var(--ink); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(36rem, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
dialog.wide { width: min(56rem, calc(100vw - 24px)); }
dialog::backdrop { background: var(--scrim); }
dialog form { padding: 22px; margin: 0; }
dialog h2 { font-size: 1.15rem; margin-bottom: 14px; }
dialog .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 20px; }

#toasts { position: fixed; z-index: 50; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 30rem; padding: 11px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2); font-weight: 520; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* Typeahead picker (combo.js). */
.combo { position: relative; }
.combo .pop {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 18rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-2); padding: 4px;
}
.combo [role=option] { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo [role=option] small { flex: none; }
.combo [role=option][aria-selected="true"] { background: var(--surface-2); }
.combo [role=option].on { color: var(--accent); font-weight: 600; }
.combo .none { padding: 10px; color: var(--ink-3); }
.combo .chips { margin-top: 8px; }

/* Steps: what a draft still needs before it can be sent. */
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 4px 14px; align-items: start; }
.step .mark {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: .85rem;
  background: var(--surface-3); color: var(--ink-2);
}
.step.done .mark { background: var(--ok-soft); color: var(--ok); }
.step.todo .mark { background: var(--warn-soft); color: var(--warn); }
.step h3 { margin: 3px 0 2px; font-size: 1rem; }
.step .body { color: var(--ink-2); font-size: .92rem; }
.step .act { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) { .step { grid-template-columns: 32px minmax(0, 1fr); } .step .act { grid-column: 2; justify-content: flex-start; } }

.preview, .thumb iframe { color-scheme: light; }
.thumb.open { cursor: zoom-in; }
.preview { width: 100%; height: 72vh; min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--preview-bg); display: block; }
.preview.phone { width: 390px; max-width: 100%; margin: 0 auto; }
.thumb { position: relative; max-width: 640px; height: 260px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--preview-bg); }
.thumb iframe { width: 200%; height: 520px; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; }
pre.plain { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0; font-size: .85rem; max-height: 50vh; overflow: auto; }

.feed { display: flex; flex-direction: column; }
.feed .item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.feed .item:first-child { border-top: 0; }
.feed .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.feed .ico.ok { background: var(--ok-soft); color: var(--ok); } .feed .ico.bad { background: var(--bad-soft); color: var(--bad); }
.feed .ico.info { background: var(--info-soft); color: var(--info); } .feed .ico.warn { background: var(--warn-soft); color: var(--warn); }
.feed .what { font-weight: 560; }
.feed .meta { color: var(--ink-3); font-size: .85rem; overflow-wrap: anywhere; }
.feed .when { color: var(--ink-3); font-size: .85rem; white-space: nowrap; }
.feed details summary { cursor: pointer; color: var(--ink-3); font-size: .82rem; }
.feed pre { margin: 6px 0 0; font-size: .78rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.combo .clear { position: absolute; right: 4px; top: 4px; }
.tight { margin: 10px 0 0; }
.more-opts summary { cursor: pointer; color: var(--ink-3); margin-top: 10px; font-size: .9rem; }
.more-opts[open] summary { margin-bottom: 8px; }
.thumb.open:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 700px) { td .none { display: none; } }
