.web-currency-field {
  --web-currency-font-size: 16px;
  --web-currency-font-weight: 400;
  --web-currency-text-align: right;
  --web-currency-text-color: #1F2937;
  --web-currency-text-color-negative: #D14343;
  --web-currency-border-width: 1px;
  --web-currency-focus-border-color: #A6C9EC;
  --web-currency-focus-border-width: 1px;
  --web-currency-padding-inline: 6px;
  --web-currency-border-color: #A6C9EC;
  --web-currency-bg: #FFFFFF;
  --web-currency-invalid-border-color: #D14343;
  --web-currency-invalid-border-width: 2px;

  display: grid;
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.web-currency-field__input {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 var(--web-currency-padding-inline);
  border: var(--web-currency-border-width) solid var(--web-currency-border-color);
  background: var(--web-currency-bg);
  color: var(--web-currency-text-color);
  font: inherit;
  font-size: var(--web-currency-font-size);
  font-weight: var(--web-currency-font-weight);
  text-align: var(--web-currency-text-align);
  outline: none;
  box-sizing: border-box;
}

.web-currency-field[data-sign="negative"] .web-currency-field__input {
  color: var(--web-currency-text-color-negative);
}

.web-currency-field__input:focus {
  box-shadow: inset 0 0 0 var(--web-currency-focus-border-width) var(--web-currency-focus-border-color);
}

.web-currency-field[data-state="invalid"] .web-currency-field__input {
  border-color: var(--web-currency-invalid-border-color);
  border-width: var(--web-currency-invalid-border-width);
  box-shadow: none;
}

.web-currency-field[data-state="invalid"] .web-currency-field__input:focus {
  border-color: var(--web-currency-invalid-border-color);
  border-width: var(--web-currency-invalid-border-width);
  box-shadow: none;
}

.web-currency-field__action {
  position: absolute;
  top: 4px;
  z-index: 2;
  display: none;
  height: calc(100% - 8px);
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--web-currency-border-color);
  background: transparent;
  color: var(--web-currency-border-color);
  cursor: pointer;
  box-sizing: border-box;
}

.web-currency-field:hover .web-currency-field__action,
.web-currency-field:focus-within .web-currency-field__action {
  display: block;
}

.web-currency-field__action:disabled {
  cursor: default;
  opacity: 0.35;
}

.web-currency-field[data-has-value="false"] .web-currency-field__clear {
  pointer-events: none;
}

.web-currency-field[data-history="empty"] .web-currency-field__restore {
  display: none;
}

.web-currency-field__clear {
  background: linear-gradient(var(--web-currency-border-color), var(--web-currency-border-color)) center 78% / 60% 2px no-repeat;
}

.web-currency-field__clear::before,
.web-currency-field__clear::after,
.web-currency-field__restore::before {
  content: "";
  position: absolute;
  display: block;
}

.web-currency-field__clear::before {
  left: 38%;
  top: 20%;
  width: 34%;
  height: 40%;
  border-radius: 4px 4px 2px 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.web-currency-field__clear::after {
  left: 22%;
  top: 46%;
  width: 32%;
  height: 28%;
  border: 1px solid currentColor;
  border-radius: 3px 2px 2px 3px;
  background: var(--web-currency-bg);
  transform: rotate(45deg);
}

.web-currency-field__restore::before {
  inset: 21%;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.2 7.2V3.5L1.8 8.9l5.4 5.4v-3.8h7.4a4.9 4.9 0 1 1-3.6 8.2l-1.9 1.9A7.6 7.6 0 1 0 14.6 7.2H7.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.web-currency-field--align-left .web-currency-field__clear {
  right: 4px;
}

.web-currency-field--align-left .web-currency-field__restore {
  right: 40px;
}

.web-currency-field--align-right .web-currency-field__restore {
  left: 8px;
  transform: translateX(100%);
}

.web-currency-field--align-right .web-currency-field__clear {
  left: 4px;
}

.web-currency-field--align-center .web-currency-field__restore {
  left: 4px;
}

.web-currency-field--align-center .web-currency-field__clear {
  right: 4px;
}

.web-currency-field--align-left[data-has-value="true"] .web-currency-field__input,
.web-currency-field--align-left[data-history="available"] .web-currency-field__input {
  padding-right: max(var(--web-currency-padding-inline), 74px);
}

.web-currency-field--align-right[data-has-value="true"] .web-currency-field__input,
.web-currency-field--align-right[data-history="available"] .web-currency-field__input {
  padding-left: max(var(--web-currency-padding-inline), 74px);
}

.web-currency-field--align-center[data-has-value="true"] .web-currency-field__input,
.web-currency-field--align-center[data-history="available"] .web-currency-field__input {
  padding-left: var(--web-currency-padding-inline);
  padding-right: var(--web-currency-padding-inline);
}

.web-currency-field__history-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 74px;
  z-index: 10;
  border: 1px solid var(--web-currency-border-color);
  background: var(--web-currency-bg);
  box-shadow: 0 4px 10px rgb(31 41 55 / 14%);
}

.web-currency-field--align-right .web-currency-field__history-list,
.web-currency-field--align-center .web-currency-field__history-list {
  left: 40px;
  right: 0;
}

.web-currency-field--align-left .web-currency-field__history-list {
  left: 0;
  right: 74px;
}

.web-currency-field__history-item {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--web-currency-border-color) 55%, transparent);
  background: transparent;
  color: var(--web-currency-text-color);
  font-size: var(--web-currency-font-size);
  text-align: left;
  cursor: pointer;
}

.web-currency-field__history-item:last-child {
  border-bottom: 0;
}

.web-currency-field__history-item:hover {
  background: color-mix(in srgb, var(--web-currency-border-color) 16%, transparent);
}

/* Action buttons and history list follow WebTextField exactly. */
.web-currency-field__action {
  border-radius: 2px;
  display: block;
  opacity: 0;
  pointer-events: none;
}

.web-currency-field[data-history="empty"] .web-currency-field__restore {
  display: none;
}

.web-currency-field__clear {
  right: 4px;
  left: auto;
  background:
    linear-gradient(var(--web-currency-border-color), var(--web-currency-border-color)) center 78% / 60% 2px no-repeat;
}

.web-currency-field__restore {
  right: 8px;
  left: auto;
  transform: translateX(-100%);
}

.web-currency-field--align-right .web-currency-field__clear {
  right: auto;
  left: 4px;
}

.web-currency-field--align-right .web-currency-field__restore {
  right: auto;
  left: 8px;
  transform: translateX(100%);
}

.web-currency-field--align-center .web-currency-field__restore {
  right: auto;
  left: 4px;
  transform: none;
}

.web-currency-field__restore::before {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: 72%;
  height: 72%;
  background: var(--web-currency-border-color);
  transform: translate(-50%, -50%);
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M25 8 5 25l20 17V30h15a12 12 0 1 1-8.5 20.5L25.8 56A20 20 0 1 0 40 22H25V8Z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M25 8 5 25l20 17V30h15a12 12 0 1 1-8.5 20.5L25.8 56A20 20 0 1 0 40 22H25V8Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.web-currency-field__clear::before {
  left: 56%;
  top: 38%;
  right: auto;
  bottom: auto;
  width: 42%;
  height: 30%;
  border-radius: 3px 3px 1px 1px;
  background: var(--web-currency-border-color);
  transform: translate(-50%, -50%) rotate(45deg);
}

.web-currency-field__clear::after {
  left: 39%;
  top: 57%;
  right: auto;
  bottom: auto;
  width: 42%;
  height: 30%;
  border: 1px solid var(--web-currency-border-color);
  border-radius: 1px 1px 3px 3px;
  background: transparent;
  transform: translate(-50%, -50%) rotate(45deg);
}

.web-currency-field[data-has-value="true"]:hover .web-currency-field__clear,
.web-currency-field[data-has-value="true"]:focus-within .web-currency-field__clear {
  opacity: 1;
  pointer-events: auto;
}

.web-currency-field[data-has-value="false"][data-history="available"]:hover .web-currency-field__clear,
.web-currency-field[data-has-value="false"][data-history="available"]:focus-within .web-currency-field__clear {
  opacity: 0.35;
  pointer-events: none;
}

.web-currency-field[data-history="available"]:hover .web-currency-field__restore,
.web-currency-field[data-history="available"]:focus-within .web-currency-field__restore {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.web-currency-field[data-has-value="true"]:hover .web-currency-field__input,
.web-currency-field[data-has-value="true"]:focus-within .web-currency-field__input,
.web-currency-field[data-history="available"]:hover .web-currency-field__input,
.web-currency-field[data-history="available"]:focus-within .web-currency-field__input {
  padding-right: max(var(--web-currency-padding-inline), 34px);
}

.web-currency-field--align-left[data-history="available"]:hover .web-currency-field__input,
.web-currency-field--align-left[data-history="available"]:focus-within .web-currency-field__input {
  padding-right: max(var(--web-currency-padding-inline), 66px);
}

.web-currency-field--align-right[data-has-value="true"]:hover .web-currency-field__input,
.web-currency-field--align-right[data-has-value="true"]:focus-within .web-currency-field__input,
.web-currency-field--align-right[data-history="available"]:hover .web-currency-field__input,
.web-currency-field--align-right[data-history="available"]:focus-within .web-currency-field__input {
  padding-right: var(--web-currency-padding-inline);
  padding-left: max(var(--web-currency-padding-inline), 66px);
}

.web-currency-field--align-center:hover .web-currency-field__input,
.web-currency-field--align-center:focus-within .web-currency-field__input {
  padding-left: var(--web-currency-padding-inline);
  padding-right: var(--web-currency-padding-inline);
}

.web-currency-field__history-list {
  z-index: 30;
  display: grid;
  gap: 2px;
  padding: 4px;
  right: 74px;
  background: #FFFFFF;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.web-currency-field--align-right .web-currency-field__history-list,
.web-currency-field--align-center .web-currency-field__history-list {
  left: 40px;
  right: 0;
}

.web-currency-field__history-list[hidden] {
  display: none;
}

.web-currency-field__history-item {
  min-width: 0;
  height: 28px;
  min-height: 0;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--web-currency-text-color);
  font: inherit;
  font-size: 13px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.web-currency-field__history-item:hover,
.web-currency-field__history-item:focus {
  outline: none;
  background: #DAE9F8;
  color: #215C98;
}

.web-currency-field__help {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--web-currency-border-color);
  background: #FFFFFF;
  color: var(--web-currency-text-color);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  box-sizing: border-box;
}

.web-currency-field__help[hidden] {
  display: none;
}

.web-currency-field__help-item {
  min-width: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1.25;
  text-align: left;
}
