.mp-tool {
  width: min(390px, 100%);
  max-width: none;
  max-height: calc(100dvh - 12px);
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--ui-line);
  border-radius: 18px 18px 0 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  overscroll-behavior: contain;
  font-variant-numeric: tabular-nums;
}

.mp-tool::backdrop { background: var(--ui-overlay); backdrop-filter: none; }
.mp-tool[open] { animation: mp-tool-open 180ms cubic-bezier(.23, 1, .32, 1) both; }
@keyframes mp-tool-open {
  from { transform: translateY(8px); opacity: 0; }
}

.mp-tool-panel { min-width: 0; }
.mp-tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--ui-line);
}

.mp-tool-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.mp-tool-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: transparent;
  color: var(--ui-muted);
  font-size: 24px;
  line-height: 1;
}

.mp-tool .btn {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ui-control-bg);
  color: var(--ui-text);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.4;
}

.mp-tool .btn.primary { background: var(--ui-yellow); color: var(--ui-on-yellow); }
.mp-tool-body, .mp-tool-form { display: grid; gap: 12px; }
.mp-tool-body { padding: 12px 16px max(20px, env(safe-area-inset-bottom)); }
.mp-tool-body > *, .mp-tool-form > * { min-width: 0; }
.mp-tool-row, .mp-tool-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 4px 0;
  border-bottom: 1px solid var(--ui-line);
  font-size: 13px;
}

.mp-tool-row > span, .mp-tool-count > span { color: var(--ui-muted); }
.mp-tool-row strong, .mp-tool-count output { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.mp-tool-step { display: flex; align-items: center; gap: 8px; }
.mp-tool .mp-tool-step .btn { width: 44px; padding: 0; }
.mp-tool-step output { min-width: 24px; text-align: center; }
.mp-tool-field { display: grid; gap: 6px; margin: 0; font-size: 13px; font-weight: 550; }
.mp-tool .mp-tool-field input {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--ui-input-line);
  border-radius: 8px;
  background: var(--ui-input-bg);
  color: var(--ui-text);
  font-size: 16px;
}

.mp-tool .mp-tool-field input.mp-tool-amount {
  min-height: 58px;
  color: var(--ui-strong);
  font-size: 26px;
  font-weight: 650;
}

.mp-tool-presets, .mp-tool-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mp-tool .mp-tool-presets .btn, .mp-tool .mp-tool-controls .btn { padding: 8px 4px; font-size: 12px; overflow-wrap: anywhere; }
.mp-tool .mp-tool-status { margin: 0; color: var(--ui-muted); font-size: 12px; line-height: 1.5; }
.mp-tool .mp-tool-error { color: #ff8293; }
:root[data-theme=light] .mp-tool .mp-tool-error { color: #ab233e; }
.mp-tool .btn.mp-tool-end { background: #a52d45; color: #fff; }
.mp-tool-result, .mp-tool-stage {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  background: var(--ui-surface);
  text-align: center;
  overflow-wrap: anywhere;
}

.mp-tool-result strong { color: var(--ui-strong); font-size: clamp(28px, 8vw, 38px); font-weight: 700; }
.mp-tool-result > span { color: var(--ui-muted); font-size: 13px; }
.mp-tool-result p { margin: 4px 0 0; color: var(--ui-text); }
.mp-tool-section-title { margin: 0; font-size: 13px; font-weight: 650; }
.mp-tool-invites { display: grid; gap: 4px; max-height: 178px; overflow: auto; overscroll-behavior: contain; }
.mp-tool-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--ui-surface);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.mp-tool-invite input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--ui-yellow); }
.mp-tool-stage h3 { margin: 0; font-size: 19px; font-weight: 650; }
.mp-tool-duration { display: grid; gap: 2px; font-size: 12px; color: var(--ui-muted); }
.mp-tool-clock { font-size: 36px; font-weight: 650; line-height: 1.2; color: var(--ui-strong); }
.mp-tool-participants { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mp-tool-participants span { padding: 6px 8px; border-radius: 6px; background: var(--ui-input-bg); font-size: 12px; }
.mp-tool-preview { padding: 8px; border: 1px dashed var(--ui-input-line); border-radius: 6px; }
.mp-tool-stage .mp-tool-preview, .mp-tool-captions p, .mp-tool-archive p { margin: 4px 0 0; color: var(--ui-text); font-size: 13px; line-height: 1.5; }
.mp-tool-captions, .mp-tool-archive {
  padding: 12px;
  border-radius: 8px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
}

.mp-tool-captions { min-height: 92px; }
.mp-tool-captions .mp-tool-original, .mp-tool-archive .mp-tool-original { color: var(--ui-muted); }
.mp-tool-archive summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-size: 13px; }
.mp-tool-archive summary:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.mp-tool-controls { display: flex; flex-wrap: wrap; }
.mp-tool-controls button { flex: 1 1 58px; min-width: 0; border: 1px solid var(--ui-line); }
.mp-tool .mp-tool-controls [aria-pressed=true] { border-color: var(--ui-accent); color: var(--ui-accent); }
.mp-tool-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.mp-tool-summary > div { display: grid; gap: 4px; padding: 10px 6px; text-align: center; border-radius: 8px; background: var(--ui-surface); overflow-wrap: anywhere; }
.mp-tool-summary strong { font-size: 18px; font-weight: 650; }
.mp-tool-summary span, .mp-tool-history small { color: var(--ui-muted); font-size: 12px; }
.mp-tool-history { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 58px; padding: 8px 0; border-bottom: 1px solid var(--ui-line); background: transparent; text-align: left; overflow-wrap: anywhere; }
.mp-tool-history > span { display: grid; gap: 4px; }
.mp-tool-history strong { font-size: 13px; font-weight: 650; }

@media (hover: hover) and (pointer: fine) {
  .mp-tool-close:hover, .mp-tool-history:hover, .mp-tool .btn:not(.primary,.mp-tool-end):hover { background: var(--ui-control-active); }
  .mp-tool .btn.mp-tool-end:hover { background: #8c2339; }
}

@media (min-width: 700px) {
  .mp-tool { margin: auto; max-height: min(780px, calc(100dvh - 32px)); border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .mp-tool[open] { animation: none; }
}
