:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d9dce3;
  --text: #1d2129;
  --muted: #5d6573;
  --accent: #4752c4;
  --accent-text: #ffffff;
  --sale: #17753f;
  --danger: #b3261e;
  --notice-bg: #fff4d6;
  --notice-text: #5c4300;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --surface: #212328;
    --border: #383b43;
    --text: #eceef2;
    --muted: #a3a9b5;
    --accent: #5865f2;
    --sale: #5fd38d;
    --danger: #ff8a80;
    --notice-bg: #3d3214;
    --notice-text: #f5dc9a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .25rem; }
ul { list-style: none; margin: 0; padding: 0; }
p { margin: 0 0 1rem; }
a { color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  padding: .5rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.account { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }

.button {
  display: inline-block;
  padding: .5rem .9rem;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:disabled { opacity: .6; cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); }
.quiet { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login { max-width: 520px; margin: 12vh auto 0; padding: 0 16px; }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.servers { padding: 1.25rem 16px; border-right: 1px solid var(--border); background: var(--surface); }
.servers h2 { margin-bottom: .75rem; }
.servers #invite { margin-top: 1rem; font-size: .9rem; white-space: normal; text-align: center; display: block; }

.guild-button {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .45rem .5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.guild-button:hover { background: var(--bg); }
.guild-button[aria-current="true"] { background: var(--accent); color: var(--accent-text); }
.guild-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: .85rem;
  font-weight: 700;
}
.guild-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 1.5rem 16px 3rem; max-width: 800px; width: 100%; }
@media (min-width: 900px) { .content { padding-inline: 2rem; } }

.panel {
  margin-bottom: 1.25rem;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
label { display: block; margin-bottom: .3rem; font-weight: 600; font-size: .92rem; }
select, input[type="text"] {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.notice {
  padding: .6rem .8rem;
  border-radius: 6px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: .94rem;
}

.add-game { margin: .75rem 0 1rem; }
.add-row { display: flex; gap: .5rem; }
.search { position: relative; flex: 1; min-width: 0; }
.suggestions {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 4px) 0 auto 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}
.suggestion {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .4rem .6rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.suggestion:hover, .suggestion:focus-visible { background: var(--bg); }
.suggestion img { flex: none; width: 92px; height: 35px; object-fit: cover; border-radius: 3px; }

.watch-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 0;
  border-top: 1px solid var(--border);
}
.watch-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.watch-price { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.watch-price.sale { color: var(--sale); font-weight: 600; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  max-width: 460px;
  margin-left: auto;
  padding: .7rem 1rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
}
.toast.bad { background: var(--danger); color: #ffffff; }
@media (prefers-color-scheme: dark) { .toast.bad { color: #1d0b09; } }

.tabs { display: flex; gap: .25rem; flex: 1; min-width: 0; overflow-x: auto; }
.tab {
  padding: .4rem .7rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab[aria-current="page"] { color: var(--text); background: var(--bg); }

.narrow { max-width: 420px; margin: 10vh auto 0; padding: 0 16px; }
.single { max-width: 800px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.grow { flex: 1; min-width: 0; }
.field-hint { margin: .3rem 0 0; font-size: .88rem; }
.short { max-width: 120px; }
.error { margin: 0; }

input[type="password"], input[type="number"], textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input.short { width: 120px; }
textarea { resize: vertical; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.visually-hidden:focus-visible + *, label:has(+ .visually-hidden:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.profile { display: flex; gap: 1.5rem; align-items: flex-start; }
.avatar-box { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.avatar-box .button { margin: 0; font-size: .9rem; }
.icon-actions { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; text-align: center; }
.notice a { color: inherit; }
.bot-avatar { width: 112px; height: 112px; border-radius: 50%; background: var(--border); object-fit: cover; }

.plain-list { margin-bottom: 1rem; }
.plain-item { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; }
.user-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.user-info .muted { font-size: .9rem; }
.user-list .watch-item:first-child { border-top: 0; }

fieldset { margin: 0; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 6px; }
legend { padding: 0 .3rem; font-weight: 600; font-size: .92rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; margin: .3rem 0; font-weight: 400; }
.check input { flex: none; margin-top: .3rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.danger { margin-left: auto; background: transparent; border-color: var(--danger); color: var(--danger); }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .servers { border-right: 0; border-bottom: 1px solid var(--border); }
  .add-row { flex-direction: column; }
  .account #username { display: none; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; flex-basis: 100%; }
  .profile { flex-direction: column; align-items: stretch; }
}
