/* Tresor v2 – Konversation: ein Baustein für erste Nachricht und Antworten.
   Baut auf style.css auf (Tokens --card, --line, --muted, --accent, --r …). */
:root {
  --tk-them: #2f7d6b;
  --tk-mine-bg: #faf6f2;
  --tk-soft: #f1ebe5;
  --tk-once: #a55a12;
  --tk-once-bg: #fff6e8;
  --tk-once-line: #e8b44e;
  --tk-redact: #1c1410;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tk-them: #5cc2aa;
    --tk-mine-bg: #231913;
    --tk-soft: #2a1f18;
    --tk-once: #f2a65a;
    --tk-once-bg: #33230f;
    --tk-once-line: #8a6420;
    --tk-redact: #6b5a4e;
  }
}
:root[data-theme="dark"] {
  --tk-them: #5cc2aa;
  --tk-mine-bg: #231913;
  --tk-soft: #2a1f18;
  --tk-once: #f2a65a;
  --tk-once-bg: #33230f;
  --tk-once-line: #8a6420;
  --tk-redact: #6b5a4e;
}
[hidden] { display: none !important; }
.tk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tk-sp { flex: 1; }
.tk-hint { font-size: 0.76rem; color: var(--muted); }
.tk-hint--once { color: var(--tk-once); }

/* Erstellen */
.tk-linkblock { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.9rem 0 0.4rem; }
.tk-linkblock .tr-bookmark { margin: 0.4rem 0 0; }

/* Kopf */
.tk-conv { display: flex; flex-direction: column; gap: 1rem; }
.tk-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1rem; }
.tk-head h1 { margin: 0; }
.tk-facts { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.8rem; color: var(--muted); }
.tk-fact { display: inline-flex; align-items: center; gap: 0.3rem; }
.tk-lock { color: var(--muted); padding: 0.2rem; border-radius: var(--r); }
.tk-lock:hover { color: var(--accent); }
.tk-lock svg { width: 15px; height: 15px; }
.tk-burn { border: 1px solid transparent; background: none; font: inherit; color: var(--muted); cursor: pointer; padding: 0.15rem 0.45rem; border-radius: var(--r); }
.tk-burn:hover { border-color: var(--line); }
.tk-burn-ico { font-size: 0.95rem; line-height: 1; }
.tk-burn.is-confirm { border-color: var(--err); }
.tk-burn.is-confirm .tr-count { color: var(--err); font-family: inherit; }
.tk-facts { align-items: center; }
.tk-fact svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.tk-fact .tr-count { font-size: 0.85rem; }

.tk-note { background: var(--card); border: 1px dashed var(--line); border-radius: var(--r); padding: 0.8rem 0.9rem; font-size: 0.88rem; }
.tk-note p { margin: 0 0 0.5rem; color: var(--muted); }

/* Verlauf */
.tk-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.65rem; position: relative; }
.tk-thread.is-multi::before { content: ""; position: absolute; left: 19px; top: 22px; bottom: 22px; width: 1px; background: var(--line); }
.tk-msg, .tk-composer { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 0.75rem; position: relative; }
.tk-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 0.85rem; font-weight: 800; color: var(--on-ink); position: relative; z-index: 1; border: 3px solid var(--bg); }
.tk-av--me { background: var(--ink); }
.tk-av--them { background: var(--tk-them); }
.tk-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 0.75rem 0.9rem 0.8rem; min-width: 0; box-shadow: 0 6px 18px var(--shadow); }
.tk-msg.is-mine .tk-box { background: var(--tk-mine-bg); }
.tk-msg.is-once .tk-box { border-color: var(--tk-once-line); }
.tk-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.5rem; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.tk-meta b { color: var(--ink); font-size: 0.84rem; }
.tk-msg:not(.is-mine) .tk-meta b { color: var(--tk-them); }
.tk-chip { display: inline-flex; align-items: center; font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: var(--r); background: var(--tk-soft); color: var(--muted); }
.tk-chip--first { background: var(--tk-soft); }
.tk-chip--once { background: var(--tk-once-bg); color: var(--tk-once); }
.tk-chip--read { background: transparent; color: var(--ok); padding: 0.05rem 0; }
.tk-copy { border: 1px solid transparent; background: none; color: var(--muted); border-radius: var(--r); width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; }
.tk-copy:hover { border-color: var(--line); color: var(--ink); }
.tk-body { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 0.95rem; }

.tk-locked { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
.tk-redact { display: flex; flex-direction: column; gap: 0.35rem; width: 100%; }
.tk-redact i { display: block; height: 0.7em; border-radius: 3px; background: var(--tk-redact); opacity: 0.85; }
.tk-reveal svg, .tk-gone svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; flex: none; }
.tk-gone { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; border: 1px dashed var(--tk-once-line); border-radius: var(--r); background: var(--tk-once-bg); color: var(--tk-once); font-size: 0.85rem; }
.tk-gone--now { margin-top: 0.6rem; }

/* Composer: derselbe Baustein, leer */
.tk-composer .tk-box { padding: 0.6rem; }
.tk-composer .tk-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.tk-composer-label { display: block; font-size: 0.76rem; color: var(--muted); padding: 0.1rem 0.25rem; }
.tk-composer textarea { width: 100%; border: 0; background: transparent; color: var(--ink); resize: vertical; min-height: 4rem; font: inherit; padding: 0.25rem; }
.tk-composer textarea:focus { outline: none; }
.tk-bar { display: flex; align-items: center; gap: 0.5rem; border-top: 1px solid var(--tk-soft); padding-top: 0.5rem; margin-top: 0.25rem; }
.tk-send { padding: 0.5rem 0.95rem; }
.tk-send:disabled { opacity: 0.45; cursor: not-allowed; }
.tk-senderr { margin: 0.5rem 0 0; }

.tk-actions { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.tk-danger:hover { border-color: var(--err); color: var(--err); }
.tk-danger.is-confirm { background: var(--err); border-color: var(--err); color: var(--on-accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 460px) {
  .tk-msg, .tk-composer { grid-template-columns: 30px minmax(0, 1fr); gap: 0 0.55rem; }
  .tk-av { width: 30px; height: 30px; font-size: 0.72rem; border-width: 2px; }
  .tk-thread.is-multi::before { left: 14px; }
  .tk-bar { flex-wrap: wrap; }
}

/* ── Phase 2: Kopf-Navigation, Konto ─────────────────────────────── */
.tk-topnav { display: flex; align-items: center; gap: 0.5rem; }
.tk-navbtn { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.tk-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.tk-check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.tk-check input { margin-top: 0.25rem; accent-color: var(--accent); }
.tk-code-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.5rem; letter-spacing: 0.35em; text-align: center; }
.tk-recovery { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.05em; background: var(--tk-soft); border: 1px dashed var(--line); border-radius: var(--r); padding: 0.9rem; text-align: center; word-break: break-all; user-select: all; }
.tk-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.tk-linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
.tk-linkbtn:hover { color: var(--ink); }

.tk-accbar { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.tk-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.tk-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0.8rem; align-items: center; padding: 0.8rem 0.95rem; }
.tk-item + .tk-item { border-top: 1px solid var(--tk-soft); }
.tk-item-title { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-item-sub { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: center; font-size: 0.76rem; color: var(--muted); grid-column: 1; }
.tk-item-actions { display: flex; gap: 0.4rem; grid-column: 2; grid-row: 1 / span 2; align-items: center; }
.tk-item-actions .tr-btn { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
.tk-item.is-dead .tk-item-title { color: var(--muted); }
.tk-st { font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: var(--r); background: var(--tk-soft); color: var(--muted); }
.tk-st--active { background: var(--ok-bg); color: var(--ok); }
.tk-st--waiting { background: var(--info-bg); color: var(--info); }
.tk-st--expired, .tk-st--gone, .tk-st--broken { background: var(--err-bg); color: var(--err); }
.tk-badge-new { font-size: 0.7rem; font-weight: 800; padding: 0.05rem 0.45rem; border-radius: 99px; background: var(--accent); color: var(--on-accent); }
.tk-rename { grid-column: 1 / -1; display: flex; gap: 0.4rem; }
.tk-rename .tr-input { padding: 0.45rem 0.6rem; font-size: 0.9rem; }
.tk-savebar { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; font-size: 0.85rem; }
.tk-savebar .tr-btn { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.tk-saved { color: var(--ok); font-weight: 700; }
.tk-danger-zone summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.tk-danger-zone[open] summary { margin-bottom: 0.5rem; }
@media (max-width: 520px) {
  .tk-item { grid-template-columns: minmax(0, 1fr); }
  .tk-item-actions { grid-column: 1; grid-row: auto; }
}
.tk-labelfield { margin-top: 0.9rem; display: flex; }
.tr-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tk-recovery { word-break: normal; overflow-wrap: break-word; }

/* ── Phase 3: Anhänge ────────────────────────────────────────────── */
.tk-iconbtn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: var(--r); width: 34px; height: 32px; display: grid; place-items: center; cursor: pointer; flex: none; }
.tk-iconbtn:hover { background: var(--tk-soft); }
.tk-iconbtn svg, .tk-attadd svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tk-attrow { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
.tk-attadd { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.tk-attttl { font-size: 0.78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.4rem; }
.tk-attrow .tk-attttl { margin-top: 0; }
.tk-attttl select { font: inherit; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink); padding: 0.15rem 0.3rem; }
.tk-pending { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0; }
.tk-pending-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.76rem; border: 1px solid var(--line); border-radius: var(--r); padding: 0.1rem 0.2rem 0.1rem 0.5rem; background: var(--card); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-pending-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 0.1rem 0.3rem; }
.tk-atterr { font-size: 0.8rem; color: var(--tk-once); background: var(--tk-once-bg); border-radius: var(--r); padding: 0.45rem 0.6rem; margin: 0.4rem 0 0; }

.tk-att { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; }
.tk-file { display: flex; align-items: center; gap: 0.6rem; border: 1px solid var(--line); border-radius: var(--r); padding: 0.45rem 0.55rem; max-width: 420px; background: var(--card); }
.tk-file.is-gone { opacity: 0.65; border-style: dashed; }
.tk-fi { width: 32px; height: 38px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 3px; font-size: 0.58rem; font-weight: 800; color: var(--accent); letter-spacing: 0.03em; background: var(--card); }
.tk-fn { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.tk-fn div { font-weight: 600; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-fn small { color: var(--muted); font-size: 0.74rem; }
.tk-att-dl { color: var(--ok) !important; }
.tk-att-btn { padding: 0.35rem 0.65rem; font-size: 0.8rem; white-space: nowrap; }
.tk-img { margin: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; max-width: 420px; background: var(--tk-soft); }
.tk-img img { display: block; width: 100%; height: auto; }
.tk-img figcaption { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.74rem; color: var(--muted); padding: 0.3rem 0.5rem; border-top: 1px solid var(--line); background: var(--card); }

.tk-files { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.6rem; }
.tk-files .tk-head h2 { margin: 0; }
.tk-quota { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 0.8rem 0.95rem; display: flex; flex-direction: column; gap: 0.5rem; }
.tk-quota-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.tk-quota-num { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tk-quota-num small { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.tk-meter { height: 8px; border-radius: 99px; background: var(--tk-soft); overflow: hidden; }
.tk-meter i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width 0.35s ease; }
.tk-frow { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; gap: 0.4rem 0.8rem; align-items: center; padding: 0.7rem 0.95rem; transition: opacity 0.25s; }
.tk-frow + .tk-frow { border-top: 1px solid var(--tk-soft); }
.tk-frow.is-burning { opacity: 0.2; }
.tk-frow-main { min-width: 0; }
.tk-burnat { text-align: right; font-size: 0.74rem; color: var(--muted); line-height: 1.35; display: flex; flex-direction: column; }
.tk-burnat .tr-count { font-size: 0.85rem; }
.tk-burnat .tr-count.is-soon { color: var(--tk-once); }
.tk-shorten { font: inherit; font-size: 0.78rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink); padding: 0.3rem 0.3rem; }
.tk-fst--downloaded { background: transparent; color: var(--ok); padding: 0; }
.tk-fst--once { background: var(--tk-once-bg); color: var(--tk-once); }
.tk-frow .tk-item-actions { grid-column: auto; grid-row: auto; }
@media (max-width: 560px) {
  .tk-frow { grid-template-columns: 32px minmax(0, 1fr); }
  .tk-burnat { grid-column: 2; text-align: left; flex-direction: row; gap: 0.5rem; align-items: baseline; }
  .tk-frow .tk-item-actions { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .tk-meter i, .tk-frow { transition: none; } }

/* ── Phase 4: Passkeys, Namen ──────────────────── */
.tk-pkbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tk-divider { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.8rem; margin: 0.2rem 0; }
.tk-divider::before, .tk-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.tk-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.tk-setting { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 0.85rem 0.95rem; display: flex; flex-direction: column; gap: 0.5rem; }
.tk-setting .tr-h2 { margin: 0; }
.tk-setting .tk-hint { margin: 0; }
.tk-grow { flex: 1 1 140px; min-width: 0; padding: 0.5rem 0.65rem; font-size: 0.9rem; }
.tk-pklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.tk-pkitem { display: flex; align-items: center; gap: 0.6rem; border: 1px solid var(--tk-soft); border-radius: var(--r); padding: 0.45rem 0.6rem; }
.tk-pkitem .tk-frow-main { flex: 1; }
.tk-setting .tr-btn { padding: 0.5rem 0.85rem; font-size: 0.88rem; }
