:root {
  --vault-bg: #f5f5f7;
  --vault-paper: #ffffff;
  --vault-ink: #1d1d1f;
  --vault-muted: #6e6e73;
  --vault-subtle: #86868b;
  --vault-line: #d2d2d7;
  --vault-line-soft: #e7e7ea;
  --vault-green: #50766b;
  --vault-green-dark: #3f6258;
  --vault-green-soft: #edf3f1;
  --vault-orange: #d58a20;
  --vault-radius-sm: 12px;
  --vault-radius-md: 16px;
  --vault-radius-lg: 20px;
  --vault-radius-xl: 24px;
  --vault-content: 1200px;
  --vault-shadow-soft: 0 12px 32px rgba(0, 0, 0, .06);
  --vault-ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html { background: var(--vault-bg); }

body {
  margin: 0;
  color: var(--vault-ink);
  background: var(--vault-bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button, .upload-button, .doc-card { -webkit-tap-highlight-color: transparent; }

.app-shell > header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  min-height: 64px;
  padding: 0 max(24px, calc((100vw - var(--vault-content)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .82);
  border-bottom: 1px solid rgba(210, 210, 215, .65);
  box-shadow: none;
  backdrop-filter: saturate(155%) blur(18px);
  -webkit-backdrop-filter: saturate(155%) blur(18px);
}

.app-shell > header h1 {
  margin: 1px 0 0;
  color: var(--vault-ink);
  font-size: 19px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -.025em;
}

.eyebrow {
  color: var(--vault-green-dark);
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .2em;
}

.header-actions { display: flex; align-items: center; gap: 6px; }

.header-actions button,
.header-actions .ghost,
.header-actions .icon-btn {
  min-height: 42px;
  height: 42px;
  padding: 0 14px;
  color: #3a3a3c;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}

.header-actions button:hover { color: var(--vault-ink); background: #f1f1f3; }
.header-actions #notifyBtn { color: #fff; background: var(--vault-green); border-color: var(--vault-green); }
.header-actions #notifyBtn:hover { background: var(--vault-green-dark); }

.app-shell > main {
  width: min(calc(100% - 48px), var(--vault-content));
  max-width: var(--vault-content);
  margin: 0 auto;
  padding: 40px 0 112px;
}

.hero {
  min-height: 164px;
  margin: 0;
  padding: 36px 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 42px;
  color: var(--vault-ink);
  background: #eef3f1;
  background-image: none;
  border: 1px solid rgba(80, 118, 107, .08);
  border-radius: var(--vault-radius-xl);
  box-shadow: none;
  overflow: hidden;
  position: relative;
}

.hero-copy { position: relative; }

.hero-copy::before {
  content: "";
  position: absolute;
  left: -52px;
  top: 50%;
  width: 3px;
  height: 76px;
  border-radius: 999px;
  background: #2f6f62;
  transform: translateY(-50%);
}

.hero h2 {
  margin: 0;
  max-width: 760px;
  color: var(--vault-ink);
  font-size: clamp(36px, 3.25vw, 44px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -.045em;
}

.hero p {
  margin: 16px 0 0;
  max-width: 700px;
  color: var(--vault-muted);
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
}

.hero-actions {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
}

.hero-actions .stamp-trigger {
  min-height: 44px;
  border-radius: 13px;
  color: var(--vault-green);
  background: rgba(255, 255, 255, .75);
}

.upload-button.primary {
  flex: 0 0 auto;
  min-width: 156px;
  height: 50px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: var(--vault-green);
  border: 1px solid var(--vault-green);
  border-radius: 13px;
  box-shadow: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s ease, transform .2s var(--vault-ease), box-shadow .2s ease;
}

.upload-button.primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-button.primary:hover {
  background: var(--vault-green-dark);
  border-color: var(--vault-green-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(63, 98, 88, .16);
}

.notice {
  margin: 18px 0 0;
  padding: 16px 18px;
  color: var(--vault-ink);
  background: var(--vault-paper);
  border: 1px solid var(--vault-line-soft);
  border-radius: var(--vault-radius-md);
  box-shadow: none;
}

.stats {
  margin: 20px 0 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stats button {
  position: relative;
  min-height: 82px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  color: var(--vault-ink);
  background: var(--vault-paper);
  border: 1px solid var(--vault-line-soft);
  border-radius: var(--vault-radius-md);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: transform .22s var(--vault-ease), box-shadow .22s ease, border-color .22s ease;
}

.stats button:hover {
  transform: translateY(-2px);
  border-color: var(--vault-line);
  box-shadow: var(--vault-shadow-soft);
}

.stats button b {
  color: var(--vault-ink);
  font-size: 32px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -.035em;
}

.stats button span { color: var(--vault-muted); font-size: 14px; line-height: 1.35; font-weight: 400; }

.stats button.has-action::after {
  content: "";
  position: absolute;
  top: 19px;
  right: 19px;
  width: 7px;
  height: 7px;
  background: var(--vault-orange);
  border-radius: 50%;
}

.toolbar,
.price-toolbar {
  margin: 0 0 28px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.search {
  height: 52px;
  padding: 0 14px 0 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--vault-paper);
  border: 1px solid var(--vault-line);
  border-radius: 14px;
  box-shadow: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.search:focus-within { border-color: var(--vault-green); box-shadow: 0 0 0 3px rgba(80, 118, 107, .1); }

.search > span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--vault-muted);
  font-size: 0;
}

.search > span svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.search input {
  min-width: 0;
  height: 100%;
  flex: 1;
  color: var(--vault-ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
  font-weight: 400;
}

.search input::placeholder { color: var(--vault-subtle); }

.search button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--vault-muted);
  background: #f1f1f3;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity .15s ease, background-color .15s ease;
}

.search input:placeholder-shown + button { opacity: 0; pointer-events: none; }
#searchInput:placeholder-shown + #clearSearch { visibility: hidden; }

.toolbar > .search { width: 100%; max-width: none; }
.toolbar.nav-only { grid-template-columns: minmax(0, max-content); }

.collection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 14px;
}
.collection-heading h2 { margin: 0; font-size: 22px; color: var(--vault-ink); }
.collection-heading p { margin: 0; font-size: 13px; color: var(--vault-muted); }
#documentView .empty { min-height: 0; padding: 36px 20px; }
#resetDocumentSearch { margin-top: 12px; }

.tabs,
.price-modes {
  min-height: 44px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: #e9e9ec;
  border: 0;
  border-radius: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.price-modes::-webkit-scrollbar { display: none; }

.tabs button,
.price-modes button {
  min-width: max-content;
  height: 36px;
  padding: 0 15px;
  color: var(--vault-muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.tabs button.active,
.price-modes button.active { color: var(--vault-ink); background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .09); }

.document-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }

.doc-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: var(--vault-ink);
  background: var(--vault-paper);
  border: 1px solid var(--vault-line-soft);
  border-radius: var(--vault-radius-md);
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s var(--vault-ease), box-shadow .25s ease, border-color .25s ease;
}

.doc-card:hover { transform: translateY(-3px); border-color: var(--vault-line); box-shadow: var(--vault-shadow-soft); }
.doc-card:focus-within { outline: 2px solid #2f6f62; outline-offset: 2px; }

.doc-preview {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  flex: none;
  overflow: hidden;
  background: #eeeef0;
}

.doc-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .28s var(--vault-ease);
}

.doc-card:hover .doc-preview img { transform: scale(1.02); }

.doc-body {
  min-width: 0;
  min-height: 172px;
  padding: 14px 15px 15px;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.doc-top { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.type-badge {
  max-width: 65%;
  padding: 4px 7px;
  color: var(--vault-green-dark);
  background: var(--vault-green-soft);
  border: 0;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status { color: var(--vault-muted); font-size: 11px; line-height: 1.25; font-weight: 500; white-space: nowrap; }
.status.confirmed { color: var(--vault-green-dark); }
.status.pending, .status.waiting, .status.retry { color: #9a6518; }

.doc-card h3 {
  margin: 12px 0 6px;
  color: var(--vault-ink);
  font-size: 16px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -.018em;
}

.doc-open {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.doc-open::after { content: ""; position: absolute; inset: 0; }
.doc-open:focus-visible { outline: none; }

.doc-card p {
  margin: 0;
  color: var(--vault-muted);
  font-size: 12.5px;
  line-height: 1.55;
  font-weight: 400;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.doc-meta {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--vault-line-soft);
  color: var(--vault-subtle);
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading { margin: 12px 0 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-heading h2 { margin: 0; color: var(--vault-ink); font-size: 27px; line-height: 1.15; font-weight: 650; letter-spacing: -.035em; }
.section-heading p { margin: 7px 0 0; color: var(--vault-muted); font-size: 14px; line-height: 1.55; }

.secondary,
.section-heading .primary,
.dialog-actions button,
.dialog-head button,
.panel-title button,
.panel-title a { min-height: 42px; border-radius: 11px; box-shadow: none; }

.category-card,
.category-text-card,
.reminder-card,
.trash-item,
.price-customers,
.price-results-panel,
.price-detail,
.price-card,
.price-table-wrap { background: var(--vault-paper); border-color: var(--vault-line-soft); box-shadow: none; }

.category-card, .category-text-card, .reminder-card, .trash-item, .price-card { border-radius: var(--vault-radius-md); }
.price-customers, .price-results-panel, .price-detail { border-radius: var(--vault-radius-lg); }

.empty {
  min-height: 300px;
  padding: 58px 24px;
  color: var(--vault-muted);
  background: var(--vault-paper);
  border: 1px solid var(--vault-line-soft);
  border-radius: var(--vault-radius-lg);
}

.detail-dialog,
dialog {
  color: var(--vault-ink);
  background: var(--vault-paper);
  border: 1px solid var(--vault-line-soft);
  border-radius: var(--vault-radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .16);
}

dialog::backdrop { background: rgba(0, 0, 0, .28); backdrop-filter: blur(4px); }
.login-shell { background: var(--vault-bg); background-image: none; }
.login-card { border: 1px solid var(--vault-line-soft); border-radius: var(--vault-radius-xl); box-shadow: var(--vault-shadow-soft); }
.brand-mark { background: var(--vault-green); }

.mobile-nav {
  background: rgba(255, 255, 255, .9);
  border-top: 1px solid var(--vault-line-soft);
  box-shadow: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.mobile-nav button,
.mobile-nav button span,
.camera-nav,
.camera-nav:active { animation: none !important; transform: none; }
.mobile-nav button { color: var(--vault-muted); }
.mobile-nav button.active { color: var(--vault-green-dark); }
.mobile-nav .camera-nav { background: var(--vault-green); color: #fff; }

.hero,
.stats,
.toolbar,
#documentView,
#reminderView,
#categoryView,
#pricesView,
#trashView { animation: vault-rise .45s var(--vault-ease) both; }
.stats { animation-delay: .04s; }
.toolbar { animation-delay: .08s; }
#documentView, #reminderView, #categoryView, #pricesView, #trashView { animation-delay: .12s; }

@keyframes vault-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1024px) {
  .app-shell > header { padding-inline: 24px; }
  .app-shell > main { width: min(calc(100% - 40px), var(--vault-content)); padding-top: 30px; }
  .hero { padding: 32px 40px; }
  .hero-copy::before { left: -40px; }
  .hero h2 { font-size: clamp(34px, 4.6vw, 40px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .toolbar { grid-template-columns: 1fr; gap: 14px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1 0 auto; }
  .header-actions button { padding-inline: 11px; }
}

@media (max-width: 700px) {
  .app-shell > header { height: 60px; min-height: 60px; padding-inline: 18px; }
  .app-shell > header h1 { font-size: 17px; }
  .eyebrow { font-size: 8px; }
  .header-actions > button:not(#moreBtn) { display: none !important; }
  .header-actions #moreBtn { display: inline-flex !important; }
  .app-shell > main { width: min(calc(100% - 28px), var(--vault-content)); padding-top: 18px; padding-bottom: 104px; }
  .hero { min-height: 0; padding: 22px 26px 20px; display: block; border-radius: 21px; }
  .hero-copy::before { left: -26px; }
  .hero h2 { font-size: clamp(24px, 6.5vw, 32px); line-height: 1.18; }
  .hero p { margin-top: 8px; font-size: 13px; line-height: 1.55; }
  .hero-actions { margin-top: 14px; grid-template-columns: 1fr 1fr; }
  .hero-actions .upload-button { width: 100%; min-width: 0; height: 44px; padding-inline: 9px; }
  .hero-actions .stamp-trigger { padding-inline: 9px; }
  .stats { margin: 12px 0 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .stats button { min-height: 66px; padding: 8px; border-radius: 12px; }
  .stats button b { font-size: 22px; }
  .stats button span { font-size: 12px; }
  .stats button.has-action::after { top: 9px; right: 8px; width: 5px; height: 5px; }
  .toolbar { margin-bottom: 16px; gap: 10px; }
  .toolbar.nav-only { grid-template-columns: minmax(0, 1fr); }
  .search { height: 50px; }
  .tabs { width: 100%; max-width: 100%; justify-content: flex-start; }
  .tabs button { flex: 0 0 auto; padding-inline: 16px; }
  .document-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .doc-card { border-radius: 12px; }
  .doc-preview { min-height: 0; aspect-ratio: 1; }
  .doc-body { min-height: 0; padding: 7px 8px 8px; gap: 4px; }
  .doc-card h3 { margin: 0; font-size: 13px; }
  .doc-top { order: 1; margin-top: auto; }
  .doc-top .status { overflow: hidden; text-overflow: ellipsis; }
  .doc-card :is(.type-badge, p, .doc-meta) { display: none; }
  .collection-heading h2 { font-size: 19px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .section-heading h2 { font-size: 25px; }
  .section-heading > button, .price-heading-actions { width: 100%; }
  .price-heading-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .price-heading-actions button { width: 100%; }
  .price-toolbar { grid-template-columns: 1fr; gap: 12px; }
  .price-modes { width: 100%; }
  .price-modes button { flex: 1; }
}

@media (max-width: 390px) {
  .app-shell > main { width: calc(100% - 24px); }
  .hero { padding-inline: 22px; }
  .hero-copy::before { left: -22px; }
  .tabs { width: 100%; max-width: 100%; }
}

@media (max-width: 340px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-actions { grid-template-columns: 1fr; }
}

#stampDialog {
  width: min(540px, calc(100% - 24px));
  max-height: min(680px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid var(--vault-line);
  border-radius: 20px;
  background: white;
}

#stampDialog .dialog-head, .stamp-dialog .dialog-head h2, .stamp-body h3 { margin: 0; }
.stamp-body { padding: 18px 22px 22px; }
.stamp-help, .stamp-feedback, .stamp-jobs p {
  color: var(--vault-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
  overflow-wrap: anywhere;
}
.stamp-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0 18px; }
.stamp-inputs button, .stamp-result { min-height: 44px; }
.stamp-feedback { color: var(--vault-ink); margin-bottom: 14px; }
.stamp-body h3 { font-size: 16px; }
.stamp-body h3 + .stamp-help { margin-top: 8px; }
.stamp-jobs { padding: 0; margin: 10px 0 0; list-style: none; }
.stamp-jobs:empty { margin: 0; }
.stamp-jobs li { display: grid; gap: 7px; padding: 12px 0; border-top: 1px solid var(--vault-line); }
.stamp-job-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.stamp-job-heading strong { font-weight: 600; overflow-wrap: anywhere; }
.stamp-status { flex: 0 0 auto; font-size: 12px; border-radius: 99px; padding: 4px 8px; background: #f0f1f1; color: var(--vault-muted); }
.stamp-status[data-state="completed"] { background: #eaf1ee; color: var(--vault-green); }
.stamp-status:is([data-state="review"], [data-state="failed"]) { background: #fbf1e2; color: #764b23; }
.stamp-result { justify-self: start; }

#appView :is(button, a):focus-visible,
:is(#detailDialog, #stampDialog) :is(button, a, input, summary):focus-visible {
  outline: 2px solid #2f6f62;
  outline-offset: 2px;
}
#appView .doc-open:focus-visible { outline: none; }

#detailDialog[open] {
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  overflow: hidden;
}
#detailDialog .dialog-head { flex: none; gap: 12px; }
#detailDialog .dialog-head > div:first-child { min-width: 0; }
#detailDialog .dialog-head h2 { overflow-wrap: anywhere; }
.detail-header-actions { flex: none; display: flex; align-items: center; gap: 8px; }
#detailDialog .detail-grid {
  min-height: 0;
  overflow: auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  scroll-padding: 12px;
  overscroll-behavior: contain;
}
#detailDialog .confirm-panel {
  min-width: 0;
  max-height: none;
  overflow: visible;
}
#detailDialog .image-stage { height: clamp(160px, 54dvh, 530px); }
#detailDialog .image-stage img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
#detailDialog.text-only .detail-grid { grid-template-columns: minmax(0, 1fr); }
#detailDialog .source-note { overflow-wrap: anywhere; }
.recognition-panel {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--vault-line-soft);
  border-radius: 12px;
  background: var(--vault-green-soft);
}
.recognition-panel h3 { margin: 0 0 10px; font-size: 15px; }
.recognition-actions, .detail-more-actions, .detail-footer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recognition-panel button:disabled, .detail-footer button:disabled { opacity: .55; cursor: wait; }
.recognition-panel #openaiStatus { margin: 10px 0 0; color: var(--vault-green-dark); font-size: 13px; }
#openaiResult { margin-top: 10px; }
#openaiFields .field-row { grid-template-columns: minmax(84px, .65fr) minmax(0, 1fr); }
#openaiFields input[readonly] { background: var(--vault-paper); }
#loadOpenaiFields { margin-top: 8px; }
.document-actions { margin-top: 12px; padding: 0 4px; }
.document-actions summary, #openaiResult summary {
  padding: 10px 0;
  color: var(--vault-green-dark);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.detail-more-actions { padding-top: 4px; }
.detail-footer {
  display: flex;
  flex: none;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--vault-line-soft);
  background: var(--vault-paper);
}
.detail-footer-buttons { flex-shrink: 0; }
.detail-footer-buttons button { min-height: 44px; }
#detailFeedback { min-width: 0; margin: 0 auto 0 0; color: var(--vault-muted); font-size: 13px; overflow-wrap: anywhere; }
#detailFeedback:empty { display: none; }

@media (min-width: 851px) and (min-height: 620px) {
  #detailDialog .source-panel { position: sticky; top: 0; }
}

@media (max-width: 850px) {
  #detailDialog .detail-grid { display: block; }
  #detailDialog .image-stage { height: clamp(140px, 31dvh, 330px); }
}

@media (max-width: 700px) {
  #detailDialog[open] {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  #detailDialog .detail-grid { flex: 1; }
  #detailDialog .dialog-head .close { width: 44px; height: 44px; }
  #detailDialog .field-row > input { min-height: 44px; font-size: 16px; }
  #detailDialog .field-remove, #detailDialog .field-add-button,
  #detailDialog .recognition-panel button, #detailDialog .detail-more-actions button { min-height: 44px; }
  .detail-footer { display: block; padding-inline: 14px; }
  #detailFeedback { margin-bottom: 6px; }
  .detail-footer-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
