/* ============================================================================
 * DrNick widget — ONFA Noir
 * Lives inside the (mock) iframe. Self-contained CSS. Gold density < 10%.
 * ==========================================================================*/

.dn-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: var(--font-sans);
  --dn-w: 396px;
  --dn-h: 660px;
}

/* ── THEME-LOCAL TOKENS (dark defaults) — every theme-dependent surface routes
 * through one of these so a single [data-theme="light"] override (themes.css)
 * re-skins the whole widget with no rule rewriting. ──────────────────────── */
.dn-root {
  --dn-chrome:        rgba(2,2,2,0.72);          /* header + composer glass */
  --dn-panel-shadow:  0 30px 90px rgba(0,0,0,0.7);
  --dn-input-bg:      rgba(0,0,0,0.45);
  --dn-user-bubble:   rgba(255,255,255,0.06);
  --dn-inset-bg:      rgba(0,0,0,0.40);          /* confirm token strip */
  --dn-file-bg:       rgba(0,0,0,0.35);          /* attached-file preview */
  --dn-pre-bg:        #060606;                   /* code block */
  --dn-scroll:        rgba(255,255,255,0.12);
  --dn-grid-dot:      rgba(255,255,255,0.04);    /* panel dot grid */
  --dn-bloom-1:       rgba(239, 194, 67,0.10);      /* atmosphere blooms */
  --dn-bloom-2:       rgba(239, 194, 67,0.05);
  --dn-fab-img-a:     #1a1a1a;                   /* avatar backplate */
  --dn-fab-img-b:     #0b0b0b;
  --dn-code-bg:       rgba(239, 194, 67,0.10);
  --dn-code-fg:       var(--gold-200);
  --dn-focus-ring:    rgba(239, 194, 67,0.12);
  --dn-gold-text:     var(--gold);               /* gold used as TEXT (legible stop) */
}

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.dn-fab {
  position: absolute;
  /* 52px circle centered in the 60px collapsed iframe with a 4px inset ALL sides, so the border,
     shadow and status dot stay INSIDE the box (an iframe clips anything past its own edge). Keep
     width/height in sync with loader.js SIZE.fab (60) minus the 8px inset. */
  right: 4px;
  bottom: 4px;
  width: 52px;
  height: 52px;
  border-radius: var(--r-full);
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--gold-line);
  /* compact shadow — the full --shadow-2 (0 8px 24px) cannot render inside a 60px box. */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  overflow: visible;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.dn-fab img {
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  object-fit: cover;
  object-position: 50% 18%;
  background: radial-gradient(circle at 50% 30%, var(--dn-fab-img-a), var(--dn-fab-img-b));
}
.dn-fab:hover {
  border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);  /* compact — stays inside the 60px box */
}
.dn-fab:active { transform: scale(0.96); }
.dn-fab .dn-fab-ping {
  position: absolute;
  top: 2px; right: 2px;          /* inside the 4px FAB inset → dot stays within the iframe box */
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--pos);
  border: 2px solid var(--bg);
  box-shadow: 0 0 4px rgba(45,195,133,0.6);
}

/* tooltip nudge */
.dn-fab-tip {
  position: absolute;
  right: 76px;
  bottom: 16px;
  white-space: nowrap;
  background: var(--elevated);
  border: 1px solid var(--line-strong);
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 13px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateX(6px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dn-fab-wrap:hover .dn-fab-tip { opacity: 1; transform: translateX(0); }

/* ── PANEL ───────────────────────────────────────────────────────────────── */
.dn-panel {
  width: var(--dn-w);
  height: min(var(--dn-h), calc(100vh - 48px));
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: var(--dn-panel-shadow), 0 2px 0 rgba(255,255,255,0.03) inset;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  animation: dn-rise var(--dur) var(--ease-out);
}
@keyframes dn-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* atmosphere */
.dn-panel::before {
  content: "";
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 84% 8%, var(--dn-bloom-1), transparent 40%),
    radial-gradient(circle at 12% 96%, var(--dn-bloom-2), transparent 34%);
}
.dn-panel::after {
  content: "";
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, var(--dn-grid-dot) 1px, transparent 1.5px);
  background-size: 30px 30px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 84%, transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 84%, transparent);
  opacity: 0.5;
}
.dn-panel > * { position: relative; z-index: 1; }

/* ── HEADER ──────────────────────────────────────────────────────────────── */
.dn-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--dn-chrome);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
          backdrop-filter: blur(20px) saturate(120%);
}
.dn-head-av {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: var(--r-full);
  object-fit: cover;
  object-position: 50% 16%;
  border: 1px solid var(--gold-line);
  background: var(--dn-fab-img-b);
}
.dn-head-meta { flex: 1; min-width: 0; }
.dn-head-name {
  font-size: 15px; font-weight: 600; color: var(--fg-1);
  letter-spacing: -0.01em; line-height: 1.2;
}
.dn-head-status {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-3);
}
.dn-head-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pos); box-shadow: 0 0 10px rgba(45,195,133,0.6);
  animation: onfa-pulse 1.6s ease-in-out infinite;
}
.dn-iconbtn {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--fg-3);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.dn-iconbtn:hover { background: var(--secondary); color: var(--fg-1); }
.dn-iconbtn svg { width: 18px; height: 18px; }

/* ── BODY (scroll) ───────────────────────────────────────────────────────── */
.dn-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--dn-scroll) transparent;
}
.dn-body::-webkit-scrollbar { width: 8px; }
.dn-body::-webkit-scrollbar-thumb { background: var(--dn-scroll); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

/* ── WELCOME ─────────────────────────────────────────────────────────────── */
/* Figure is a tall, slim right-gutter element. Chips reserve a right inset so
   they never enter the figure's x-column — no overlap regardless of height. */
.dn-welcome {
  position: relative;
  min-height: 100%;
  padding-bottom: 22px;
}
.dn-welcome-top {
  padding: 26px 22px 0;
}
.dn-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold);
  display: inline-flex; align-items: center; gap: 8px;
}
.dn-eyebrow .bar { width: 16px; height: 1px; background: var(--gold-line); }
.dn-welcome-h {
  margin: 16px 0 0;
  font-size: 25px; font-weight: 700; line-height: 1.18; letter-spacing: -0.02em;
  color: var(--fg-1);
  text-wrap: balance;
}
.dn-welcome-sub {
  margin: 12px 0 0;
  font-size: 13.5px; line-height: 1.6; color: var(--fg-3);
  max-width: 27ch;
}
.dn-chips {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px 130px 0 22px;   /* right inset reserves the figure column */
  position: relative; z-index: 2;
}
.dn-chip {
  text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 13.5px; font-weight: 500;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.dn-chip svg { width: 14px; height: 14px; color: var(--fg-4); flex: 0 0 14px; transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.dn-chip:hover { border-color: var(--gold-line); background: var(--panel-2); color: var(--fg-1); }
.dn-chip:hover svg { color: var(--gold); transform: translateX(2px); }
.dn-chip:active { transform: scale(0.99); }

.dn-welcome-art {
  position: absolute;
  right: 0; bottom: 0;
  width: 150px; height: 272px;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  display: flex; align-items: flex-end; justify-content: flex-end;
}
.dn-welcome-art img {
  height: 272px;
  width: auto;
  object-fit: contain;
  object-position: bottom right;
  margin: 0 -6px -6px 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%);
          mask-image: linear-gradient(to bottom, transparent, #000 30%);
  filter: drop-shadow(0 12px 40px rgba(0,0,0,0.55));
}
.dn-welcome-glow {
  position: absolute; right: 12px; bottom: 0;
  width: 175px; height: 175px;
  background: radial-gradient(circle, rgba(239, 194, 67,0.12), transparent 62%);
  pointer-events: none;
}

/* ── MESSAGES ────────────────────────────────────────────────────────────── */
.dn-thread { padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 16px; }

.dn-msg { display: flex; gap: 10px; max-width: 100%; animation: dn-msg-in var(--dur) var(--ease-out); }
@keyframes dn-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.dn-msg-av {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: var(--r-full);
  object-fit: cover; object-position: 50% 16%;
  border: 1px solid var(--gold-line);
  margin-top: 2px;
}
.dn-bubble {
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px; line-height: 1.6; color: var(--fg-2);
  max-width: 286px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.dn-msg.bot .dn-bubble {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-top-left-radius: 5px;
}
.dn-msg.user { flex-direction: row-reverse; }
.dn-msg.user .dn-bubble {
  background: var(--dn-user-bubble);
  border: 1px solid var(--line-strong);
  border-top-right-radius: 5px;
  color: var(--fg-1);
}

/* markdown inside bubbles */
.dn-bubble p { margin: 0 0 8px; }
.dn-bubble p:last-child { margin-bottom: 0; }
.dn-bubble strong { color: var(--fg-1); font-weight: 700; }
.dn-bubble em { font-style: italic; }
.dn-bubble a { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--gold-line); }
.dn-bubble a:hover { text-decoration-color: var(--gold); }
.dn-bubble code {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600;
  background: var(--dn-code-bg); color: var(--dn-code-fg);
  padding: 1px 5px; border-radius: 5px;
  white-space: nowrap;
}
.dn-bubble pre {
  background: var(--dn-pre-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; margin: 8px 0; overflow-x: auto;
}
.dn-bubble pre code { background: none; color: var(--fg-2); padding: 0; white-space: pre; }
.dn-bubble ul, .dn-bubble ol { margin: 6px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.dn-bubble li { line-height: 1.5; }
.dn-bubble li::marker { color: var(--fg-4); }
.dn-bubble h3, .dn-bubble h4, .dn-bubble h5, .dn-bubble h6 { margin: 6px 0 4px; color: var(--fg-1); font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.dn-bubble blockquote { margin: 8px 0; padding: 4px 0 4px 12px; border-left: 2px solid var(--gold-line); color: var(--fg-3); }
.dn-bubble hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.dn-bubble table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.dn-bubble th, .dn-bubble td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dn-bubble th { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-4); font-weight: 700; }
.dn-bubble td { color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* caret while streaming */
.dn-caret {
  display: inline-block; width: 7px; height: 15px; vertical-align: -2px;
  margin-left: 1px; background: var(--gold); border-radius: 1px;
  animation: dn-blink 1s steps(2) infinite;
}
@keyframes dn-blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }

/* user-attached file preview inside bubble */
.dn-msg-file {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: var(--dn-file-bg); border: 1px solid var(--line);
  border-radius: 9px;
}
.dn-msg-file img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: 0 0 34px; }
.dn-msg-file .fic { width: 34px; height: 34px; border-radius: 6px; flex: 0 0 34px; display: grid; place-items: center; background: var(--panel-3); color: var(--gold); }
.dn-msg-file .fic svg { width: 16px; height: 16px; }
.dn-msg-file .fmeta { min-width: 0; }
.dn-msg-file .fname { font-size: 12.5px; color: var(--fg-1); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.dn-msg-file .fsize { font-family: var(--font-mono); font-size: 10px; color: var(--fg-4); letter-spacing: 0.04em; }

/* ── TOOL INDICATOR ──────────────────────────────────────────────────────── */
.dn-tool {
  display: inline-flex; align-items: center; gap: 9px;
  margin-left: 38px;
  padding: 8px 13px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-full);
  width: fit-content;
  animation: dn-msg-in var(--dur) var(--ease-out);
}
.dn-tool .spin {
  width: 13px; height: 13px; flex: 0 0 13px;
  border-radius: 50%;
  border: 2px solid var(--gold-line);
  border-top-color: var(--gold);
  animation: dn-spin 0.7s linear infinite;
}
@keyframes dn-spin { to { transform: rotate(360deg); } }
.dn-tool .lbl { font-size: 12.5px; color: var(--fg-2); font-weight: 500; }
.dn-tool .nm {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--fg-4);
  padding: 1px 6px; border-radius: 5px; background: var(--secondary);
}
.dn-tool.done .spin { border: none; color: var(--pos); display: grid; place-items: center; animation: none; }
.dn-tool.done .spin svg { width: 13px; height: 13px; }

/* ── CONFIRM CARD ────────────────────────────────────────────────────────── */
.dn-confirm {
  margin-left: 38px;
  width: calc(100% - 38px);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), transparent 36%),
    var(--panel);
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  overflow: hidden;
  animation: dn-msg-in var(--dur) var(--ease-out);
}
.dn-confirm.dead {
  border-color: var(--neg-line);
  background:
    linear-gradient(135deg, rgba(255,122,122,0.05), transparent 40%),
    var(--panel);
}
.dn-confirm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}
.dn-confirm-head .ttl {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
  display: inline-flex; align-items: center; gap: 8px;
}
.dn-confirm-head .ttl svg { width: 14px; height: 14px; }
.dn-confirm-ttl-line {
  padding: 13px 15px 4px;
  font-size: 15px; font-weight: 600; color: var(--fg-1); letter-spacing: -0.01em;
}
.dn-confirm-rows { padding: 8px 15px 4px; display: flex; flex-direction: column; }
.dn-confirm-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--hairline);
  gap: 12px;
}
.dn-confirm-row:last-child { border-bottom: none; }
.dn-confirm-row .k { font-size: 12.5px; color: var(--fg-3); }
.dn-confirm-row .v {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 600; color: var(--fg-1); letter-spacing: 0.01em;
  text-align: right;
}
.dn-confirm-row .v.gold { color: var(--gold); }
.dn-confirm-warn {
  padding: 9px 15px 4px;
  font-size: 12.5px; line-height: 1.45; color: var(--fg-3);
}
.dn-confirm-token {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 15px;
  margin: 6px 15px 0;
  background: var(--dn-inset-bg); border: 1px solid var(--line);
  border-radius: 9px;
}
.dn-confirm-token .tk {
  font-family: var(--font-mono); font-size: 10px; color: var(--fg-4);
  letter-spacing: 0.06em;
}
.dn-confirm-token .tk b { color: var(--fg-2); font-weight: 600; }
.dn-confirm-token .ttl-timer { font-family: var(--font-mono); font-size: 10px; color: var(--gold); letter-spacing: 0.08em; display: inline-flex; align-items: center; gap: 5px; }
.dn-confirm-token .ttl-timer .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold-glow); animation: onfa-pulse 1.6s ease-in-out infinite; }
.dn-confirm-actions { display: flex; gap: 9px; padding: 13px 15px 15px; }
.dn-confirm-actions .onfa-btn { flex: 1; min-height: 42px; font-size: 14px; }
.dn-confirm.resolved { border-color: var(--line-strong); }
.dn-confirm-resolved-note {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 15px; font-size: 13px; color: var(--fg-3);
}
.dn-confirm-resolved-note svg { width: 16px; height: 16px; }
.dn-confirm-resolved-note.ok { color: var(--pos); }
.dn-confirm-resolved-note.cancel { color: var(--fg-4); }

/* ── COMPOSER ────────────────────────────────────────────────────────────── */
.dn-composer {
  border-top: 1px solid var(--line);
  background: var(--dn-chrome);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
          backdrop-filter: blur(20px) saturate(120%);
  padding: 12px;
}
.dn-attach-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.dn-attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 6px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 9px;
}
.dn-attach-chip img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; }
.dn-attach-chip .fic { width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; background: var(--panel-3); color: var(--gold); }
.dn-attach-chip .fic svg { width: 13px; height: 13px; }
.dn-attach-chip .nm { font-size: 12px; color: var(--fg-2); max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dn-attach-chip .x { width: 18px; height: 18px; display: grid; place-items: center; color: var(--fg-4); border-radius: 5px; }
.dn-attach-chip .x:hover { color: var(--neg); background: var(--neg-soft); }
.dn-attach-chip .x svg { width: 12px; height: 12px; }
.dn-attach-chip .st { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.04em; color: var(--fg-4); text-transform: uppercase; }
.dn-attach-chip.failed { border-color: var(--neg-line); background: var(--neg-soft); }
.dn-attach-chip.failed .st { color: var(--neg); }

.dn-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--dn-input-bg);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 6px 6px 6px 8px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.dn-input-row:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--dn-focus-ring); }
.dn-attach-btn {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  display: grid; place-items: center; color: var(--fg-3);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.dn-attach-btn:hover { color: var(--gold); background: var(--secondary); }
.dn-attach-btn svg { width: 18px; height: 18px; }
.dn-textarea {
  flex: 1;
  background: none; border: none; outline: none; resize: none;
  color: var(--fg-1); font-size: 14px; line-height: 1.5;
  padding: 8px 2px; max-height: 120px; min-height: 22px;
  font-family: var(--font-sans);
}
.dn-textarea::placeholder { color: var(--fg-4); }
.dn-send {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--ink);
  box-shadow: var(--shadow-gold);
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.dn-send svg { width: 17px; height: 17px; }
.dn-send:hover { background: var(--gold-light); box-shadow: var(--shadow-gold-strong); }
.dn-send:active { transform: scale(0.94); }
.dn-send:disabled { opacity: 0.35; box-shadow: none; cursor: not-allowed; background: var(--panel-3); color: var(--fg-4); }
.dn-footnote {
  text-align: center; margin-top: 9px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg-5);
}
.dn-footnote b { color: var(--fg-4); font-weight: 600; }

/* ≥44px tap target (WCAG 2.5.5 / Apple HIG) — expand the HIT area only, glyph size unchanged
   (spec 46 Q2). A centered transparent ::before enlarges the clickable region without changing
   layout width, so the tight header cluster does not crowd. */
.dn-send, .dn-attach-btn, .dn-iconbtn { position: relative; }
.dn-send::before, .dn-attach-btn::before, .dn-iconbtn::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
}

/* ── TOTP + error (added for the real confirm flow; design mock had none) ──── */
.dn-otp-row { display: flex; flex-direction: column; gap: 5px; padding: 4px 15px 2px; }
.dn-otp {
  width: 140px; letter-spacing: 4px; text-align: center;
  font-family: var(--font-mono); font-size: 16px; font-weight: 600;
  color: var(--fg-1); background: var(--bg-2, rgba(255,255,255,0.04));
  border: 1px solid var(--line, rgba(255,255,255,0.14)); border-radius: 10px;
  padding: 9px 10px;
}
.dn-otp:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--dn-focus-ring); }
.dn-otp:disabled { opacity: 0.5; }
.dn-otp-note { font-size: 11px; color: var(--fg-4, #8a8f98); }
.dn-confirm-err {
  margin: 6px 15px 2px; padding: 8px 11px; border-radius: 9px;
  font-size: 12.5px; line-height: 1.45; color: var(--neg);
  background: var(--neg-soft); border: 1px solid var(--neg-line);
}

/* ════ v2 PORT: header controls · language · quick actions · new-conv sheet ════ */

/* ── header control cluster ──────────────────────────────────────────────── */
.dn-head-actions { display: flex; align-items: center; gap: 4px; }
.dn-head-divider { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; flex: 0 0 1px; }
.dn-iconbtn.sm { width: 30px; height: 30px; flex: 0 0 30px; }
.dn-iconbtn.sm svg { width: 16px; height: 16px; }

/* language segmented toggle (VI | EN) */
.dn-lang {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--r-full);
  padding: 2px; background: var(--secondary);
  font-family: var(--font-mono);
}
.dn-lang button {
  appearance: none; border: 0; background: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--fg-4);
  padding: 4px 8px; border-radius: var(--r-full); line-height: 1;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.dn-lang button:hover { color: var(--fg-2); }
.dn-lang button.on { background: var(--dn-gold-text); color: var(--ink); }

/* ── quick-actions bar (persistent, above input) ─────────────────────────── */
.dn-quick {
  display: flex; gap: 7px;
  padding-bottom: 10px; margin-bottom: 2px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
}
.dn-quick::-webkit-scrollbar { display: none; }
.dn-qbtn {
  flex: 0 0 auto; scroll-snap-align: start; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border-radius: var(--r-full);
  background: var(--panel); border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.dn-qbtn svg { width: 14px; height: 14px; flex: 0 0 14px; color: var(--fg-4); transition: color var(--dur-fast) var(--ease); }
.dn-qbtn:hover { border-color: var(--gold-line); background: var(--panel-2); color: var(--fg-1); }
.dn-qbtn:hover svg { color: var(--dn-gold-text); }
.dn-qbtn:active { transform: scale(0.97); }
.dn-quick.disabled { -webkit-mask-image: none; mask-image: none; }
.dn-qbtn:disabled,
.dn-quick.disabled .dn-qbtn {
  opacity: 0.4; cursor: not-allowed; pointer-events: none;
  border-color: var(--line); background: var(--panel); color: var(--fg-4);
}
.dn-quick.disabled .dn-qbtn svg { color: var(--fg-5); }

/* ── new-conversation confirm dialog (in-panel sheet) ────────────────────── */
.dn-sheet-scrim {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: dn-fade var(--dur-fast) var(--ease-out);
}
@keyframes dn-fade { from { opacity: 0; } to { opacity: 1; } }
.dn-sheet {
  width: 100%; max-width: 320px;
  background: var(--elevated); border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 20px;
  animation: dn-rise var(--dur) var(--ease-out);
}
.dn-sheet .sic {
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--gold-soft); border: 1px solid var(--gold-line); color: var(--dn-gold-text);
}
.dn-sheet .sic svg { width: 19px; height: 19px; }
.dn-sheet h4 { margin: 14px 0 0; font-size: 16px; font-weight: 700; color: var(--fg-1); letter-spacing: -0.01em; }
.dn-sheet p { margin: 8px 0 0; font-size: 13px; line-height: 1.55; color: var(--fg-3); }
.dn-sheet-actions { display: flex; gap: 9px; margin-top: 18px; }
.dn-sheet-actions .onfa-btn { flex: 1; min-height: 40px; font-size: 13.5px; }

/* ── mobile full-screen (narrow viewport) ────────────────────────────────── */
/* Mobile: one full-bleed breakpoint for the whole phone range (≤480px, covers 430px + large
   Android, below the smallest tablet). dvh so the mobile keyboard shrinks the panel instead of
   covering the composer (was a vh-only 401–460 gap → W1); safe-area insets keep the header clear
   of the notch and the composer/footnote clear of the home indicator with viewport-fit=cover (W2). */
@media (max-width: 480px) {
  .dn-root { right: 0; bottom: 0; --dn-w: 100vw; }
  .dn-panel {
    width: 100vw; height: 100vh; height: 100dvh;
    border: none; border-radius: 0;
  }
  .dn-fab-wrap { position: fixed; right: 16px; bottom: 16px; }
  .dn-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .dn-composer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }
}
