:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel-2: #313338;
  --line: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --accent: #5865f2;
  --accent-2: #4752c4;
  --green: #23a55a;
  --yellow: #f0b232;
  --red: #da373c;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
a { color: #8ea1ff; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: #111214; border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; gap: 8px; align-items: center; }
.brand-mark { color: var(--accent); font-size: 1.3rem; }
.userbox { display: flex; align-items: center; gap: 8px; min-width: 0; }
.userbox img { width: 28px; height: 28px; border-radius: 50%; }
.userbox .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

.view { max-width: 860px; margin: 0 auto; padding: 16px 16px 96px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile { text-align: left; cursor: pointer; width: 100%; color: var(--text); font: inherit; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile .icon { font-size: 1.6rem; }
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.tile[disabled] { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }

.btn {
  appearance: none; border: 0; border-radius: 8px; padding: 10px 16px; min-height: 44px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.steps { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; overflow-x: auto; }
.steps li { flex: 1 0 auto; text-align: center; font-size: .8rem; color: var(--muted); padding: 6px 8px; border-bottom: 3px solid var(--line); white-space: nowrap; }
.steps li.done { color: var(--text); border-color: var(--green); }
.steps li.active { color: var(--text); border-color: var(--accent); font-weight: 700; }

.guild { display: flex; align-items: center; gap: 12px; }
.guild-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.guild-icon img { width: 100%; height: 100%; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.badge.create { background: rgba(35,165,90,.18); color: #57d38c; }
.badge.update { background: rgba(240,178,50,.18); color: var(--yellow); }
.badge.keep { background: var(--panel-2); color: var(--muted); }
.badge.skip { background: rgba(218,55,60,.15); color: #ff7b7e; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check + .check { margin-top: 8px; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check .desc { color: var(--muted); font-size: .875rem; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.summary div { background: var(--panel-2); border-radius: 10px; padding: 10px; text-align: center; }
.summary b { display: block; font-size: 1.4rem; }

.alert { border-radius: 10px; padding: 12px; margin-bottom: 12px; border: 1px solid; }
.alert.error { border-color: var(--red); background: rgba(218,55,60,.1); }
.alert.warn { border-color: var(--yellow); background: rgba(240,178,50,.08); }
.alert.ok { border-color: var(--green); background: rgba(35,165,90,.1); }
.alert ul { margin: .25rem 0 0; padding-left: 1.2rem; }

details.group { background: var(--panel-2); border-radius: 10px; margin-bottom: 8px; }
details.group summary { padding: 12px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.group summary::-webkit-details-marker { display: none; }
.item { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: flex-start; }
.item .what { min-width: 0; overflow-wrap: anywhere; }
.item .note { color: var(--muted); font-size: .8rem; }

.progress { height: 12px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.log { max-height: 50vh; overflow: auto; font-size: .875rem; background: #111214; border-radius: 10px; padding: 8px; margin-top: 12px; }
.log div { padding: 3px 4px; border-bottom: 1px solid #1f2024; overflow-wrap: anywhere; }
.log .error { color: #ff7b7e; }
.log .warn { color: var(--yellow); }

textarea, input[type=text] {
  width: 100%; background: #111214; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font: .9rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
textarea { min-height: 160px; }

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  background: #111214; border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.footer-bar .inner { max-width: 860px; margin: 0 auto; display: flex; justify-content: space-between; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 20; background: #111214; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); }
.toast.error { border-color: var(--red); }

.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); max-width: min(480px, calc(100vw - 32px)); padding: 20px; }
.dialog::backdrop { background: rgba(0,0,0,.6); }

@media (max-width: 520px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 1.3rem; }
}
