:root {
  --bg: #101014;
  --bg2: #17171d;
  --card: #1b1b22;
  --card2: #24242d;
  --line: #33333e;
  --text: #faf8f9;
  --muted: #b0aeb8;
  --accent: #cb2337;
  --accent-ink: #ffffff;
  --ok: #22c55e;
  --warn: #eab308;
  --err: #ef4444;
  --info: #38bdf8;
  --t: #e0a33a;
  --ct: #5b9bd5;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
body.center { display: grid; place-items: center; padding: 16px; }
a { color: #ff8390; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
code { background: var(--card2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #555460; background: #2e2e39; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ab172c; }
.btn.ghost { background: transparent; }
.btn.danger { color: #fca5a5; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
input[type=text], input[type=number], input[type=search], input[type=password], select {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; font: inherit;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select { margin-top: 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 14px; }
.switch input { width: 38px; height: 22px; appearance: none; background: var(--line); border-radius: 22px; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 19px; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(16,16,20,.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); text-decoration: none; font-size: 17px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; }
.logo::after { content: ""; position: absolute; inset: 7px 6px 6px; background: #fff; clip-path: polygon(0 100%, 0 0, 50% 53%, 100% 0, 100% 100%, 76% 100%, 76% 51%, 50% 79%, 24% 51%, 24% 100%); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user form { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.off::before { background: var(--err); }
.avatar { border-radius: 50%; background: var(--card2); object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; }
.avatar.lg { width: 84px; height: 84px; border-radius: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.narrow { width: min(560px, 100%); }
.alert { padding: 10px 12px; border-radius: 9px; margin: 8px 0; border: 1px solid; }
.alert.success { border-color: #166534; background: #052e16; color: #bbf7d0; }
.alert.error { border-color: #7f1d1d; background: #2a0b0b; color: #fecaca; }
.alert.warn { border-color: #713f12; background: #2a1d05; color: #fde68a; }
.alert.info { border-color: #0c4a6e; background: #062234; color: #bae6fd; }

/* ---------- app ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 18px 16px 120px; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }
.profile { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.profile .who { flex: 1 1 240px; min-width: 0; }
.profile .who h1 { font-size: 22px; margin: 0 0 4px; overflow-wrap: anywhere; }
.profile .ids { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; flex: 2 1 420px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 18px 0 12px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; }
.seg button.active { background: var(--card2); color: var(--text); }
.seg button.t.active { color: var(--t); }
.seg button.ct.active { color: var(--ct); }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; scrollbar-width: thin; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { background: var(--card); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.item {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 10px; cursor: pointer; text-align: left; color: var(--text); font: inherit;
  display: flex; flex-direction: column; gap: 6px; min-width: 0; transition: border-color .15s, background .15s;
}
.item:hover { border-color: #646270; background: #24242e; }
.item.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.item .img { aspect-ratio: 4/3; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2c2b35, #17171e); border-radius: 8px; overflow: hidden; }
.item .img img { width: 100%; height: 100%; object-fit: contain; }
.item .img .ph { color: var(--muted); font-size: 12px; }
.item .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: #000a; border: 1px solid var(--line); }
.badge.st { color: #fb923c; }
.badge.t { color: var(--t); }
.badge.ct { color: var(--ct); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.section-title h2 { font-size: 18px; margin: 0; }
.note { font-size: 13px; color: var(--muted); margin: -4px 0 14px; }

/* ---------- save bar ---------- */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(23,23,29,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.savebar .inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.savebar .state { flex: 1 1 220px; font-size: 14px; color: var(--muted); min-width: 0; }
.savebar .state.dirty { color: var(--warn); }
.apply-status { margin-top: 10px; }

/* ---------- modal ---------- */
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; width: min(980px, 100%); box-shadow: var(--shadow); }
.modal header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.editor { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.editor .preview { background: radial-gradient(circle at 50% 40%, #2c2b35, #121217); border-radius: 12px; aspect-ratio: 4/3; display: grid; place-items: center; overflow: hidden; }
.editor .preview img { width: 100%; height: 100%; object-fit: contain; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 14px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input[type=number] { width: 110px; flex: none; }
.wear-label { font-size: 12px; color: #ff8390; font-weight: 700; }
.paint-grid { max-height: 360px; overflow-y: auto; padding-right: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 14px 0 0; min-width: 0; }
legend { padding: 0 6px; font-weight: 700; font-size: 14px; }
.slot { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px dashed var(--line); }
.slot:first-of-type { border-top: 0; }
.slot .thumb { width: 64px; height: 48px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; cursor: pointer; }
.slot .thumb img { width: 100%; height: 100%; object-fit: contain; }
.slot .mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 6px; margin-top: 6px; }
.slot .mini label { font-size: 11px; }
.slot .mini input { padding: 5px 7px; font-size: 13px; }
.limits { display: grid; gap: 10px; }
.limits li { margin-bottom: 6px; }
.err-text { color: #fca5a5; font-size: 12px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 64px; right: 12px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100vw - 24px)); }
.toast { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); font-size: 14px; animation: slide .2s ease-out; }
.toast.success { border-color: #166534; }
.toast.error { border-color: #7f1d1d; }
.toast.warn { border-color: #713f12; }
@keyframes slide { from { transform: translateY(-6px); opacity: 0; } }

/* ---------- setup ---------- */
.setup form { display: grid; gap: 12px; }
.setup form.row { display: flex; flex-wrap: wrap; gap: 8px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; font-size: 14px; }
.checks li { padding: 4px 0; }
.checks .ok { color: #86efac; }
.checks .bad { color: #fca5a5; }

@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; }
  .editor .preview { max-height: 220px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .hide-sm { display: none; }
  .savebar .btn { flex: 1 1 auto; }
}


/* Shared visual language */
:root { --display: Bahnschrift, "Arial Narrow", "Segoe UI", sans-serif; --shell: 76rem; }
.topbar { min-height: 4.5rem; padding-inline: max(1rem, calc((100% - var(--shell)) / 2)); }
.brand { text-transform: uppercase; letter-spacing: .08em; font-family: var(--display); white-space: nowrap; }
.logo { width: 32px; height: 32px; flex: 0 0 32px; }
.logo::after { inset: 8px 7px; }
.nav-wrap { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.nav-wrap nav { display: flex; flex-wrap: wrap; gap: clamp(1rem, 3vw, 2.5rem); }
.nav-wrap nav a { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 650; }
.nav-wrap nav a:hover { color: var(--text); }
.btn { border-radius: 7px; min-height: 2.75rem; }
.btn.sm { min-height: 2.25rem; }
.eyebrow { color: #ff8390; font-family: var(--display); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; }
.site-footer { max-width: var(--shell); margin: 0 auto; padding: 1.25rem 0 1.5rem; border-top: 1px solid var(--line); display: flex; gap: .5rem 1.25rem; justify-content: space-between; flex-wrap: wrap; color: var(--muted); font-size: .875rem; width: calc(100% - 2rem); }
.site-footer span:first-child { color: var(--text); font-family: var(--display); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

/* Public pages */
.public { display: flex; flex-direction: column; }
.public .site-footer { margin-top: auto; }
.landing { padding-bottom: clamp(2rem, 5vw, 4rem); }
.hero {
  background: linear-gradient(90deg, #100d12 0%, #100d12e8 27%, #100d1233 72%),
    linear-gradient(0deg, #101014 0%, transparent 45%), url("mirathis-hero.webp") center 52% / cover no-repeat, #24151b;
  min-height: clamp(25rem, 45vw, 35rem); display: grid; align-items: center;
  padding: 3.5rem 1rem 5rem;
}
.hero-inner { width: 100%; max-width: var(--shell); margin-inline: auto; }
.hero h1 { font-family: var(--display); font-size: clamp(3.2rem, 10vw, 8.3rem); letter-spacing: -.055em; line-height: .93; margin: .17em 0; font-weight: 850; }
.hero h1 span { color: #ff485b; }
.hero-copy { color: #e2dfe5; max-width: 28rem; font-size: clamp(1rem, 2vw, 1.25rem); margin: 1.35rem 0 1.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.hero .btn.ghost { background: #17171dd9; }
.server-strip, .public-details { max-width: var(--shell); width: calc(100% - 2rem); margin-inline: auto; }
.server-strip { position: relative; margin-top: -2rem; display: grid; grid-template-columns: 1.1fr .7fr 1.35fr; padding: 0; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.server-cell { padding: clamp(.9rem, 2.3vw, 1.5rem); display: grid; align-content: start; justify-items: start; gap: .25rem; min-width: 0; }
.server-cell + .server-cell { border-left: 1px solid var(--line); }
.server-cell strong { font-family: var(--display); font-size: clamp(1.05rem, 2.4vw, 1.65rem); overflow-wrap: anywhere; max-width: 100%; }
.address-cell strong { font-family: ui-monospace, Consolas, monospace; }
.address-cell .btn { margin-top: .2rem; }
#copy-status:empty { display: none; }
#copy-status { color: #84e4aa; }
.public-details { display: grid; grid-template-columns: 1.2fr 1fr .85fr; gap: 1rem; padding-top: clamp(1.25rem, 4vw, 3rem); }
.public-details .card { padding: clamp(1rem, 2.2vw, 1.6rem); border-top: 2px solid #484651; }
.public-details .community { border-top-color: var(--accent); }
.public-details h2 { font-family: var(--display); font-size: 1.25rem; margin: 0 0 .65rem; }
.public-details p, .rules ul { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.rules ul { padding-inline-start: 1.25rem; }
.rules li + li { margin-top: .35rem; }
.public-details article, #sunucu { scroll-margin-top: 7rem; }
.login-wrap {
  min-height: 37rem; flex: 1; display: grid; place-items: center; padding: 3rem 1rem;
  background: linear-gradient(0deg, #101014 1%, #101014b0 62%, #10101477), url("mirathis-hero.webp") center / cover no-repeat, #21161b;
}
.login-card { width: min(100%, 29rem); padding: clamp(1.35rem, 5vw, 2.7rem); background: #17171df5; text-align: center; box-shadow: var(--shadow); border-top: 3px solid var(--accent); }
.login-card h1 { font: 750 clamp(1.65rem, 5vw, 2.2rem)/1.1 var(--display); }
.login-card p { color: var(--muted); }
.login-card .steam { width: 100%; margin-top: .6rem; min-height: 3.15rem; }
.login-card .alert { text-align: left; }
.login-mark { display: inline-grid; width: 3.2rem; height: 3.2rem; place-items: center; margin-bottom: 1rem; background: #321c25; border: 1px solid #6b2d3b; color: #ff9aa6; border-radius: 9px; }
.login-mark svg { width: 1.75rem; height: 1.75rem; }

/* Player workspace */
.app { padding-top: clamp(1rem, 3vw, 2rem); }
.profile { padding: clamp(1rem, 2.2vw, 1.65rem); background: linear-gradient(105deg, #281c25, var(--card) 51%); border-left: 3px solid var(--accent); }
.profile .who h1 { font: 750 clamp(1.4rem, 3vw, 2rem)/1.15 var(--display); }
.avatar-fallback { display: grid; place-items: center; font: 800 2rem var(--display); color: #ff8390; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { min-width: 0; }
.stat span { font-size: .83rem; }
.stat b { overflow-wrap: anywhere; }
.workspace { margin-top: 1.5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.workspace-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; padding: 1rem clamp(.75rem, 3vw, 1.5rem); }
.workspace-head h2 { margin: 0; font: 750 1.6rem var(--display); }
.toolbar { margin: 0; }
.tabs { margin: 0; padding-inline: .6rem; background: #141419; }
.tabs button:hover { color: var(--text); }
#tab { padding: clamp(.8rem, 3vw, 1.5rem); }
.section-title { flex-wrap: wrap; padding: 0; margin-top: 0; }
.section-title h2 { font: 720 1.35rem var(--display); }
.section-title + .note, #tab > .note:first-child { margin-top: 0; }
.catalog-search { width: min(100%, 24rem); font-size: .875rem; }
.result-count { margin: .65rem 0; }
.catalog-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr)); }
.item .img, .item .name, .item .sub { width: 100%; }
.item .name { font-size: .9rem; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
.item .sub { font-size: .8rem; }
.item.selected { border-color: #ff596b; background: #32202a; }
.item.selected::after { content: "✓"; position: absolute; inset: .45rem auto auto .45rem; color: white; background: var(--accent); border-radius: 50%; width: 1.35rem; height: 1.35rem; text-align: center; line-height: 1.35rem; font-weight: 800; }
.item .img img, .editor .preview img { min-height: 0; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 1.5rem 1rem; margin: 0; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: .35rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination button { min-width: 2.25rem; }
.pagination [aria-current] { background: var(--accent); border-color: #ff6374; }
.pagination button:disabled { opacity: .45; }
.extras-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: .75rem; }
.loading { border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.loading::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #ff596b; margin-right: .55rem; }
.modal { padding: 0; margin: auto; color: var(--text); max-width: calc(100% - 1.5rem); max-height: calc(100dvh - 2rem); }
.modal::backdrop { background: #08080bbf; }
.modal header, .modal footer { position: sticky; background: var(--bg2); z-index: 2; }
.modal header { top: 0; }
.modal footer { bottom: 0; }
.picker-grid { margin-top: 1rem; }
.paint-grid { max-height: none; overflow: visible; padding: 0; }
.editor > * { min-width: 0; }
.fields label, .slot .mini label { font-size: .85rem; }
.savebar .btn { flex-shrink: 0; }
@media (max-width: 920px) {
  .public-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-details .community { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .public .nav-wrap { flex-wrap: wrap; gap: .45rem; padding-block: .25rem; }
  .public .nav-wrap nav { order: 3; width: 100%; padding-block: .2rem; gap: 1.2rem; }
  .public .nav-wrap .btn { font-size: .83rem; padding: .4rem .55rem; min-height: 2.4rem; }
  .public .nav-wrap .btn svg { width: 1.05rem; }
  .hero { background-position: 66% center; }
  .hero h1 { font-size: clamp(2.65rem, 11vw, 4.4rem); }
  .server-strip { grid-template-columns: minmax(0, 1fr) minmax(0, .75fr); }
  .server-cell.address-cell { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .public-details { grid-template-columns: minmax(0, 1fr); }
  #server-pill { display: none; }
  .profile { gap: .7rem; }
  .profile .avatar.lg { width: 3rem; height: 3rem; }
  .profile .who { flex-basis: 10rem; }
  .workspace-head .toolbar { gap: .45rem; }
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding-inline: .25rem; }
  .tabs button { padding: .65rem .2rem; font-size: .82rem; }
  .switch .small { font-size: .72rem; }
  .catalog-grid, .grid.small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .savebar .state { flex-basis: 100%; }
  .field-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
