.xmd-poll {
  --xmd-poll-accent: #08785c;
  --xmd-poll-accent-soft: #e8f3ef;
  --xmd-poll-border: #d8dee2;
  --xmd-poll-muted: #68727a;
  --xmd-poll-surface: #fff;
  max-width: 760px;
  margin: 1rem 0;
  border: 1px solid var(--xmd-poll-border);
  border-radius: 8px;
  color: #20262b;
  background: var(--xmd-poll-surface);
  overflow: hidden;
}

.xmd-poll-header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.8rem;
  padding: 1.1rem 1.1rem 0.85rem;
  border-bottom: 1px solid #e7ebed;
}

.xmd-poll-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #fff;
  background: var(--xmd-poll-accent);
  font-size: 1.05rem;
}

.xmd-poll-kicker {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--xmd-poll-accent);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.xmd-poll-header h3 {
  margin: 0 !important;
  color: #20262b !important;
  font-size: 1.1rem !important;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.xmd-poll-description {
  margin: 0.35rem 0 0 !important;
  color: var(--xmd-poll-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.xmd-poll-form {
  margin: 0;
}

.xmd-poll-options {
  display: grid;
  gap: 0.55rem;
  padding: 1rem 1.1rem;
}

.xmd-poll-option {
  position: relative;
  display: grid;
  min-height: 46px;
  align-items: center;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 0.65rem;
  margin: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid #dfe4e7;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
}

.xmd-poll-option:hover {
  border-color: #9fbcb3;
  background: #fbfdfc;
}

.xmd-poll-option:focus-within {
  border-color: var(--xmd-poll-accent);
  box-shadow: 0 0 0 2px rgba(8, 120, 92, 0.12);
}

.xmd-poll-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.xmd-poll-control {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #aab3b8;
  border-radius: 50%;
  background: #fff;
}

.xmd-poll[data-xmd-mode="multiple"] .xmd-poll-control {
  border-radius: 4px;
}

.xmd-poll-option > input:checked + .xmd-poll-control {
  border-color: var(--xmd-poll-accent);
  background: var(--xmd-poll-accent);
}

.xmd-poll-option > input:checked + .xmd-poll-control::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.xmd-poll[data-xmd-mode="multiple"] .xmd-poll-option > input:checked + .xmd-poll-control::after {
  width: 8px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  border-radius: 0;
  background: transparent;
  transform: translateY(-1px) rotate(-45deg);
}

.xmd-poll-option-text,
.xmd-poll-option-result {
  position: relative;
  z-index: 1;
}

.xmd-poll-option-text {
  min-width: 0;
  color: #2c3338;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.xmd-poll-option-result {
  color: var(--xmd-poll-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.xmd-poll-option-result b {
  color: inherit;
  font-weight: 600;
}

.xmd-poll-option-bar {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 0;
  max-width: 100%;
  background: var(--xmd-poll-accent-soft);
  transition: width 0.3s ease;
  pointer-events: none;
}

.xmd-poll-option > input:disabled ~ * {
  cursor: default;
}

.xmd-poll-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.1rem;
  border-top: 1px solid #e7ebed;
  background: #fafbfb;
}

.xmd-poll-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  color: var(--xmd-poll-muted);
  font-size: 0.78rem;
}

.xmd-poll-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.xmd-poll-meta i {
  color: #879198;
}

.xmd-poll-submit {
  display: inline-flex;
  min-width: 92px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--xmd-poll-accent);
  border-radius: 5px;
  color: #fff;
  background: var(--xmd-poll-accent);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.xmd-poll-submit:hover:not(:disabled) {
  border-color: #05684f;
  background: #05684f;
}

.xmd-poll-submit:focus-visible {
  outline: 2px solid rgba(8, 120, 92, 0.3);
  outline-offset: 2px;
}

.xmd-poll-submit:disabled {
  border-color: #aeb8bd;
  background: #aeb8bd;
  cursor: default;
}

.xmd-poll-status {
  min-height: 0;
  padding: 0 1.1rem;
  color: var(--xmd-poll-muted);
  font-size: 0.82rem;
}

.xmd-poll-status:not(:empty) {
  min-height: 34px;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  border-top: 1px solid #edf0f1;
}

.xmd-poll-status.is-success { color: #08785c; }
.xmd-poll-status.is-error { color: #b53c35; }

.xmd-poll-modal .modal-content {
  border: 1px solid #d8dee2;
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(24, 31, 36, 0.18);
  overflow: hidden;
}

.xmd-poll-modal .modal-content > form {
  display: flex;
  min-height: 0;
  max-height: calc(100vh - 3.5rem);
  flex-direction: column;
}

.xmd-poll-modal .modal-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
}

.xmd-poll-modal .modal-header,
.xmd-poll-modal .modal-footer {
  flex: 0 0 auto;
}

.xmd-poll-modal .modal-header,
.xmd-poll-modal .modal-footer {
  border-color: #e2e6e8;
}

.xmd-poll-modal .modal-title {
  font-size: 1.08rem;
  line-height: 1.35;
}

.xmd-poll-modal-subtitle {
  margin-top: 0.15rem;
  color: #747e85;
  font-size: 0.78rem;
}

.xmd-poll-builder-section {
  padding: 0.85rem;
  border: 1px solid #e0e5e7;
  border-radius: 7px;
  background: #f8faf9;
}

.xmd-poll-builder-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.xmd-poll-builder-heading > span {
  color: #79838a;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.xmd-poll-option-fields {
  display: grid;
  gap: 0.5rem;
}

.xmd-poll-option-field {
  display: grid;
  align-items: center;
  grid-template-columns: 24px minmax(0, 1fr) 34px;
  gap: 0.45rem;
}

.xmd-poll-option-handle {
  color: #9ba4a9;
  text-align: center;
}

.xmd-poll-option-remove,
.xmd-poll-add-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.xmd-poll-option-remove {
  width: 34px;
  height: 34px;
  color: #8a4a46;
}

.xmd-poll-option-remove:hover:not(:disabled) {
  border-color: #e8cbc8;
  background: #fff4f3;
}

.xmd-poll-option-remove:disabled {
  color: #b9c0c4;
  cursor: default;
}

.xmd-poll-add-option {
  min-height: 34px;
  gap: 0.4rem;
  margin: 0.65rem 0 0 24px;
  padding: 0.35rem 0.65rem;
  border-color: #cbd5d8;
  color: #365e52;
  background: #fff;
  font-size: 0.84rem;
}

.xmd-poll-add-option:hover:not(:disabled) {
  border-color: #8db1a6;
  background: #f2f8f6;
}

.xmd-poll-add-option:disabled {
  color: #9ca5aa;
  cursor: default;
}

.xmd-poll-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid #ced5d8;
  border-radius: 6px;
  background: #f2f4f5;
}

.xmd-poll-mode label {
  min-width: 0;
  margin: 0;
  padding: 0.42rem 0.55rem;
  border-radius: 4px;
  color: #667078;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.xmd-poll-mode input:checked + label {
  color: #245347;
  background: #fff;
  box-shadow: 0 1px 3px rgba(30, 39, 44, 0.12);
}

[data-xmd-poll-max-row] {
  transition: opacity 0.15s ease;
}

[data-xmd-poll-max-row].is-disabled {
  opacity: 0.45;
}

.xmd-poll-changeable {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #e0e5e7;
  border-radius: 6px;
  background: #fafbfb;
}

.xmd-poll-changeable strong,
.xmd-poll-changeable span {
  display: block;
}

.xmd-poll-changeable strong {
  color: #30373c;
  font-size: 0.87rem;
}

.xmd-poll-changeable span {
  margin-top: 0.12rem;
  color: #788289;
  font-size: 0.76rem;
}

@media (max-width: 575.98px) {
  .xmd-poll-modal .modal-content > form {
    max-height: calc(100vh - 1rem);
  }

  .xmd-poll-header {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .xmd-poll-icon {
    width: 36px;
    height: 36px;
  }

  .xmd-poll-options {
    padding: 0.8rem;
  }

  .xmd-poll-option {
    grid-template-columns: 18px minmax(0, 1fr);
    padding: 0.6rem 0.65rem;
  }

  .xmd-poll-option-result {
    grid-column: 2;
  }

  .xmd-poll-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 0.75rem 0.8rem;
  }

  .xmd-poll-submit {
    width: 100%;
  }

  .xmd-poll-builder-section {
    padding: 0.7rem;
  }

  .xmd-poll-option-field {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .xmd-poll-option-handle {
    display: none;
  }

  .xmd-poll-add-option {
    margin-left: 0;
  }
}

[data-bs-theme="dark"] .xmd-poll {
  --xmd-poll-accent-soft: #183c33;
  --xmd-poll-border: #414a50;
  --xmd-poll-muted: #a7b0b6;
  --xmd-poll-surface: #24292d;
  color: #edf0f2;
}

[data-bs-theme="dark"] .xmd-poll-header,
[data-bs-theme="dark"] .xmd-poll-footer,
[data-bs-theme="dark"] .xmd-poll-status:not(:empty) {
  border-color: #3b4449;
}

[data-bs-theme="dark"] .xmd-poll-header h3,
[data-bs-theme="dark"] .xmd-poll-option-text {
  color: #edf0f2 !important;
}

[data-bs-theme="dark"] .xmd-poll-option,
[data-bs-theme="dark"] .xmd-poll-control {
  border-color: #4a545a;
  background: #2b3135;
}

[data-bs-theme="dark"] .xmd-poll-option:hover,
[data-bs-theme="dark"] .xmd-poll-footer {
  background: #292f33;
}
