.tool { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 26rem) minmax(0, 1fr); padding-bottom: 4rem; align-items: start; }
@media (max-width: 52rem) { .tool { grid-template-columns: 1fr; } }
[hidden] { display: none !important; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; }
.form { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; position: relative; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.label { font-weight: 600; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; min-height: 1.2em; }
.row { display: flex; gap: .6rem; align-items: center; }
.row input[type="text"] { flex: 1; min-width: 0; }
.checks { display: flex; flex-direction: column; gap: .5rem; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--muted); white-space: nowrap; }
.check input { accent-color: var(--accent); }

.form input[type="text"], .form select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.form input:disabled { opacity: .6; }

.divider { display: flex; align-items: center; gap: .75rem; margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.status { margin: 0; min-height: 1.4em; color: var(--muted); font-size: .95rem; }
.status.error { color: #d6455d; }

.results { list-style: none; margin: 0; padding: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; max-height: 18rem; overflow-y: auto; }
.results li { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border-radius: 8px; cursor: pointer; }
.results li:hover, .results li:focus { background: var(--glow); outline: none; }
.results img { width: 4.6rem; height: auto; border-radius: 4px; flex: none; }
.results .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { font: inherit; font-weight: 600; cursor: pointer; padding: .55rem 1.1rem; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.btn:hover { border-color: var(--accent); color: var(--ink); }
.btn.small { padding: .35rem .8rem; font-size: .9rem; border-radius: 10px; align-self: flex-start; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.settings summary { cursor: pointer; font-weight: 600; }
.settings[open] { display: flex; flex-direction: column; gap: .75rem; }

.preview { min-height: 24rem; display: flex; flex-direction: column; padding: 1rem; background: #dcdde3; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; }
.preview .btn:not(.primary) { background: #fff; color: #5d5a68; }
.stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem 0; overflow-x: auto; }
.preview .hint { text-align: center; color: #6b6975; }
#canvas { display: block; max-width: 100%; height: auto; }

/* ---- bulk + mode ---- */
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { flex: 1; font: inherit; font-weight: 600; padding: .55rem .5rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.form textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; resize: vertical; }
.form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.hint code { color: var(--ink); }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.testout { margin: 0; padding: .7rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: .8rem; line-height: 1.5; white-space: pre-wrap; color: var(--ink); }
.worker summary { cursor: pointer; font-weight: 600; }
.worker ol { margin: .6rem 0; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; display: grid; gap: .3rem; }
.worker code { color: var(--ink); }
.worker pre { margin: .5rem 0 0; padding: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; font-size: .75rem; line-height: 1.45; color: var(--ink); }

.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: .75rem; }
.bcard { display: flex; flex-direction: column; gap: .45rem; min-width: 0; background: #fff; border-radius: 12px; padding: .75rem; }
.bthumb { display: flex; align-items: center; justify-content: center; min-height: 4.5rem; border-radius: 8px; background: #eceef2; color: #6b6975; font-size: .85rem; text-align: center; overflow: hidden; }
.bthumb canvas { display: block; max-width: 100%; height: auto; }
.bcard input { width: 100%; font: inherit; font-size: .85rem; color: #1c1b29; background: #f6f6f9; border: 1px solid #dcdde3; border-radius: 8px; padding: .3rem .5rem; }
.bcard .prices { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.bmsg { font-size: .8rem; color: #6b6975; min-height: 1.1em; }
.bmsg.fail { color: #d6455d; }
.bmsg.ok { color: #2f8f58; }
.bcard .btn.small { padding: .2rem .6rem; font-size: .8rem; align-self: flex-start; }
