:root {
  --d-bg: #f4f6f9;
  --d-header: #1e3a5f;
  --d-accent: #6e93d6;
  --d-text: #1a1a1a;
  --d-danger: #b91c1c;
  --d-border: #d8dee8;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--d-bg);
  color: var(--d-text);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

body.is-app {
  overflow: hidden;
  height: 100%;
}

.hidden {
  display: none !important;
}

.d-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  background: #fff;
  color: #1e293b;
  border-bottom: 1px solid var(--d-border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  min-height: 3.5rem;
  flex: 0 0 auto;
}

.d-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e40af;
  white-space: nowrap;
  flex: 0 0 auto;
}

.d-news-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 28rem;
  justify-content: center;
  margin: 0 auto;
}

.d-news-spot {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  margin: 0;
  padding: 0.28rem 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.45rem;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.d-news-spot:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.d-news-spot-kicker {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  line-height: 1;
}

.d-news-spot-title {
  display: block;
  width: 100%;
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.d-news-btn {
  position: relative;
  flex: 0 0 auto;
  font-weight: 700;
}

.d-news-unread-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 1.1rem;
  padding: 0.05rem 0.28rem;
  border-radius: 999px;
  background: #facc15;
  color: #0f172a;
  border: 1px solid #ca8a04;
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.d-news-header.is-highlight .d-news-spot {
  border-color: #facc15;
  background: #fef9c3;
  box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.55);
  animation: d-news-pulse 1.4s ease-out infinite;
}

.d-news-header.is-highlight .d-news-spot-kicker {
  color: #a16207;
}

@keyframes d-news-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(250, 204, 21, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .d-news-header.is-highlight .d-news-spot {
    animation: none;
  }
}

.d-news-header.is-update {
  max-width: 34rem;
}

.d-news-header.is-update .d-news-spot {
  border-color: #ea580c;
  background: #ffedd5;
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.25);
  animation: none;
}

.d-news-header.is-update .d-news-spot:hover {
  background: #fed7aa;
  border-color: #c2410c;
}

.d-news-header.is-update .d-news-spot-kicker {
  color: #c2410c;
}

.d-news-header.is-update .d-news-spot-title {
  color: #9a3412;
}

.d-version-reload {
  flex: 0 0 auto;
  font-weight: 800;
  color: #fff;
  background: #ea580c;
  border: 1px solid #c2410c;
}

.d-version-reload:hover {
  background: #c2410c;
}

.d-news-page {
  padding: 0.75rem 1rem 1.25rem;
  overflow: auto;
  min-height: 0;
  height: 100%;
}

.d-news-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.d-news-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.35rem;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.d-news-item:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.d-news-item.is-unread {
  border-color: #fde68a;
  background: #fffbeb;
}

.d-news-item-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.15rem;
}

.d-news-item-meta {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
}

.d-news-detail {
  margin-top: 0.35rem;
}

.d-news-detail-title {
  margin: 0.55rem 0 0.25rem;
  font-size: 1.15rem;
  color: #0f172a;
}

.d-news-detail-body {
  margin-top: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #1e293b;
}

.d-news-detail-body h1,
.d-news-detail-body h2,
.d-news-detail-body h3 {
  margin: 0.75rem 0 0.35rem;
  line-height: 1.25;
}

.d-news-detail-body p,
.d-news-detail-body ul,
.d-news-detail-body ol {
  margin: 0.4rem 0;
}

.d-news-detail-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 0.1rem 0.25rem;
  border-radius: 0.2rem;
}

.d-news-detail-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 0.35rem;
  overflow: auto;
}

.d-news-detail-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.d-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  background: #eef2ff;
  color: #3730a3;
}

.d-spacer {
  flex: 1;
}

.d-header-user {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
  flex: 0 0 auto;
}

.d-expert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #475569;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
  white-space: nowrap;
}

.d-expert-toggle input {
  margin: 0;
}

.d-main {
  max-width: none;
  margin: 0;
  padding: 0.75rem 1rem 1.5rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.is-app .d-main {
  overflow: hidden;
  padding-bottom: 0.75rem;
}

.d-main #panel_app {
  max-width: none;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.d-card {
  padding: 1.5rem;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.d-card-narrow {
  max-width: 28rem;
  margin: 2rem auto 0;
}

.d-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
}

.d-meta {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: #555;
}

.d-meta code {
  font-size: 0.8rem;
  background: #eef2f7;
  padding: 0.1rem 0.35rem;
  border-radius: 0.2rem;
}

.d-expert-hint {
  color: #8a5a00;
}

.d-label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
}

.d-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #c5cdd8;
  border-radius: 0.35rem;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.4;
}

.d-input:focus {
  outline: 2px solid var(--d-accent);
  outline-offset: 1px;
  border-color: var(--d-accent);
}

.d-btn {
  margin-top: 1rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 0.35rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.d-btn-primary {
  width: 100%;
  background: var(--d-accent);
  color: #fff;
  font-weight: 600;
}

.d-btn-primary:hover {
  filter: brightness(0.95);
}

.d-btn-ghost {
  margin-top: 0;
  background: transparent;
  color: #475569;
  border: 1px solid var(--d-border);
}

.d-btn-ghost:hover {
  background: #f1f5f9;
}

.d-btn-icon {
  margin-top: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #b91c1c;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.d-btn-icon:hover {
  background: #fef2f2;
}

.d-error {
  margin: 0.75rem 0 0;
  color: var(--d-danger);
  font-size: 0.875rem;
}

.d-context {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.3rem 0.65rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  flex: 0 1 auto;
  width: max-content;
  max-width: calc(100% - 14rem);
  min-width: 0;
  overflow: hidden;
}

.d-context-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.d-context-item {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 18rem;
}

.d-context-progress {
  flex: 0 0 auto;
  min-width: 0;
}

.d-context-sep {
  flex: 0 0 auto;
  width: 1px;
  height: 1.75rem;
  background: #e2e8f0;
}

.d-context-label {
  display: block;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.05rem;
  line-height: 1.1;
}

.d-context-value {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  width: max-content;
  max-width: 100%;
}

.d-context-bar-track {
  margin-top: 0.2rem;
  width: 5.5rem;
  height: 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.d-context-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #2563eb;
  transition: width 0.2s ease, background 0.2s ease;
}

.d-context-bar-fill.is-complete {
  background: #22c55e;
}

.d-btn-export {
  position: relative;
  margin-top: 0;
  padding: 0.3rem 0.55rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.35rem;
  background: #fff;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  white-space: nowrap;
  width: auto;
  min-width: 0;
  line-height: 1.2;
}

.d-btn-export:hover {
  background: #f1f5f9;
}

.d-btn-export:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.d-export-badge {
  position: absolute;
  top: -0.45rem;
  right: -0.35rem;
  padding: 0.05rem 0.3rem;
  border-radius: 0.15rem;
  border: 1px solid #fff;
  background: #2563eb;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 900;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.d-btn-icon-gear {
  margin-top: 0;
  position: relative;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #1e40af;
  cursor: pointer;
  flex: 0 0 auto;
}

.d-btn-icon-gear::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.85rem;
  height: 0.85rem;
  margin: -0.425rem 0 0 -0.425rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  box-sizing: border-box;
  box-shadow:
    0 -0.55rem 0 -0.28rem currentColor,
    0 0.55rem 0 -0.28rem currentColor,
    -0.55rem 0 0 -0.28rem currentColor,
    0.55rem 0 0 -0.28rem currentColor,
    -0.39rem -0.39rem 0 -0.28rem currentColor,
    0.39rem -0.39rem 0 -0.28rem currentColor,
    -0.39rem 0.39rem 0 -0.28rem currentColor,
    0.39rem 0.39rem 0 -0.28rem currentColor;
}

.d-btn-icon-gear:hover {
  background: #eff6ff;
}

.d-view-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: #f1f5f9;
  border-bottom: 1px solid var(--d-border);
  flex: 0 0 auto;
}

.d-view-bar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

.d-tabs {
  display: none;
}

.d-tab-panels {
  margin-top: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.d-tab-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.d-snackbar {
  visibility: hidden;
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  min-width: 12rem;
  max-width: 90vw;
  padding: 0.75rem 1.25rem;
  background: #333;
  color: #fff;
  border-radius: 0.35rem;
  font-size: 0.875rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.d-snackbar.show {
  visibility: visible;
  opacity: 1;
}

.d-card-flush {
  padding: 0;
  overflow: hidden;
}

.d-maengel-layout {
  display: grid;
  /* Narrower than NiceGUI ~18%: scales with viewport, caps so wide screens stay tight */
  grid-template-columns: clamp(10.75rem, 11vw + 1.25rem, 13.25rem) 1fr;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.d-maengel-nav {
  border-right: 1px solid var(--d-border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.d-nav-toolbar {
  display: flex;
  border-bottom: 1px solid var(--d-border);
  background: #fff;
  min-height: 2.5rem;
  flex: 0 0 auto;
}

.d-nav-btn {
  flex: 1;
  margin: 0;
  padding: 0.5rem 0.25rem;
  border: none;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.d-nav-btn.is-active {
  color: var(--d-header);
  border-bottom-color: var(--d-accent);
  background: #fff;
}

.d-nav-list {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  overscroll-behavior: contain;
}

.d-nav-empty {
  padding: 0.85rem 0.75rem;
  font-style: italic;
  color: #94a3b8;
}

.d-nav-customer {
  border-bottom: 1px solid #e2e8f0;
}

.d-nav-customer-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.45rem;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
}

.d-nav-customer-title:hover {
  background: #eef2f7;
}

.d-nav-customer-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d-nav-chevron {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-top: 0.28rem solid transparent;
  border-bottom: 0.28rem solid transparent;
  border-left: 0.38rem solid #94a3b8;
  transition: transform 0.12s ease;
}

.d-nav-customer.is-open > .d-nav-customer-title .d-nav-chevron {
  transform: rotate(90deg);
}

.d-nav-icon {
  flex: 0 0 auto;
  width: 0.9rem;
  height: 0.9rem;
  position: relative;
  opacity: 0.85;
}

/* briefcase / work */
.d-nav-icon-work {
  border: 1.5px solid #64748b;
  border-radius: 0.12rem;
  background: transparent;
}
.d-nav-icon-work::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.22rem;
  width: 0.38rem;
  height: 0.22rem;
  margin-left: -0.19rem;
  border: 1.5px solid #64748b;
  border-bottom: none;
  border-radius: 0.12rem 0.12rem 0 0;
  box-sizing: border-box;
}

/* building */
.d-nav-icon-building {
  border: 1.5px solid #64748b;
  border-radius: 0.08rem;
  background:
    linear-gradient(#64748b, #64748b) 20% 30% / 18% 18% no-repeat,
    linear-gradient(#64748b, #64748b) 55% 30% / 18% 18% no-repeat,
    linear-gradient(#64748b, #64748b) 20% 60% / 18% 18% no-repeat,
    linear-gradient(#64748b, #64748b) 55% 60% / 18% 18% no-repeat;
}

.d-nav-projects {
  display: none;
  padding: 0 0 0.2rem;
}

.d-nav-projects.is-open {
  display: block;
}

.d-nav-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.32rem 0.45rem 0.32rem 1.15rem;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.75rem;
  color: #334155;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.d-nav-item-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d-nav-item:hover {
  background: #f8fafc;
}

.d-nav-item.is-active {
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 700;
}

.d-nav-mangel {
  padding-left: 0.55rem;
  min-height: 1.75rem;
  font-size: 0.75rem;
}

.d-nav-item.is-done {
  background: #4ade80;
  color: #0f172a;
  font-weight: 600;
}

.d-nav-item.is-done:hover {
  background: #22c55e;
}

.d-nav-item.is-done.is-active {
  box-shadow: inset 0 0 0 2px #3b82f6;
}

.d-nav-mangel.is-active:not(.is-done) {
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 700;
}

.d-maengel-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 0.75rem 1rem 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.d-editor-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: #94a3b8;
}

.d-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #eef2f7;
}

.d-editor-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 35%);
  gap: 0.35rem 0.5rem;
  align-items: stretch;
}

.d-editor-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.d-editor-section {
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  padding: 0.55rem 0.65rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.d-editor-section-fields {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0.15rem;
}

.d-editor-section-norms {
  margin: 0.55rem 0;
  overflow: visible;
  transition: background 0.12s ease;
}

.d-editor-section-norms:has(#chk_extracted_norms:checked) {
  background: #dcfce7;
  border-color: #86efac;
}

.d-editor-section-bottom {
  margin-bottom: 0.25rem;
  overflow: visible;
}

.d-editor-bottom-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  overflow: visible;
}

.d-editor-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.d-btn-toolbar {
  margin-top: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 0.2rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.d-btn-save {
  background: var(--d-accent);
  color: #fff;
  border: 1px solid #5f82c4;
}

.d-btn-save:hover {
  filter: brightness(0.96);
}

.d-btn-delete {
  background: var(--d-accent);
  color: #fff;
  border: 1px solid #5f82c4;
}

.d-btn-delete:hover {
  filter: brightness(0.96);
}

.d-btn-ki {
  background: #fff;
  color: #334155;
  border: 1px solid var(--d-border);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.d-btn-ki:hover {
  background: #f8fafc;
}

.d-btn-ki:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.d-btn-solid {
  margin-top: 0;
  background: var(--d-accent);
  color: #fff;
  font-weight: 600;
}

.d-btn-danger {
  margin-top: 0;
  background: #fff;
  color: var(--d-danger);
  border: 1px solid #fecaca;
  font-weight: 600;
}

.d-audio-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-width: 100%;
}

.d-audio-tag {
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #64748b;
}

.d-audio-play {
  margin: 0;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  background: #fff;
  color: #1e40af;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.d-audio-play:hover {
  background: #f1f5f9;
}

.d-audio-time {
  font-size: 0.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #475569;
  white-space: nowrap;
  min-width: 4.8rem;
}

.d-audio-seek {
  width: 5.5rem;
  max-width: 18vw;
  height: 0.35rem;
  margin: 0;
  padding: 0;
  accent-color: var(--d-accent);
  cursor: pointer;
}

.d-audio-vol {
  width: 3rem;
  height: 0.35rem;
  margin: 0;
  padding: 0;
  accent-color: #94a3b8;
  cursor: pointer;
}

.d-audio-el {
  display: none;
}

.d-pruef-box {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem 0.55rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.4rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  min-width: 8.5rem;
}

.d-pruef-label {
  font-size: 0.5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.d-pruef-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.d-pruef-track {
  flex: 1 1 auto;
  height: 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  min-width: 4.5rem;
}

.d-pruef-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #60a5fa;
  transition: width 0.15s ease, background 0.15s ease;
}

.d-pruef-fill.is-complete {
  background: #22c55e;
}

#pruef_progress {
  font-size: 0.625rem;
  font-weight: 800;
  color: #64748b;
  white-space: nowrap;
}

.d-pruef {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
}

.d-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.65rem;
  align-items: start;
}

.d-field-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.d-field {
  margin-bottom: 0.3rem;
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
  transition: background 0.12s ease;
}

.d-field:has(> .d-field-head > input[type="checkbox"]:checked),
.d-field-radio:has(> input[type="checkbox"]:checked) {
  background: #dcfce7;
}

.d-field-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.1rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #475569;
}

.d-field-head input[type="checkbox"],
.d-field-radio > input[type="checkbox"],
.d-norms-check {
  accent-color: #22c55e;
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

.d-editor-form .d-input {
  padding: 0.3rem 0.45rem;
  font-size: 0.85rem;
  border-radius: 0.2rem;
  border-color: #cbd5e1;
}

.d-textarea {
  /* ~5 lines at 0.85rem / line-height 1.4 + vertical padding */
  min-height: calc(1.4em * 5 + 0.6rem);
  height: auto;
  overflow-y: hidden;
  resize: none;
  field-sizing: content;
}

.d-radio-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin: 0.25rem 0 0.45rem;
}

.d-field-radio {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin-bottom: 0;
  flex: 1 1 16rem;
  min-width: 0;
}

.d-radios {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.75rem;
}

.d-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}

.d-radio-label input {
  margin: 0;
  width: 1rem;
  height: 1rem;
}

.d-editor-gallery {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  /* Slots stay 4:3; do not stretch to left form height (avoids letterbox bars). */
  align-items: flex-start;
  justify-content: flex-start;
  border-left: 1px solid var(--d-border);
  padding-left: 0.5rem;
  box-sizing: border-box;
  container-type: size;
}

.d-gallery-slot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  /* Width from shared column; height = 4:3. Cap width so height never exceeds form. */
  max-width: min(100%, calc(100cqh * 4 / 3));
  max-height: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  align-self: flex-start;
  border: 1px solid var(--d-border);
  border-radius: 0.15rem;
  overflow: hidden;
  background: #0f172a;
}

.d-gallery-label {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  z-index: 2;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.85);
  padding: 0.05rem 0.3rem;
  pointer-events: none;
}

.d-gallery-img {
  /* Absolute fill avoids %-height gaps when slot height comes only from aspect-ratio */
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #0f172a;
  cursor: pointer;
}

/* Auswahl + Crop nur bei Hover / Fokus — Klick aufs Bild öffnet Crop */
.d-gallery-tools {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.35rem 0.3rem 0.3rem;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.d-gallery-slot:hover .d-gallery-tools,
.d-gallery-slot:focus-within .d-gallery-tools {
  opacity: 1;
  pointer-events: auto;
}

.d-gallery-sel {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  font-size: 0.7rem;
  padding: 0.15rem 0.25rem;
  height: 1.6rem;
}

.d-gallery-crop-btn {
  flex: 0 0 auto;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 0.2rem;
  background: rgba(30, 58, 95, 0.92);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  height: 1.6rem;
  cursor: pointer;
}

.d-gallery-crop-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.d-gallery-crop-btn:hover:not(:disabled) {
  background: #1e3a5f;
}

.d-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.d-modal-card {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  padding: 1rem 1.1rem 1.15rem;
}

.d-modal-card.d-crop-card {
  /* Hug canvas — no fixed wide card (that caused black letterboxing) */
  width: max-content;
  max-width: 96vw;
  min-width: min(22rem, 94vw);
}

.d-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.d-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--d-header);
}

.d-crop-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.15rem 0 0.65rem;
  border-bottom: 1px solid var(--d-border);
}

.d-crop-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem 0.5rem;
  margin-bottom: -1px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.d-crop-tab:hover {
  color: #0f172a;
}

.d-crop-tab.is-active {
  color: var(--d-header);
  border-bottom-color: var(--d-accent);
}

.d-crop-panel.hidden {
  display: none !important;
}

.d-crop-stage-wrap {
  background: #111;
  border-radius: 0.35rem;
  padding: 0;
  margin: 0.5rem auto 0.75rem;
  display: block;
  line-height: 0;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
}

.d-crop-canvas {
  display: block;
  /* Bitmap size = HTML width/height attrs only. Never set CSS width/height. */
  background: #111;
  cursor: grab;
  touch-action: none;
  user-select: none;
  vertical-align: top;
}

.d-annotate-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
}

.d-ann-tool.is-active {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

.d-ann-colors {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0.15rem;
}

.d-ann-swatch {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: var(--sw, #ef4444);
  padding: 0;
  cursor: pointer;
}

.d-ann-swatch.is-active {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.d-annotate-stage-wrap {
  background: #111;
  border-radius: 0.35rem;
  padding: 0;
  margin: 0.15rem auto 0.65rem;
  display: flex;
  justify-content: center;
  align-items: center;
  width: max-content;
  max-width: 100%;
  max-height: calc(92vh - 14rem);
  overflow: auto;
}

.d-annotate-canvas {
  display: block;
  max-width: 100%;
}

/* Fabric wraps canvas in .canvas-container */
.d-annotate-stage-wrap .canvas-container {
  margin: 0 auto;
}

#annotate_hint {
  margin: 0 0 0.65rem;
}

.d-crop-save-actions {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--d-border);
}

.d-crop-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 0.15rem 0 0.85rem;
}

.d-crop-toolbar #crop_zoom_label {
  min-width: 3.25rem;
  text-align: center;
  font-weight: 700;
}

.d-crop-toolbar .d-btn {
  min-width: 2.25rem;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}

.d-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.d-feedback-card {
  max-width: 32rem;
}

.d-feedback-textarea {
  width: 100%;
  min-height: 7rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  font: inherit;
  resize: vertical;
}

.d-feedback-file {
  display: block;
  width: 100%;
  margin: 0.25rem 0 0.75rem;
  font-size: 0.85rem;
}

.d-norms-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.d-norms-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.d-btn-recherche {
  background: #fff;
  color: #1e40af;
  border: 1px solid #cbd5e1;
  letter-spacing: 0.04em;
}

.d-btn-recherche:hover {
  background: #f8fafc;
}

/* --- CTA: KI-Recherche (bubble burst) --- */

.d-cta-fx {
  position: relative;
  isolation: isolate;
  overflow: visible;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.75rem;
  padding: 0;
  margin-top: 0;
  background: transparent;
  color: #fff;
  border: none;
  box-shadow: none;
  cursor: pointer;
  z-index: 0;
}

.d-cta-fx.d-btn-ki {
  background: transparent;
  color: #fff;
  border: none;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: none;
}

.d-cta-fx.d-btn-ki:hover {
  background: transparent;
  filter: none;
}

.d-cta-fx.d-btn-ki:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#btn_generate.d-cta-fx {
  min-width: 11.5rem;
}

.d-cta-fx:hover {
  background: transparent;
  color: #fff;
  filter: none;
}

/* Squash ring only — text/face never scaled (stays sharp) */
.d-cta-fx-plate {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: transparent;
  border: 2px solid rgba(147, 197, 253, 0.85);
  border-radius: 0.25rem;
  pointer-events: none;
  animation: d-cta-squash-boom 5s ease-in-out infinite;
  opacity: 0;
}

.d-cta-fx:hover .d-cta-fx-face {
  background: #1e40af;
}

.d-cta-fx-face {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.45rem 0.95rem;
  background: #1d4ed8;
  border: 1px solid #1e40af;
  border-radius: 0.2rem;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.28);
  overflow: visible;
  transform: none;
}

.d-cta-fx-text {
  position: relative;
  z-index: 2;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #fff;
  text-shadow: none;
  -webkit-font-smoothing: antialiased;
  transform: none;
}

.d-cta-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  z-index: 3;
  padding: 0.08rem 0.35rem;
  background: #facc15;
  color: #0f172a;
  border: 1px solid #ca8a04;
  border-radius: 0.2rem;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.d-cta-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.d-cta-soap {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--s, 6px);
  height: var(--s, 6px);
  margin: calc(var(--s, 6px) / -2) 0 0 calc(var(--s, 6px) / -2);
  border-radius: 50%;
  pointer-events: none;
  background: #1d4ed8;
  border: 1px solid #1e40af;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  opacity: 0;
  will-change: transform, opacity;
  animation: d-cta-soap-fly 5s linear infinite;
  animation-delay: var(--st, 0s);
}

@keyframes d-cta-squash-boom {
  0%,
  10% {
    transform: none;
    opacity: 0;
  }
  14% {
    transform: scale(0.92);
    opacity: 0.9;
  }
  18% {
    transform: scale(0.84);
    opacity: 1;
  }
  22% {
    transform: scale(1.04);
    opacity: 0.7;
  }
  26%,
  100% {
    transform: none;
    opacity: 0;
  }
}

@keyframes d-cta-soap-fly {
  0%,
  26% {
    opacity: 0;
    transform: rotate(var(--a)) translateY(calc(var(--rim-start) * -1)) scale(0.75);
  }
  28% {
    opacity: 0.55;
    transform: rotate(var(--a)) translateY(calc(var(--rim-start) * -1)) scale(0.9);
  }
  32% {
    opacity: 1;
    transform: rotate(var(--a)) translateY(calc(var(--rim) * -1)) scale(1);
  }
  52% {
    opacity: 0.9;
    transform: rotate(var(--a))
      translateY(calc((var(--rim) + var(--travel)) * -1)) scale(1);
  }
  68% {
    opacity: 0;
    transform: rotate(var(--a))
      translateY(calc((var(--rim) + var(--travel) + 12px) * -1)) scale(0.75);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--a))
      translateY(calc((var(--rim) + var(--travel) + 12px) * -1)) scale(0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .d-cta-fx-plate,
  .d-cta-soap {
    animation: none !important;
  }

  .d-cta-soap,
  .d-cta-fx-plate {
    display: none;
  }
}

.d-norms-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 12rem;
  min-height: 1.9rem;
  min-width: 0;
  padding: 0.2rem 0.35rem;
  background: rgba(248, 250, 252, 0.7);
  border: 1px solid #e2e8f0;
  border-radius: 0.25rem;
}

.d-norms-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
}

.d-norms-empty {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
}

.d-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  border-radius: 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
}

.d-chip-name {
  font-weight: 700;
}

.d-chip-sep {
  opacity: 0.55;
  font-weight: 500;
}

.d-chip-pages {
  font-weight: 500;
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
}

.d-btn-icon-copy {
  margin-top: 0;
  padding: 0.15rem 0.4rem;
  border: none;
  border-radius: 0.2rem;
  background: transparent;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}

.d-btn-icon-copy:hover {
  background: #e2e8f0;
  color: #1e40af;
}

.d-check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.d-btn-outline {
  margin-top: 0;
  background: #fff;
  color: var(--d-header);
  border: 1px solid var(--d-border);
  font-weight: 600;
}

.d-btn-tiny {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.d-btn-ghost-dark {
  margin-top: 0;
  background: transparent;
  color: #475569;
  border: 1px solid var(--d-border);
}

.d-research-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 34%);
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}

.d-research-layout.is-pdf-expanded {
  grid-template-columns: minmax(0, 1fr) minmax(0, 75%);
}

.d-research-main {
  min-width: 0;
  min-height: 0;
  padding: 0.65rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: hidden;
}

.d-research-pdf {
  border-left: 1px solid var(--d-border);
  background: #dbeafe;
  padding: 0.4rem;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.d-pdf-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 0.25rem;
}

.d-pdf-pane-active {
  flex: 1 1 auto;
  height: 100%;
}

/* LEGACY dual-compare layout — only if USE_LEGACY_PDF_IMAGE_PREVIEW is re-enabled */
.d-pdf-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.d-pdf-pane-label {
  margin: 0;
  padding: 0.3rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93c5fd;
  background: #1e293b;
  flex: 0 0 auto;
}

.d-research-pdf .d-meta {
  color: #64748b;
  padding: 1rem;
}

.d-pdf-preview {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.d-pdf-js-viewer {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.d-pdf-js-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.3rem 0.4rem;
  background: #bfdbfe;
  border-bottom: 1px solid #93c5fd;
  flex: 0 0 auto;
}

.d-pdf-js-zoom,
.d-pdf-js-pager,
.d-pdf-js-cite-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.d-pdf-js-zoom {
  justify-self: start;
}

.d-pdf-js-pager {
  justify-self: center;
  grid-column: 2;
}

.d-pdf-js-cite-wrap {
  justify-self: end;
  justify-content: flex-end;
}

.d-pdf-js-toolbar .d-meta {
  padding: 0;
  min-width: 2.5rem;
  text-align: center;
  color: #1e3a8a;
  font-weight: 700;
  font-size: 0.75rem;
}

#pdf_js_page_label {
  min-width: 7.5rem;
}

.d-pdf-js-cite {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  color: #64748b;
  /* Reserve space for the longer status so the right column width stays stable */
  display: inline-block;
  min-width: 12.5rem;
  text-align: right;
}

.d-pdf-js-cite.is-cited {
  color: #166534;
}

.d-pdf-js-cite.is-not-cited {
  color: #9a3412;
}

.d-pdf-js-toolbar .d-btn {
  margin-top: 0;
  min-width: 1.75rem;
  color: #1e3a8a;
  border-color: #93c5fd;
  background: #eff6ff;
}

.d-pdf-js-toolbar .d-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.d-pdf-js-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.35rem;
  background: #dbeafe;
}

.d-pdf-js-canvas {
  display: block;
  max-width: none;
  background: #fff;
  margin: 0 auto;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.d-stale-banner {
  padding: 0.45rem 0.65rem;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.d-research-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.25rem;
  flex: 0 0 auto;
}

.d-research-toolbar .d-btn {
  margin-top: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 0.2rem;
}

.d-search-input {
  flex: 1 1 14rem;
  min-width: 10rem;
  margin: 0;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.d-hide-short {
  margin-left: 0.25rem;
}

.d-selected-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 0.25rem;
  flex: 0 0 auto;
}

.d-selected-bar .d-btn {
  margin-top: 0;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.d-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding: 0.35rem;
  background: #dbeafe;
  border-radius: 0.25rem;
  overscroll-behavior: contain;
}

.d-search-more-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 0.35rem 0.45rem;
  flex: 0 0 auto;
}

.d-search-more-wrap .d-btn {
  margin-top: 0;
}

.d-search-more-exhausted {
  margin: 0;
  font-style: italic;
  color: #64748b;
  text-align: center;
}

.d-result-card {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.15rem;
  padding: 0.45rem 0.55rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.d-result-card.is-selected {
  border-color: #34d399;
  background: #f0fdf4;
}

.d-result-card.is-pdf-viewing {
  box-shadow: inset 3px 0 0 #2563eb;
}

.d-pdf-viewing-hint {
  font-size: 0.7rem;
  font-weight: 700;
  color: #1d4ed8;
  white-space: nowrap;
}

.d-pdf-viewing-hint:empty {
  display: none;
}

.d-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.d-result-alias {
  color: #6e93d6;
  font-weight: 500;
  font-size: 1.05rem;
}

.d-result-file {
  color: #64748b;
  font-size: 0.7rem;
}

.d-result-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
  margin: 0.15rem 0;
  white-space: pre-wrap;
}

.d-result-body {
  font-size: 0.85rem;
  color: #1e293b;
  white-space: pre-wrap;
  margin: 0;
}

.d-result-body b,
.d-result-title b {
  font-weight: 700;
  background: #fef08a;
}

.d-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
  align-items: center;
}

.d-cite-select {
  width: auto;
  min-width: 6.5rem;
  margin: 0;
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
}

.d-cite-manual {
  width: auto;
  min-width: 10rem;
  max-width: 16rem;
  margin: 0;
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
}

.d-expand-btn {
  margin-top: 0.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--d-accent);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.d-manager {
  padding: 0.75rem 1rem 1.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.d-manager-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.d-expert-bar {
  padding: 0.5rem;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 0.35rem;
}

.d-upload-label {
  margin-top: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.d-mgr-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

.d-mgr-progress {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  background: #f8fafc;
}

.d-mgr-progress.is-aborted {
  border-color: #fca5a5;
  background: #fef2f2;
}

.d-mgr-progress.is-stale {
  border-color: #fbbf24;
  background: #fffbeb;
}

.d-mgr-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.d-mgr-progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.d-mgr-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0284c7, #0369a1);
  transition: width 0.25s ease;
}

.d-mgr-progress.is-aborted .d-mgr-progress-bar {
  background: #dc2626;
}

.d-mgr-progress.is-stale .d-mgr-progress-bar {
  background: linear-gradient(90deg, #d97706, #b45309);
}

.d-mgr-progress-detail,
.d-mgr-progress-counts,
.d-mgr-progress-alive {
  margin: 0.4rem 0 0;
  line-height: 1.35;
}

.d-mgr-progress-alive.is-live::before {
  content: "● ";
  color: #059669;
}

.d-mgr-progress-alive.is-stale-text {
  color: #b45309;
  font-weight: 600;
}

.d-mgr-table {
  border: 1px solid var(--d-border);
  border-radius: 0.35rem;
  overflow: auto;
  max-height: calc(70vh - 10rem);
  background: #fff;
}

.d-mgr-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1.2fr) minmax(10rem, 1.4fr) 5.5rem 5.5rem auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #eef2f7;
  font-size: 0.8rem;
}

.d-mgr-row.is-head {
  background: #f8fafc;
  font-weight: 700;
  color: #64748b;
  position: sticky;
  top: 0;
  z-index: 1;
}

.d-mgr-row input.d-input {
  margin: 0;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
}

.d-badge-ok {
  color: #166534;
  font-weight: 700;
}

.d-badge-pending {
  color: #9a3412;
  font-weight: 700;
}

@media (max-width: 720px) {
  .d-header {
    flex-wrap: wrap;
  }

  .d-context {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .d-context-sep {
    display: none;
  }

  .d-context-item {
    flex: 1 1 40%;
  }

  .d-context-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .d-tabs {
    overflow-x: auto;
  }

  .d-tab {
    white-space: nowrap;
  }

  .d-maengel-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(10rem, 32vh) minmax(0, 1fr);
  }

  .d-maengel-nav {
    border-right: none;
    border-bottom: 1px solid var(--d-border);
  }

  .d-editor-top,
  .d-field-row,
  .d-radio-row {
    grid-template-columns: 1fr;
  }

  .d-editor-top {
    display: flex;
    flex-direction: column;
  }

  .d-radio-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .d-field-radio {
    flex: 1 1 auto;
  }

  .d-editor-gallery {
    flex-direction: row;
    height: auto;
    min-height: 0;
    align-self: stretch;
    align-items: flex-start;
    border-left: none;
    padding-left: 0;
  }

  .d-gallery-slot {
    flex: 1 1 0;
    min-width: 0;
    height: auto;
    max-height: none;
    max-width: 100%;
    aspect-ratio: 4 / 3;
  }

  .d-gallery-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .d-gallery-tools {
    opacity: 1;
    pointer-events: auto;
  }

  .d-research-layout {
    grid-template-columns: 1fr;
  }

  .d-research-layout.is-pdf-expanded {
    grid-template-columns: 1fr;
  }

  .d-mgr-row {
    grid-template-columns: 1fr;
  }
}
