.lcw-widget {
  --lcw-ink: #111923;
  --lcw-muted: #625f57;
  --lcw-line: #d7bf89;
  --lcw-soft: #f8f3e8;
  --lcw-primary: #c59a3d;
  --lcw-primary-dark: #765312;
  --lcw-navy: #071320;
  --lcw-navy-soft: #111e2e;
  --lcw-ivory: #fffdf7;
  --lcw-teal: #24704d;
  --lcw-danger: #9f2f26;
  box-sizing: border-box;
  overflow: hidden;
  margin: 1.5rem auto;
  max-width: 1120px;
  color: var(--lcw-ink);
  border: 1px solid #bd9137;
  border-radius: 16px;
  background:
    linear-gradient(rgb(255 253 247 / 96%), rgb(251 247 238 / 96%)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgb(197 154 61 / 4%) 80px);
  box-shadow: 0 24px 65px rgb(0 8 18 / 24%), 0 0 0 4px rgb(197 154 61 / 9%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.lcw-widget *,
.lcw-widget *::before,
.lcw-widget *::after {
  box-sizing: border-box;
}

.lcw-widget button,
.lcw-widget input,
.lcw-widget select {
  font: inherit;
}

.lcw-header {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2.15rem 2.25rem;
  color: #fffaf0;
  border-bottom: 1px solid #bd9137;
  background:
    radial-gradient(ellipse at 86% 12%, rgb(180 202 221 / 22%), transparent 25%),
    radial-gradient(ellipse at 72% 115%, rgb(116 143 167 / 24%), transparent 38%),
    linear-gradient(112deg, #02070d 0%, #091521 52%, #101d2c 100%);
}

.lcw-header::before {
  position: absolute;
  z-index: -1;
  inset: -100% -12% -120% 46%;
  background:
    repeating-radial-gradient(
      ellipse at center,
      transparent 0 28px,
      rgb(201 218 232 / 11%) 30px 34px,
      transparent 37px 61px
    );
  content: "";
  filter: blur(7px);
  opacity: 0.75;
  transform: rotate(-9deg) scale(1.18, 0.7);
}

.lcw-header > * {
  position: relative;
  z-index: 1;
}

.lcw-header h2,
.lcw-panel h3,
.lcw-panel h4 {
  margin: 0;
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.2;
}

.lcw-header h2 {
  max-width: 820px;
  color: #fffdf7;
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.018em;
}

.lcw-eyebrow,
.lcw-step {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.lcw-eyebrow {
  color: #e5bd64;
}

.lcw-subtitle {
  max-width: 660px;
  margin: 0.65rem 0 0;
  color: #e9e5dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
}

.lcw-connection {
  flex: 0 0 auto;
  padding: 0.45rem 0.8rem;
  color: #f2cb70;
  border: 1px solid rgb(197 154 61 / 68%);
  border-radius: 999px;
  background: rgb(2 8 15 / 58%);
  box-shadow: inset 0 0 18px rgb(102 133 161 / 16%);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.lcw-connection.is-loading::before {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.45rem;
  border: 2px solid rgb(229 189 100 / 32%);
  border-top-color: #e5bd64;
  border-radius: 50%;
  content: "";
  animation: lcw-spin 0.8s linear infinite;
}

.lcw-connection.is-error {
  color: #fff3f2;
  background: rgb(127 29 29 / 55%);
}

@keyframes lcw-spin {
  to { transform: rotate(360deg); }
}

.lcw-snapshot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.35rem;
  padding: 0.8rem 2rem;
  color: #e7e3db;
  border-bottom: 1px solid rgb(197 154 61 / 42%);
  background: var(--lcw-navy);
  font-size: 0.79rem;
}

.lcw-snapshot strong {
  color: #e2b95f;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

.lcw-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  align-items: end;
  gap: 1rem;
  margin: 1.1rem 1.25rem 0;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--lcw-line);
  border-radius: 10px;
  background: rgb(255 253 247 / 92%);
  box-shadow: 0 7px 22px rgb(7 19 32 / 5%);
}

.lcw-controls label > span {
  display: block;
  margin-bottom: 0.35rem;
  color: #27251f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.lcw-controls small {
  color: var(--lcw-muted);
  font-weight: 500;
}

.lcw-controls select,
.lcw-controls input {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0.65rem 0.75rem;
  color: var(--lcw-ink);
  border: 1px solid #cfbd96;
  border-radius: 7px;
  background: var(--lcw-ivory);
  box-shadow: inset 0 1px 2px rgb(7 19 32 / 5%);
}

.lcw-controls select:hover,
.lcw-controls input:hover {
  border-color: #b48a36;
}

.lcw-controls select:focus,
.lcw-controls input:focus,
.lcw-button:focus-visible,
.lcw-candidate:focus-visible,
.lcw-view-tabs button:focus-visible {
  outline: 3px solid rgb(197 154 61 / 32%);
  outline-offset: 2px;
}

.lcw-control-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 0.55rem;
}

.lcw-button {
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

.lcw-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.lcw-button-primary {
  color: #f5cf77;
  border-color: #b98a30;
  background: linear-gradient(180deg, #142234, #071320);
  box-shadow: 0 5px 13px rgb(7 19 32 / 16%);
}

.lcw-button-primary:hover:not(:disabled) {
  color: #fff4d4;
  border-color: #d9b45d;
  background: linear-gradient(180deg, #1b2d43, #091827);
}

.lcw-button-secondary {
  color: #253041;
  border-color: #cfbd96;
  background: var(--lcw-ivory);
}

.lcw-button-secondary:hover:not(:disabled) {
  border-color: #b48a36;
  background: #f8f1e2;
}

.lcw-alert {
  margin: 1rem 2rem 0;
  padding: 0.8rem 1rem;
  color: #7a271a;
  border: 1px solid #f4b4ad;
  border-radius: 10px;
  background: #fff2f0;
  font-weight: 700;
}

.lcw-view-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1rem 1.25rem 0;
  padding: 0;
  border-bottom: 1px solid #d8c59d;
}

.lcw-view-tabs button {
  padding: 0.62rem 0.95rem;
  color: #686359;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.lcw-view-tabs button[aria-selected="true"] {
  color: #7a5612;
  border-bottom-color: #b8882b;
}

.lcw-panel {
  padding: 1.3rem 1.25rem 2rem;
}

.lcw-panel[hidden],
.lcw-widget [hidden] {
  display: none !important;
}

.lcw-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lcw-step {
  color: #9a6d19;
}

.lcw-panel h3 {
  color: #172130;
  font-size: 1.35rem;
  font-weight: 600;
}

.lcw-panel h4 {
  margin: 1.6rem 0 0.8rem;
  font-size: 1rem;
  font-weight: 600;
}

.lcw-sequence-context {
  margin: 0;
  color: var(--lcw-muted);
  font-size: 0.82rem;
  text-align: right;
}

.lcw-candidate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.lcw-candidate {
  display: block;
  width: 100%;
  padding: 1rem;
  color: var(--lcw-ink);
  border: 1px solid var(--lcw-line);
  border-radius: 10px;
  background: rgb(255 253 247 / 96%);
  box-shadow: 0 5px 15px rgb(7 19 32 / 6%);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.lcw-candidate:hover,
.lcw-candidate[aria-pressed="true"] {
  border-color: #b8882b;
  box-shadow: 0 9px 24px rgb(7 19 32 / 12%), 0 0 0 2px rgb(197 154 61 / 10%);
  transform: translateY(-1px);
}

.lcw-candidate[aria-pressed="true"] {
  background: #fffaf0;
}

.lcw-candidate-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  color: var(--lcw-muted);
  font-size: 0.77rem;
}

.lcw-candidate-heading strong {
  color: var(--lcw-ink);
  font-family: Georgia, "Times New Roman", serif;
}

.lcw-balls,
.lcw-selected-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.lcw-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  color: #111923;
  border: 1px solid #cbb98f;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff 0%, #fffdf7 42%, #e7dfcf 100%);
  box-shadow: inset -4px -5px 7px rgb(74 63 42 / 12%), 0 4px 8px rgb(7 19 32 / 14%);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.lcw-ball-small {
  width: 2.25rem;
  height: 2.25rem;
  border-width: 2px;
  font-size: 0.78rem;
}

.lcw-mini-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid #e1d5ba;
}

.lcw-mini-number {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--lcw-muted);
  font-size: 0.67rem;
}

.lcw-mini-swatch {
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid rgb(7 19 32 / 32%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 78%);
  border-radius: 50%;
}

.lcw-empty {
  padding: 2rem;
  color: var(--lcw-muted);
  border: 1px dashed #bca168;
  border-radius: 9px;
  background: var(--lcw-soft);
  text-align: center;
}

.lcw-score-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.lcw-score-grid > div {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--lcw-line);
  border-radius: 8px;
  background: var(--lcw-ivory);
  box-shadow: inset 0 2px 0 rgb(255 255 255 / 70%);
}

.lcw-score-grid > div:nth-child(4) {
  border-color: #b8882b;
  background:
    radial-gradient(circle at 90% 0%, rgb(129 153 177 / 17%), transparent 40%),
    linear-gradient(145deg, #132235, #071320);
  box-shadow: 0 7px 18px rgb(7 19 32 / 15%);
}

.lcw-score-grid > div:nth-child(4) span,
.lcw-score-grid > div:nth-child(4) strong,
.lcw-score-grid > div:nth-child(4) small {
  color: #efc96f;
}

.lcw-score-grid span,
.lcw-score-grid strong {
  display: block;
}

.lcw-score-grid span {
  margin-bottom: 0.2rem;
  color: var(--lcw-muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lcw-score-grid strong {
  overflow-wrap: anywhere;
  color: #172130;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 600;
}

.lcw-score-grid small {
  color: #936918;
  font-size: 0.58rem;
}

.lcw-formula-card {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  color: #fffaf0;
  border: 1px solid #b8882b;
  border-radius: 9px;
  background:
    radial-gradient(ellipse at 88% 0%, rgb(122 148 173 / 17%), transparent 38%),
    linear-gradient(120deg, #071320, #132235);
  box-shadow: 0 8px 22px rgb(7 19 32 / 12%);
}

.lcw-formula-card p {
  margin: 0.35rem 0 0;
  color: #d8d5ce;
  font-size: 0.78rem;
}

.lcw-formula-card .lcw-formula-label {
  margin: 0 0 0.25rem;
  color: #e7bd60;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lcw-formula-card strong {
  display: block;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.lcw-section-note,
.lcw-calculation-line {
  margin: -0.25rem 0 0.8rem;
  color: var(--lcw-muted);
  font-size: 0.78rem;
}

.lcw-calculation-line {
  margin: 0.7rem 0 0;
  color: #36342f;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lcw-number-evidence {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
}

.lcw-number-card {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--lcw-line);
  border-radius: 9px;
  background: var(--lcw-ivory);
  box-shadow: 0 4px 12px rgb(7 19 32 / 5%);
}

.lcw-number-card-top {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.lcw-number-labels {
  min-width: 0;
}

.lcw-number-labels strong,
.lcw-number-labels span {
  display: block;
}

.lcw-number-labels strong {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

.lcw-number-labels span {
  overflow: hidden;
  color: var(--lcw-muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lcw-carry-badge {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.22rem 0.45rem;
  color: #765312;
  border: 1px solid #d6b363;
  border-radius: 999px;
  background: #fff5d9;
  font-size: 0.63rem;
  font-weight: 800;
}

.lcw-color-row {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.lcw-color-chip {
  min-height: 2.35rem;
  padding: 0.38rem 0.5rem;
  border: 1px solid rgb(23 32 51 / 22%);
  border-radius: 6px;
  text-shadow: 0 1px 1px rgb(0 0 0 / 10%);
}

.lcw-color-chip span,
.lcw-color-chip strong {
  display: block;
}

.lcw-color-chip span {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lcw-color-chip strong {
  font-size: 0.73rem;
}

.lcw-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--lcw-line);
  border-radius: 8px;
  box-shadow: 0 5px 16px rgb(7 19 32 / 5%);
}

.lcw-table {
  width: 100%;
  min-width: 720px;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  background: var(--lcw-ivory);
  font-size: 0.79rem;
}

.lcw-table th,
.lcw-table td {
  padding: 0.7rem 0.8rem;
  border: 0;
  border-bottom: 1px solid #e4d8bd;
  text-align: left;
}

.lcw-table thead th {
  color: #f0c86a;
  background: linear-gradient(180deg, #152337, #071320);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lcw-table tbody tr:last-child th,
.lcw-table tbody tr:last-child td {
  border-bottom: 0;
}

.lcw-table .is-weak {
  color: var(--lcw-danger);
  font-weight: 800;
}

.lcw-table .is-strong {
  color: var(--lcw-teal);
  font-weight: 800;
}

.lcw-table .is-due {
  color: #765312;
  background: #fff5d9;
  font-weight: 800;
}

.lcw-signal-cell strong,
.lcw-signal-cell span,
.lcw-position-result strong,
.lcw-position-result span {
  display: block;
}

.lcw-signal-cell strong,
.lcw-position-result strong {
  color: #7a5612;
  font-family: Georgia, "Times New Roman", serif;
  font-variant-numeric: tabular-nums;
}

.lcw-signal-cell span,
.lcw-position-result span {
  color: var(--lcw-muted);
  font-size: 0.67rem;
  white-space: nowrap;
}

.lcw-winning-index {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid #c59a3d;
}

.lcw-subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lcw-subsection-heading h4 {
  margin: 0;
}

.lcw-policy-badge {
  display: inline-block;
  max-width: 280px;
  padding: 0.4rem 0.7rem;
  color: #f1cb73;
  border: 1px solid #b8882b;
  border-radius: 999px;
  background: var(--lcw-navy);
  box-shadow: inset 0 0 14px rgb(112 139 164 / 14%);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.lcw-winning-equation {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.lcw-winning-equation > div {
  padding: 0.8rem;
  border: 1px solid var(--lcw-line);
  border-radius: 8px;
  background: var(--lcw-ivory);
}

.lcw-winning-equation > div:last-child {
  border-color: #b8882b;
  background:
    radial-gradient(circle at 90% 0%, rgb(129 153 177 / 17%), transparent 42%),
    linear-gradient(145deg, #132235, #071320);
}

.lcw-winning-equation > div:last-child span,
.lcw-winning-equation > div:last-child strong {
  color: #efc96f;
}

.lcw-winning-equation span,
.lcw-winning-equation strong {
  display: block;
}

.lcw-winning-equation span {
  color: var(--lcw-muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lcw-winning-equation strong {
  margin-top: 0.2rem;
  color: #172130;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.lcw-inline-alert {
  padding: 0.8rem 1rem;
  color: #7a271a;
  border: 1px solid #f4b4ad;
  border-radius: 10px;
  background: #fff2f0;
  font-size: 0.8rem;
  font-weight: 700;
}

.lcw-audit-details {
  margin-top: 1rem;
  border: 1px solid var(--lcw-line);
  border-radius: 8px;
  background: var(--lcw-ivory);
}

.lcw-audit-details summary {
  padding: 0.8rem 1rem;
  color: #2c2a25;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.lcw-audit-details[open] summary {
  border-bottom: 1px solid var(--lcw-line);
}

.lcw-audit-details .lcw-table-wrap {
  border: 0;
  border-radius: 0 0 8px 8px;
}

.lcw-policy-provenance {
  padding: 1rem;
}

.lcw-provenance-list {
  display: grid;
  grid-template-columns: minmax(135px, 0.28fr) 1fr;
  gap: 0.55rem 1rem;
  margin: 0;
  font-size: 0.76rem;
}

.lcw-provenance-list dt {
  color: #302d27;
  font-weight: 900;
}

.lcw-provenance-list dd {
  margin: 0;
  color: var(--lcw-muted);
  overflow-wrap: anywhere;
}

.lcw-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  color: #d9d5cc;
  border-top: 1px solid #b8882b;
  background:
    radial-gradient(ellipse at 85% 0%, rgb(117 144 169 / 16%), transparent 42%),
    var(--lcw-navy);
  font-size: 0.7rem;
}

.lcw-footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .lcw-controls {
    grid-template-columns: 1fr 1fr;
  }

  .lcw-control-actions {
    grid-column: 1 / -1;
  }

  .lcw-number-evidence {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .lcw-subsection-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .lcw-widget {
    margin: 1rem 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .lcw-header,
  .lcw-panel-heading,
  .lcw-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .lcw-header,
  .lcw-controls,
  .lcw-panel,
  .lcw-footer {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .lcw-controls,
  .lcw-view-tabs {
    margin-right: 0.75rem;
    margin-left: 0.75rem;
  }

  .lcw-snapshot {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .lcw-view-tabs {
    padding-right: 0;
    padding-left: 0;
  }

  .lcw-controls,
  .lcw-candidate-list,
  .lcw-number-evidence,
  .lcw-winning-equation,
  .lcw-score-grid {
    grid-template-columns: 1fr;
  }

  .lcw-provenance-list {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .lcw-provenance-list dd {
    margin-bottom: 0.55rem;
  }

  .lcw-control-actions {
    grid-column: auto;
    flex-wrap: wrap;
  }

  .lcw-sequence-context {
    text-align: left;
  }

  .lcw-connection {
    align-self: flex-start;
  }
}

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