/* ── 问蛙 — clean centered chat UI ─────────────────────────── */

:root {
  --bg-page: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  --bg-surface: #ffffff;
  --bg-bubble-user: linear-gradient(135deg, #2563eb, #1d4ed8);
  --bg-bubble-bot: #ffffff;
  --bg-sidebar: rgba(255,255,255,.65);
  --bg-sidebar-active: #eff6ff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-on-blue: #ffffff;
  --border: #e2e8f0;
  --border-soft: rgba(226,232,240,.7);
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.08);
  --shadow-blue: 0 8px 20px rgba(37,99,235,.18);
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-page);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.container { max-width: 1680px; margin: 0 auto; padding: 0 20px; }

/* ── overall layout ─────────────────────────────────────────── */
.layout {
  display: flex;
  height: calc(100vh - 82px);  /* below product-nav header */
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 24px;
  gap: 18px;
}

/* ── sidebar (thread list) ──────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar form {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.7);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.new-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-primary);
  text-decoration: none;
}
.thread-list {
  flex: 1;
  padding: 6px;
  display: flex; flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}
.thread-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .1s;
  border: 1px solid transparent;
}
.thread-item .thread-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Kebab button per row — hidden until row hover or menu open */
.thread-item .thread-kebab {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s, background .1s;
}
.thread-item:hover .thread-kebab,
.thread-item.menu-open .thread-kebab,
.thread-item .thread-kebab:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
/* Touch devices have no hover → keep kebab visible all the time. */
@media (hover: none) {
  .thread-item .thread-kebab { opacity: 1; pointer-events: auto; }
}
.thread-item .thread-kebab:hover {
  background: rgba(15,23,42,.06);
  color: var(--text-primary);
}
.thread-item.menu-open .thread-kebab {
  background: rgba(15,23,42,.08);
  color: var(--text-primary);
}
.thread-item:hover {
  background: rgba(239,246,255,.7);
  color: var(--text-primary);
  text-decoration: none;
}
.thread-item.active {
  background: var(--bg-sidebar-active);
  color: var(--accent);
  font-weight: 600;
  border-color: #bfdbfe;
}
.empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── main chat area ─────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.chat-shell {
  display: flex; flex-direction: column;
  height: 100%;
  min-width: 0;
}

/* topbar */
.chat-topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  min-height: 50px;
}
.topbar-title {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.topbar-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 14px; cursor: pointer;
  transition: all .12s;
}
.icon-btn:hover { background: #f8fafc; color: var(--accent); border-color: #bfdbfe; }
.icon-btn-danger:hover { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

/* ── messages stream ────────────────────────────────────────── */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-surface);
}
.chat-stream {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 32px 8px;
}

.msg {
  margin: 0 0 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.msg-user {
  justify-content: flex-end;
}
.msg-bot {
  justify-content: flex-start;
}
.msg-avatar {
  flex-shrink: 0;
  flex-grow: 0;
  align-self: flex-start;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #f0f9ff;
  border: 1px solid var(--border);
  position: relative;
  margin-top: 2px;
}

/* Avatar image (替换原 emoji) */
.msg-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.msg-bubble {
  max-width: 880px;
  min-width: 0;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-user .msg-bubble {
  background: var(--bg-bubble-user);
  color: var(--text-on-blue);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-blue);
}
.msg-bot .msg-bubble {
  background: var(--bg-bubble-bot);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  flex: 1;
}

.attachments-row { margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.25);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  color: inherit;
}
.msg-bot .chip {
  background: #f1f5f9;
  border-color: var(--border);
  color: var(--text-secondary);
}

/* ── markdown inside bot bubble ─────────────────────────────── */
.msg-bot .msg-content > *:first-child { margin-top: 0; }
.msg-bot .msg-content > *:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3, .msg-content h4 {
  margin: 16px 0 8px; font-weight: 650; line-height: 1.35;
}
.msg-content h1 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.msg-content h2 { font-size: 15.5px; }
.msg-content h3 { font-size: 14.5px; }
.msg-content h4 { font-size: 13.5px; color: var(--text-secondary); }
.msg-content p { margin: 6px 0; }
.msg-content strong { color: #1e293b; font-weight: 650; }
.msg-content em { font-style: italic; color: var(--text-secondary); }
.msg-content ul, .msg-content ol { padding-left: 22px; margin: 8px 0; }
.msg-content li { margin: 3px 0; }
.msg-content code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: #f1f5f9; padding: 1.5px 5.5px; border-radius: 5px;
  border: 1px solid var(--border);
  color: #be185d;
}
.msg-content pre {
  background: #0f172a; color: #e2e8f0;
  padding: 12px 14px; border-radius: var(--radius-md); overflow-x: auto;
  margin: 10px 0; font-size: 12.5px; line-height: 1.6;
  border: 1px solid #1e293b;
}
.msg-content pre code { background: none; padding: 0; border: 0; color: inherit; }
.msg-content a { color: var(--accent); border-bottom: 1px dashed #bfdbfe; }
.msg-content a:hover { border-bottom-style: solid; }
.msg-content blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--accent);
  background: #f8fafc;
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.msg-content table {
  border-collapse: collapse; margin: 10px 0; width: 100%;
  font-size: 13px;
}
.msg-content th, .msg-content td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.msg-content th { background: #f8fafc; font-weight: 650; }
.msg-content hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* user bubble preserves whitespace */
.msg-user .msg-content { white-space: pre-wrap; }
.msg-user .msg-content > br { display: none; }

/* ── empty state ────────────────────────────────────────────── */
.empty-state {
  max-width: 580px;
  margin: 80px auto 40px;
  text-align: center;
}
.empty-emoji { font-size: 54px; line-height: 1; margin-bottom: 12px; }
.empty-title {
  font-size: 28px; font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.empty-sub {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
}
.suggestions {
  display: flex; flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.suggest {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.suggest:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ── composer (sticky bottom) ───────────────────────────────── */
.composer-wrap {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
}
.composer {
  max-width: 1100px;
  margin: 0 auto;
}
.attachments-preview {
  display: flex; flex-wrap: wrap; gap: 4px; min-height: 0;
}
.attachments-preview:not(:empty) { margin-bottom: 8px; }
.attachments-preview .chip { background: #f1f5f9; border-color: var(--border); color: var(--text-secondary); }

.composer-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 6px 6px 6px 14px;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.composer-row:focus-within {
  border-color: #93c5fd;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.composer-file {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color .12s, background .12s;
}
.composer-file:hover { color: var(--accent); background: var(--bg-sidebar-active); }
textarea#input-text {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  resize: none;
  outline: none;
  color: var(--text-primary);
  max-height: 240px;
  overflow-y: auto;
}
textarea#input-text::placeholder { color: var(--text-muted); }
.composer-send {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-blue);
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.composer-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(37,99,235,.28); }
.composer-send:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.85;
}
.composer-send.loading {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.6; }
}
.composer-hint {
  margin-top: 6px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

.bottom-spacer { height: 12px; }



/* ── thinking bubble animation ──────────────────────── */
.msg-thinking .msg-bubble {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  display: inline-block;
  min-width: 200px;
}

.thinking-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0 2px;
}
.thinking-dots span {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  animation: think-bounce 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes think-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.thinking-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 8px;
  font-feature-settings: "tnum";  /* 等宽数字 */
}
.thinking-hint #thinking-time {
  color: var(--accent);
  font-weight: 600;
}

/* ── responsive ─────────────────────────────────────────────── */
/* ── Mobile drawer infra (default: hidden on desktop) ──────── */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }
.topbar-new { display: none; }

@media (max-width: 820px) {
  /* Lock the document to viewport so the on-screen keyboard never leaves
     a scroll artifact at the top. body becomes a flex column: product-nav
     header keeps its natural size, .layout takes the rest. 100dvh shrinks
     with the keyboard automatically. */
  /* Mobile: lock the entire chat surface to the viewport with position:
     fixed so it can NEVER react to keyboard / URL-bar changes. The product-
     nav header keeps its natural sticky position; .layout sits below it,
     pinned to the four edges. The internal flex (.main → .chat-shell →
     .chat-scroll) handles its own scrolling. */
  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: contain;
  }
  .layout {
    position: fixed;
    top: 64px;     /* below product-nav header (min-height 64px) */
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    max-width: none;
    flex-direction: column;
    gap: 0;
    height: auto;
    z-index: 1600;  /* above .sidebar-backdrop so sidebar inside is tappable */
  }
  /* Drawer close-on-tap-outside is handled in JS now (see base.html). */
  .main {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    width: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  /* Hamburger button (only on mobile, sits at top-left of topbar) */
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .1s, color .1s;
  }
  .sidebar-toggle:hover { background: #f1f5f9; color: var(--text-primary); }
  .sidebar-toggle:active { background: #e2e8f0; }

  /* Sidebar becomes a fixed drawer (off-canvas by default) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 86vw;
    height: 100%;
    max-height: none;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 1500;
    border-radius: 0;
    border-right: 1px solid var(--border);
    background: #fff;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 18px 40px rgba(0,0,0,.18);
  }

  /* Backdrop — transparent: still catches taps outside the drawer so the
     drawer closes, but no visual dimming of the main content. */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 1490;
    pointer-events: none;
  }
  body.sidebar-open .sidebar-backdrop {
    pointer-events: auto;
  }
  .sidebar-backdrop[hidden] { display: block; } /* override [hidden] default since we animate */
  body:not(.sidebar-open) .sidebar-backdrop { opacity: 0; pointer-events: none; }

  /* When drawer open, prevent body scroll */
  body.sidebar-open { overflow: hidden; }

  /* Chat layout tightening */
  .chat-topbar { padding: 10px 12px; gap: 6px; }
  .topbar-title { font-size: 14.5px; font-weight: 600; }
  .chat-stream { padding: 14px 12px 8px; max-width: 100%; }
  .msg-bubble { font-size: 14px; }
  .msg-avatar { width: 30px; height: 30px; min-width: 30px; min-height: 30px; }
  .composer-wrap { padding: 8px 10px 10px; }
  .composer-row { gap: 6px; }
  .composer-row textarea { font-size: 16px; /* prevent iOS auto-zoom on focus */ }
  .composer-send { width: 38px; height: 38px; }
  .composer-file { width: 38px; height: 38px; }
  .composer-hint { display: none; }
  .empty-state { padding: 24px 12px; }
  .empty-title { font-size: 22px; }
  .empty-sub { font-size: 13px; }
  .suggestions { flex-direction: column; gap: 8px; }
  .suggest { width: 100%; text-align: left; font-size: 13px; }
  .row-menu { max-width: calc(100vw - 24px); }
  /* Force full-width on the chat surface — guards against any inherited
     max-width / margin: auto centering after the empty state is removed. */
  .main, .chat-shell { width: 100%; flex: 1 1 auto; min-height: 0; }
  .chat-stream { width: 100%; max-width: 100% !important; margin: 0 !important; }
  .msg-bubble { max-width: 100%; }
  .composer { width: 100%; max-width: 100%; margin: 0; }

}
@media (max-width: 480px) {
  /* Drawer keeps full viewport height — no max-height cap. */
  .new-btn { height: 36px; }
  .thread-item { padding: 11px 10px; font-size: 13.5px; }
  .thread-item .thread-kebab { width: 26px; height: 26px; }
}

/* ── Kebab menu (top-right of chat) ──────────────────────────── */
.kebab-wrap { position: relative; }
.kebab-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.06);
  padding: 4px;
  z-index: 30;
  display: flex; flex-direction: column;
}
.kebab-menu[hidden] { display: none; }
.kebab-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
}
.kebab-item:hover { background: #f1f5f9; }
.kebab-item-danger { color: var(--danger, #dc2626); }
.kebab-item-danger:hover { background: #fef2f2; }

/* ── SPA-nav loading state ──────────────────────────────────── */
.main.main-loading { opacity: 0.55; transition: opacity .12s; pointer-events: none; }
.main { transition: opacity .12s; }
.thread-item { cursor: pointer; }
.thread-item:active { transform: translateY(0.5px); }


/* ── Per-thread row menu (Anthropic-style floating dropdown) ── */
.row-menu {
  position: fixed;
  z-index: 1700;  /* above .layout (1600) on mobile so dropdown is visible/tappable */
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,.14), 0 2px 8px rgba(15,23,42,.06);
  padding: 6px;
  display: flex; flex-direction: column;
}
.row-menu[hidden] { display: none; }
.row-menu-item {
  appearance: none; border: 0; background: transparent;
  text-align: left;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-primary);
  border-radius: 7px;
  cursor: pointer;
  transition: background .08s;
}
.row-menu-item:hover { background: #f1f5f9; }
.row-menu-item-danger { color: var(--danger, #dc2626); }
.row-menu-item-danger:hover { background: #fef2f2; }
.row-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ── Custom modal (replaces native confirm/prompt/alert) ────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.42);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: modal-fade-in .12s ease-out;
}
.modal-backdrop[hidden] { display: none; }
body.modal-open { overflow: hidden; }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15,23,42,.28), 0 4px 12px rgba(15,23,42,.08);
  width: 100%;
  max-width: 420px;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modal-pop .14s ease-out;
}
@keyframes modal-pop {
  from { transform: scale(.96) translateY(4px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal-body {
  padding: 22px 24px 16px;
}
.modal-message {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-line;
}
.modal-input {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .1s, box-shadow .1s;
  box-sizing: border-box;
}
.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.modal-input[hidden] { display: none; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px 18px;
}
.modal-btn {
  appearance: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.modal-btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}
.modal-btn-secondary:hover { background: #f8fafc; }
.modal-btn-primary {
  background: var(--accent, #3b82f6);
  color: #fff;
}
.modal-btn-primary:hover { background: #2563eb; }
.modal-btn-danger {
  background: var(--danger, #dc2626);
  color: #fff;
}
.modal-btn-danger:hover { background: #b91c1c; }
.modal-btn:focus-visible {
  outline: 2px solid rgba(59,130,246,.55);
  outline-offset: 2px;
}
.modal-btn[hidden] { display: none; }



/* ── Drag-and-drop overlay (desktop, viewport-level) ─────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 2500;
  pointer-events: none;
}
.drop-overlay.show { display: flex; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 240px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  padding: 28px 36px;
  background: #fff;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(15,23,42,.20), 0 4px 12px rgba(15,23,42,.08);
}
