/*
 * The wallet tools (tools.js): the owner bar's status, buttons and
 * in-flight strip on /address/<a>, the steps inside trade.js's dialog
 * (Plan, Fee, Review, Sent), and the Speed up / Cancel card on /tx/<txid>.
 * app.css's tokens only, light, dark and auto; trade.css's dialog and
 * bottom sheet; the strip reuses utxo.css's family marks.
 */

/* ------------------------------------------------------------ owner bar */

/* "Your address · 14 UTXOs · 9 not extracted", then the buttons. */
.trade-addr-hint {
    order: -2;
    flex: 0 1 auto;
}

.tools-status {
    order: -1;
    flex: 1 1 auto;
    color: var(--ink-2);
    font-size: 12.5px;
}

.tools-status::before {
    content: "· ";
}

.tools-inflight {
    order: 10;
    display: grid;
    flex: 1 0 100%;
    gap: 4px;
}

.tools-inflight[hidden] {
    display: none;
}

.tools-inflight-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 4px 10px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--warning) 12%, var(--surface));
    font-size: 12.5px;
}

.tools-inflight-text {
    flex: 1 1 auto;
    font-weight: 600;
}

.tools-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: tools-pulse 1.6s ease-in-out infinite;
}

/* Dropped: nothing is happening, but it can still confirm until voided. */
.tools-inflight-line--dropped {
    background: color-mix(in srgb, var(--serious) 12%, var(--surface));
}

.tools-inflight-line--dropped .tools-dot {
    background: var(--serious);
    animation: none;
}

@keyframes tools-pulse {
    50% {
        opacity: 0.35;
    }
}

/* ------------------------------------------------------------- the menu */

.tools-menu {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tools-menu-item {
    display: grid;
    justify-items: start;
    gap: 2px;
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: 9px 12px;
    text-align: left;
    white-space: normal;
}

.tools-menu-name {
    font-weight: 600;
}

.tools-menu-sub {
    color: var(--ink-2);
    font-size: 12px;
}

/* ------------------------------------------------------------ the steps */

.tools-step {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.tools-field {
    display: grid;
    gap: 4px;
}

.tools-dest {
    font-family: var(--mono);
    font-size: 13px;
}

.tools-dest-check {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    min-height: 1.4em;
    font-size: 12.5px;
}

.tools-good {
    color: var(--good);
}

.tools-warn {
    color: var(--ink-2);
}

.tools-bad {
    color: var(--critical);
}

.tools-choice {
    align-items: flex-start;
}

.tools-check {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.tools-check input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--ink);
}

.tools-targets {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
}

.tools-targets legend {
    margin-bottom: 4px;
    padding: 0;
    font-weight: 600;
}

.tools-outpoints {
    height: auto;
    min-height: 96px;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 12px;
    resize: vertical;
}

.tools-sends {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tools-send {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9.5em auto;
    align-items: center;
    gap: 8px;
}

.tools-send .trade-input:first-child {
    font-family: var(--mono);
    font-size: 12.5px;
}

/* ---- the plan */

.tools-headline {
    color: var(--ink);
    font-weight: 600;
}

.tools-input {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.tools-input > summary {
    cursor: pointer;
    list-style-position: outside;
}

.tools-input > summary .tools-input-head {
    display: inline-flex;
}

.tools-input-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
    font-size: 13px;
}

.tools-tag {
    padding: 1px 7px;
    border-radius: 9999px;
    background: var(--chip);
    color: var(--ink-2);
    font-size: 11.5px;
}

/* The strip (decorative; the table under it is the source of truth). */
.tools-strip {
    display: block;
    width: 100%;
    height: 30px;
    --utxo-top: #8b4fd8;
    --utxo-name: #c2410c;
    --utxo-history: #b7791f;
    --utxo-uncommon: #0ca30c;
    --utxo-black: #52514e;
    --utxo-alpha: #2a78d6;
    --utxo-omega: #0f8f8f;
    --utxo-palindrome: #eb6834;
    --utxo-vintage: #8a6d3b;
    --utxo-other: #898781;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tools-strip {
        --utxo-top: #a77bf0;
        --utxo-name: #f08a4b;
        --utxo-history: #e0a83a;
        --utxo-uncommon: #3cc13c;
        --utxo-black: #c3c2b7;
        --utxo-alpha: #3987e5;
        --utxo-omega: #2bb3b3;
        --utxo-palindrome: #f07c4a;
        --utxo-vintage: #c49a5a;
    }
}

:root[data-theme="dark"] .tools-strip {
    --utxo-top: #a77bf0;
    --utxo-name: #f08a4b;
    --utxo-history: #e0a83a;
    --utxo-uncommon: #3cc13c;
    --utxo-black: #c3c2b7;
    --utxo-alpha: #3987e5;
    --utxo-omega: #2bb3b3;
    --utxo-palindrome: #f07c4a;
    --utxo-vintage: #c49a5a;
}

.tools-strip-lane {
    fill: var(--sunken);
    stroke: var(--grid);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.tools-strip .utxo-mark {
    stroke: none;
}

.tools-strip .tools-mark--kept {
    fill-opacity: 0.45;
}

.tools-seg {
    fill: var(--grid);
}

.tools-seg--rare,
.tools-seg--other {
    fill: var(--series-1);
}

.tools-seg--plain,
.tools-seg--change {
    fill: var(--axis);
}

.tools-seg--fee {
    fill: var(--warning);
}

/* The outputs each strip is cut into. */
.tools-input-outs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    color: var(--ink-2);
    font-size: 12px;
}

.tools-letter-id {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 4px;
    border-radius: 4px;
    background: var(--chip);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.tools-row--rare .tools-letter-id,
.tools-letter-id.tools-letter--rare,
.tools-letter-id.tools-letter--other {
    background: color-mix(in srgb, var(--series-1) 16%, var(--surface));
}

.tools-dest-tag {
    padding: 0 7px;
    border-radius: 9999px;
    background: var(--chip);
    color: var(--ink-2);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.tools-dest-tag--ordinals {
    background: color-mix(in srgb, var(--series-1) 14%, var(--surface));
    color: var(--ink);
}

.tools-dest-tag--external {
    background: color-mix(in srgb, var(--series-2) 18%, var(--surface));
    color: var(--ink);
}

.tools-dest-tag--fee {
    background: color-mix(in srgb, var(--warning) 18%, var(--surface));
    color: var(--ink);
}

.tools-outputs {
    min-width: 0;
}

.tools-table {
    width: 100%;
    font-size: 12.5px;
}

.tools-caption {
    padding-bottom: 4px;
    font-weight: 600;
    text-align: left;
}

.tools-table .addr-chips {
    display: inline-flex;
    margin-right: 6px;
    vertical-align: middle;
}

.tools-table td,
.tools-table th {
    vertical-align: middle;
    white-space: normal;
}

.tools-table td:nth-child(3) {
    white-space: nowrap;
}

.tools-addr {
    color: var(--ink-2);
}

.tools-checks {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.tools-tick {
    color: var(--good);
    font-weight: 700;
}

.tools-skipped-title {
    font-weight: 600;
}

.tools-list {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
}

.tools-warnings {
    display: grid;
    gap: 6px;
}

/* The server's words may name a whole outpoint. */
.tools-step .trade-alert {
    overflow-wrap: anywhere;
}

.tools-adjust {
    padding: 8px 12px;
    border: 1px solid var(--grid);
    border-radius: var(--radius);
}

.tools-adjust[open] {
    padding-bottom: 12px;
}

.tools-adjust > :not(summary) {
    margin-top: 10px;
}

.tools-adjust > summary {
    cursor: pointer;
    font-weight: 600;
}

/* ---- extract: separate each rare sat, or split into chunks */

.tools-split-box {
    display: grid;
    gap: 10px;
}

.tools-split {
    display: grid;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--grid);
    border-radius: var(--radius);
    background: var(--wash);
}

.tools-split-by {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    font-size: 13px;
}

.tools-split-by input[type="radio"] {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--ink);
}

.tools-split-number {
    width: 6.5em;
    font-variant-numeric: tabular-nums;
}

.tools-split-problem:empty,
.tools-plan-status:empty {
    display: none;
}

.tools-split-problem {
    margin: 0;
    font-size: 12.5px;
}

.tools-preview {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.tools-split-line {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tools-plan-fees {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

/* ---- the fee */

.tools-fee-total {
    font-variant-numeric: tabular-nums;
}

.tools-fee-status:empty {
    display: none;
}

.tools-fee-now {
    color: var(--ink);
    font-weight: 600;
}

/* ---- the review */

.tools-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.4fr);
    align-items: start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--grid);
    border-radius: var(--radius);
    background: var(--sunken);
}

.tools-flow-title {
    margin-bottom: 4px;
    color: var(--ink-2);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tools-flow-arrow {
    align-self: center;
    color: var(--muted);
    font-size: 18px;
}

.tools-flow-item {
    display: grid;
    align-items: baseline;
    gap: 0 8px;
    min-width: 0;
}

.tools-flow-in {
    grid-template-columns: max-content minmax(0, 1fr);
}

.tools-flow-in > .trade-small {
    grid-column: 1 / -1;
}

.tools-flow-out {
    grid-template-columns: 2.2em max-content minmax(0, 1fr) max-content;
}

.tools-flow-out .tools-holds {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tools-flow-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.tools-holds {
    min-width: 0;
    color: var(--ink-2);
    overflow-wrap: anywhere;
}

.tools-flow-fee {
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px dashed var(--grid);
}

.tools-leaving {
    display: grid;
    gap: 4px;
    padding: 9px 12px;
    border-left: 3px solid var(--series-2);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--series-2) 9%, var(--surface));
}

.tools-chunked {
    font-size: 14px;
    letter-spacing: 0.02em;
    word-spacing: 0.25em;
    overflow-wrap: anywhere;
}

.tools-sub {
    margin-bottom: -6px;
    font-size: 13.5px;
    font-weight: 650;
}

.tools-delta {
    color: var(--ink-2);
}

.tools-big {
    padding: 9px 12px;
    border: 1px solid var(--control-border);
    border-radius: var(--radius);
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ /tx/<txid> */

.tools-tx {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    margin: 14px 20px 0;
    padding: 10px 14px;
    border: 1px solid var(--grid);
    border-radius: var(--radius);
    background: var(--wash);
    font-size: 13.5px;
}

.tx-tools[hidden] {
    display: none;
}

.tools-tx-actions {
    display: flex;
    gap: 8px;
}

/* --------------------------------------------------------------- phones */

@media (max-width: 719.98px) {
    .tools-status {
        flex-basis: calc(100% - 9em);
    }

    .trade-addr-bar [data-key^="tools-"],
    .trade-cell [data-key^="tools-"],
    .tools-step .btn,
    .tools-tx .btn,
    .trade-dialog [data-key^="tools-"].btn {
        min-height: 44px;
    }

    .tools-flow-out {
        grid-template-columns: 2.2em max-content minmax(0, 1fr);
    }

    .tools-flow-out .tools-dest-tag {
        grid-column: 2 / -1;
        justify-self: start;
    }

    /* The outputs table fits the sheet: words wrap, the chips go (the words say it). */
    .tools-table .addr-chips {
        display: none;
    }

    .tools-table th,
    .tools-table td,
    .tools-table td:nth-child(3) {
        padding-left: 4px;
        padding-right: 4px;
        white-space: normal;
    }

    .tools-table .tools-addr {
        display: block;
    }

    .tools-flow {
        grid-template-columns: minmax(0, 1fr);
    }

    .tools-flow-arrow {
        display: none;
    }

    .tools-send {
        grid-template-columns: minmax(0, 1fr) 8em;
    }

    .tools-send .btn {
        grid-column: 1 / -1;
        justify-self: end;
    }

    .tools-split-by {
        min-height: 44px;
    }

    .tools-split-number {
        min-height: 44px;
    }

    .tools-tx {
        margin: 12px 14px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tools-dot {
        animation: none;
    }
}

@media (forced-colors: active) {
    .tools-strip .utxo-mark {
        fill: CanvasText;
    }

    .tools-seg--rare,
    .tools-seg--other {
        fill: Highlight;
    }

    .tools-seg--plain,
    .tools-seg--change,
    .tools-seg--fee {
        fill: GrayText;
    }

    .tools-dest-tag,
    .tools-letter-id,
    .tools-inflight-line,
    .tools-tx,
    .tools-split {
        border: 1px solid CanvasText;
    }

    .tools-dot {
        background: Highlight;
    }
}
