.tarot-widget[hidden] { display: none; }

[data-tarot-open] { cursor: pointer; }

.tarot-widget {
  --tw-surface: var(--form-surface, #fff);
  --tw-surface-muted: var(--form-surface-muted, #f0fafa);
  --tw-text: var(--form-text, #1d2b2a);
  --tw-muted: var(--form-muted, #4a524d);
  --tw-border: var(--form-line, rgba(43, 179, 177, .12));
  --tw-accent: var(--wd-teal-deep, #0f6f73);
  --tw-focus: rgba(15, 111, 115, .28);
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.tarot-widget__backdrop { position: absolute; inset: 0; background: rgba(8, 47, 50, .54); }

.tarot-widget__dialog {
  position: relative;
  width: min(720px, 100%);
  max-height: min(820px, calc(100dvh - 32px));
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--tw-text);
  background:
    radial-gradient(circle at 88% 8%, var(--form-bg-glow, rgba(100, 207, 202, .12)), transparent 30%),
    linear-gradient(180deg, var(--form-paper, #f4fffe), var(--tw-surface) 34%);
  border: 1px solid var(--form-rim, rgba(43, 179, 177, .26));
  border-radius: 14px;
  box-shadow: var(--wd-surface-shadow, 0 18px 46px rgba(29, 43, 42, .14));
}

.tarot-widget__header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px 16px; border-bottom: 1px solid var(--tw-border); background: rgba(244, 255, 254, .98); }
.tarot-widget__title { margin: 0; color: var(--form-heading, #0a4d52); font-size: clamp(1.35rem, 3vw, 1.75rem); line-height: 1.2; }
.tarot-widget__intro { margin: 6px 0 0; color: var(--tw-muted); line-height: 1.5; }
.tarot-widget__close { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--tw-border); border-radius: 50%; color: inherit; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; }
.tarot-widget__body { padding: 20px 24px 26px; }
.tarot-widget__controls { display: grid; gap: 18px; }
.tarot-widget__symbolism { display: grid; gap: 14px; padding: 14px 16px; border: 1px solid var(--tw-border); border-radius: 8px; background: var(--tw-surface-muted); }
.tarot-widget__symbolism[hidden] { display: none; }
.tarot-widget__symbolism .tarot-widget__section { margin-top: 0; }
.tarot-widget__fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.tarot-widget__legend, .tarot-widget__label { display: block; margin: 0 0 8px; font-weight: 700; }
.tarot-widget__segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tarot-widget__choice { position: relative; }
.tarot-widget__choice input { position: absolute; opacity: 0; pointer-events: none; }
.tarot-widget__choice span, .tarot-widget__select, .tarot-widget__button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid var(--wd-input-border, rgba(15, 111, 115, .18));
  border-radius: 8px;
  color: inherit;
  background: var(--tw-surface);
  font: inherit;
}
.tarot-widget__choice span { padding: 8px 12px; cursor: pointer; }
.tarot-widget__choice input:checked + span { border-color: var(--tw-accent); box-shadow: inset 0 0 0 1px var(--tw-accent); color: var(--tw-accent); font-weight: 700; }
.tarot-widget__select { width: 100%; padding: 8px 38px 8px 12px; justify-content: initial; cursor: pointer; }
.tarot-widget__button { width: 100%; padding: 9px 16px; border-color: var(--wd-btn-border-gold, rgba(228, 191, 99, .58)); color: var(--wd-on-dark, #fff9ee); background: var(--wd-btn-bg-lapis, linear-gradient(145deg, #64cfca 0%, #2bb3b1 50%, #0f6f73 100%)); box-shadow: var(--wd-btn-shadow, 0 8px 18px rgba(8, 63, 66, .16)); font-weight: 700; cursor: pointer; }
.tarot-widget__button:hover:not(:disabled) { background: var(--wd-btn-bg-lapis-hover, linear-gradient(145deg, #7dd9d5 0%, #64cfca 48%, #2bb3b1 100%)); }
.tarot-widget__button:disabled { cursor: not-allowed; opacity: .5; }
.tarot-widget__select:disabled, .tarot-widget__fieldset:disabled { cursor: not-allowed; opacity: .58; }
.tarot-widget__choice input:focus-visible + span, .tarot-widget__select:focus-visible, .tarot-widget__button:focus-visible, .tarot-widget__close:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }
.tarot-widget__result { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--tw-border); }
.tarot-widget__result[hidden] { display: none; }
.tarot-widget__back { min-height: 44px; margin: 0 0 12px; padding: 7px 0; border: 0; color: var(--tw-accent); background: transparent; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.tarot-widget__back[hidden] { display: none; }
.tarot-widget__back:hover { text-decoration: underline; text-underline-offset: 3px; }
.tarot-widget__back:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; border-radius: 2px; }
.tarot-widget__result h3 { margin: 0 0 16px; color: var(--form-heading, #0a4d52); font-size: 1.3rem; }
.tarot-widget__section { margin-top: 18px; }
.tarot-widget__section h4 { margin: 0 0 6px; font-size: .88rem; letter-spacing: .035em; text-transform: uppercase; color: var(--tw-muted); }
.tarot-widget__card-link { margin: 0; padding: 0; border: 0; color: var(--tw-accent); background: transparent; font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; }
.tarot-widget__card-link:hover { text-decoration-thickness: 2px; }
.tarot-widget__card-link:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 3px; border-radius: 2px; }
.tarot-widget__section p { max-width: 68ch; margin: 0; line-height: 1.62; }
.tarot-widget__question { padding: 14px 16px; background: var(--tw-surface-muted); border-left: 3px solid var(--tw-accent); }
.tarot-widget__helper { color: var(--tw-muted); font-size: .9rem; }
.tarot-widget__combination-controls { display: grid; gap: 14px; margin-top: 12px; }
.tarot-widget__combination-controls .tarot-widget__button { width: 100%; }
.tarot-widget__sources { margin: 8px 0 0; padding-left: 20px; color: var(--tw-muted); line-height: 1.5; }
.tarot-widget__sources a { color: var(--tw-accent); text-underline-offset: 3px; }
.tarot-widget__sources a:hover { text-decoration-thickness: 2px; }
.tarot-widget__sources a:focus-visible { outline: 3px solid var(--tw-focus); outline-offset: 2px; }
.tarot-widget__section h5 { margin: 14px 0 0; font-size: .9rem; }
.tarot-widget__note, .tarot-widget__status { color: var(--tw-muted); font-size: .9rem; line-height: 1.5; }
.tarot-widget__status { min-height: 1.5em; margin: 10px 0 0; }
body.tarot-widget-open { overflow: hidden; }

:root:not([data-wd-theme="dark"]) .tarot-widget__choice input:checked + span {
  color: var(--form-heading, #0a4d52);
  background: var(--form-primary-soft, rgba(174, 230, 229, .52));
}

:root:not([data-wd-theme="dark"]) .tarot-widget__close:hover {
  border-color: var(--wd-input-border-focus, rgba(15, 111, 115, .46));
  color: var(--wd-teal-deep, #0f6f73);
  background: rgba(43, 179, 177, .10);
}

:root[data-wd-theme="dark"] .tarot-widget {
  --tw-surface: var(--form-surface, #101c1f);
  --tw-surface-muted: var(--form-surface-muted, #17292b);
  --tw-text: var(--wd-ink, #f3e8c8);
  --tw-muted: var(--wd-muted, rgba(243, 232, 200, .76));
  --tw-border: var(--panel-border, rgba(228, 191, 99, .16));
  --tw-accent: var(--wd-teal-light, #73dad4);
  --tw-focus: rgba(115, 218, 212, .34);
  color-scheme: dark;
}

:root[data-wd-theme="dark"] .tarot-widget__backdrop { background: rgba(5, 8, 10, .76); }

:root[data-wd-theme="dark"] .tarot-widget__dialog {
  background:
    radial-gradient(circle at 88% 8%, rgba(47, 104, 183, .10), transparent 30%),
    linear-gradient(180deg, rgba(22, 33, 34, .99), rgba(11, 18, 21, .98));
  border-color: var(--panel-border, rgba(228, 191, 99, .16));
  box-shadow: var(--panel-shadow, 0 18px 46px rgba(0, 0, 0, .34)), inset 0 1px rgba(255, 249, 238, .06);
  scrollbar-color: rgba(201, 168, 91, .55) transparent;
}

:root[data-wd-theme="dark"] .tarot-widget__header { background: rgba(16, 28, 31, .98); }
:root[data-wd-theme="dark"] .tarot-widget__title,
:root[data-wd-theme="dark"] .tarot-widget__result h3 { color: var(--wd-gold-pale, #f1d57e); }

:root[data-wd-theme="dark"] .tarot-widget__choice span,
:root[data-wd-theme="dark"] .tarot-widget__select {
  border-color: var(--wd-input-border, rgba(228, 191, 99, .20));
  background: var(--wd-input-bg, rgba(9, 15, 18, .58));
}

:root[data-wd-theme="dark"] .tarot-widget__choice input:checked + span {
  color: var(--wd-teal-light, #73dad4);
  background: rgba(43, 179, 177, .10);
}

:root[data-wd-theme="dark"] .tarot-widget__button {
  border-color: var(--wd-btn-border-gold, rgba(201, 162, 87, .54));
  color: var(--wd-on-dark, #fff9ee);
  background: var(--wd-btn-bg-lapis, linear-gradient(145deg, #1b8e91 0%, #0f6f73 48%, #082e32 100%));
  box-shadow: var(--wd-btn-shadow, 0 7px 16px rgba(0, 0, 0, .28));
}

:root[data-wd-theme="dark"] .tarot-widget__button:hover:not(:disabled) {
  background: var(--wd-btn-bg-lapis-hover, linear-gradient(145deg, #239da0 0%, #137e83 48%, #0a3b3f 100%));
}

:root[data-wd-theme="dark"] .tarot-widget__close:hover {
  border-color: rgba(115, 218, 212, .44);
  color: var(--wd-teal-light, #73dad4);
  background: rgba(43, 179, 177, .10);
}

@media (max-width: 560px) {
  .tarot-widget { align-items: end; padding: 0; }
  .tarot-widget__dialog { width: 100%; max-height: 92dvh; border-radius: 14px 14px 0 0; }
  .tarot-widget__header { padding: 18px 16px 14px; }
  .tarot-widget__body { padding: 18px 16px 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  .tarot-widget__dialog { animation: tarot-widget-in .2s ease-out; }
  @keyframes tarot-widget-in { from { opacity: 0; transform: translateY(10px); } }
}
