.labduck {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 100120;
  color: #12312d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.labduck[hidden] {
  display: none !important;
}

.labduck-toggle,
.labduck button,
.labduck input,
.labduck textarea,
.labduck select {
  font: inherit;
}

.labduck-toggle {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(33, 115, 101, 0.26);
  border-radius: 8px;
  background: #f7fffb;
  color: #063f38;
  box-shadow: 0 18px 40px rgba(16, 45, 39, 0.18);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0;
}

.labduck-toggle span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #dff7ed;
}

.labduck-panel {
  display: none;
  width: min(430px, calc(100vw - 36px));
  max-height: min(78vh, 720px);
  overflow: auto;
  border: 1px solid rgba(37, 95, 85, 0.22);
  border-radius: 8px;
  background: #fbfffd;
  box-shadow: 0 24px 70px rgba(11, 39, 33, 0.2);
  padding: 14px;
}

.labduck.is-open .labduck-toggle {
  display: none;
}

.labduck.is-open .labduck-panel {
  display: block;
}

.labduck-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.labduck-kicker {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 800;
  color: #6a7c78;
  text-transform: uppercase;
  letter-spacing: 0;
}

.labduck h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: #063f38;
}

.labduck-icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(52, 79, 74, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: #294b46;
  cursor: pointer;
}

.labduck-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.labduck-field span {
  font-size: 11px;
  font-weight: 800;
  color: #5d706c;
}

.labduck-field input,
.labduck-field textarea,
.labduck-field select {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(50, 91, 83, 0.18);
  border-radius: 8px;
  background: #f5fbf8;
  color: #12312d;
  padding: 9px 10px;
  outline: none;
}

.labduck-field textarea {
  resize: vertical;
  min-height: 64px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.labduck-field input:focus,
.labduck-field textarea:focus,
.labduck-field select:focus {
  border-color: rgba(30, 131, 111, 0.55);
  box-shadow: 0 0 0 3px rgba(42, 157, 125, 0.14);
}

.labduck-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.labduck-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 8px;
}

.labduck-actions button {
  min-height: 36px;
  border: 1px solid rgba(45, 100, 90, 0.2);
  border-radius: 8px;
  background: #eef9f3;
  color: #0d5044;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
}

.labduck-actions button:hover {
  border-color: rgba(28, 121, 102, 0.45);
  background: #e2f6eb;
}

.labduck-status {
  min-height: 18px;
  margin: 0 0 8px;
  color: #5e706c;
  font-size: 12px;
}

.labduck-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.labduck-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(38, 102, 92, 0.16);
  border-radius: 8px;
  background: #ffffff;
  color: #31524c;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.labduck-grid {
  display: grid;
  gap: 10px;
}

.labduck-card {
  border: 1px solid rgba(40, 88, 80, 0.16);
  border-radius: 8px;
  background: #ffffff;
  padding: 11px;
}

.labduck-card:nth-child(2n) {
  background: #f8fbff;
}

.labduck-card:nth-child(3n) {
  background: #fffaf2;
}

.labduck-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.labduck-number {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #dff7ed;
  color: #0d5044;
  font-size: 12px;
  font-weight: 900;
}

.labduck-card h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
  color: #12312d;
}

.labduck-card-value {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 8px;
}

.labduck-card-value strong {
  color: #063f38;
  font-size: 22px;
  line-height: 1;
}

.labduck-card-value span,
.labduck-tag,
.labduck-detail {
  font-size: 12px;
}

.labduck-card-value span {
  color: #61736f;
  font-weight: 800;
}

.labduck-tag {
  display: inline-flex;
  margin: 8px 0 0;
  border-radius: 8px;
  background: #eef5ff;
  color: #244f85;
  padding: 4px 7px;
  font-weight: 850;
}

.labduck-detail {
  margin: 8px 0 0;
  color: #4f625e;
  line-height: 1.45;
}

.labduck-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 0;
}

.labduck-card dl div {
  min-width: 0;
  border-radius: 8px;
  background: rgba(237, 246, 242, 0.78);
  padding: 7px;
}

.labduck-card dt {
  color: #758681;
  font-size: 10px;
  font-weight: 850;
}

.labduck-card dd {
  margin: 2px 0 0;
  color: #183a35;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

html.dark .labduck,
body.dark .labduck,
.dark .labduck {
  color: #e8f7f0;
}

html.dark .labduck-toggle,
body.dark .labduck-toggle,
.dark .labduck-toggle {
  border-color: rgba(129, 222, 197, 0.28);
  background: #081713;
  color: #c9f8e6;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
}

html.dark .labduck-toggle span,
body.dark .labduck-toggle span,
.dark .labduck-toggle span {
  background: #123b31;
}

html.dark .labduck-panel,
body.dark .labduck-panel,
.dark .labduck-panel {
  border-color: rgba(150, 216, 198, 0.22);
  background: #08130f;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

html.dark .labduck h2,
body.dark .labduck h2,
.dark .labduck h2,
html.dark .labduck-card h3,
body.dark .labduck-card h3,
.dark .labduck-card h3,
html.dark .labduck-card-value strong,
body.dark .labduck-card-value strong,
.dark .labduck-card-value strong,
html.dark .labduck-card dd,
body.dark .labduck-card dd,
.dark .labduck-card dd {
  color: #f4fff9;
}

html.dark .labduck-kicker,
body.dark .labduck-kicker,
.dark .labduck-kicker,
html.dark .labduck-field span,
body.dark .labduck-field span,
.dark .labduck-field span,
html.dark .labduck-status,
body.dark .labduck-status,
.dark .labduck-status,
html.dark .labduck-detail,
body.dark .labduck-detail,
.dark .labduck-detail {
  color: #9eb8af;
}

html.dark .labduck-icon-button,
body.dark .labduck-icon-button,
.dark .labduck-icon-button,
html.dark .labduck-field input,
body.dark .labduck-field input,
.dark .labduck-field input,
html.dark .labduck-field textarea,
body.dark .labduck-field textarea,
.dark .labduck-field textarea,
html.dark .labduck-field select,
body.dark .labduck-field select,
.dark .labduck-field select,
html.dark .labduck-card,
body.dark .labduck-card,
.dark .labduck-card,
html.dark .labduck-summary span,
body.dark .labduck-summary span,
.dark .labduck-summary span {
  border-color: rgba(151, 214, 198, 0.18);
  background: #0d1e18;
  color: #e8f7f0;
}

html.dark .labduck-card:nth-child(2n),
body.dark .labduck-card:nth-child(2n),
.dark .labduck-card:nth-child(2n) {
  background: #0d1821;
}

html.dark .labduck-card:nth-child(3n),
body.dark .labduck-card:nth-child(3n),
.dark .labduck-card:nth-child(3n) {
  background: #1d1a10;
}

html.dark .labduck-actions button,
body.dark .labduck-actions button,
.dark .labduck-actions button {
  border-color: rgba(135, 224, 197, 0.2);
  background: #123229;
  color: #d9ffee;
}

html.dark .labduck-tag,
body.dark .labduck-tag,
.dark .labduck-tag {
  background: #132743;
  color: #d7e7ff;
}

html.dark .labduck-card dl div,
body.dark .labduck-card dl div,
.dark .labduck-card dl div {
  background: rgba(15, 45, 36, 0.78);
}

@media (max-width: 640px) {
  .labduck {
    left: max(10px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .labduck-panel {
    width: calc(100vw - 20px);
    max-height: 82vh;
    padding: 12px;
  }

  .labduck-controls {
    grid-template-columns: 1fr;
  }

  .labduck-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
