:root {
  --bg: #0a0a0a;
  --bg-raise: #121212;
  --bg-panel: #161616;
  --ink: rgba(255, 255, 255, 0.84);
  --ink-strong: #f5f5f5;
  --ink-dim: rgba(255, 255, 255, 0.55);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.72);
  --side: 13.75rem;
  --top: 3.6rem;
  --font: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "PingFang TC", "Hiragino Sans GB", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans KR", "Noto Sans Thai", "Noto Sans SC", "Noto Sans TC", "Microsoft YaHei", "Microsoft JhengHei", "Yu Gothic UI", "Yu Gothic", "Malgun Gothic", "Leelawadee UI", "Thonburi", Tahoma, sans-serif;
  --duration: 180ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  color-scheme: dark;
  scroll-padding-top: 72px;
  -webkit-font-smoothing: antialiased;
}

html, body {
  margin: 0;
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  color: var(--ink);
  background: var(--bg);
  font: 17px/1.65 var(--font);
  letter-spacing: 0;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
}

body:not(.is-ready) .shell {
  visibility: hidden;
}

::selection {
  background: #fff;
  color: var(--bg);
}

:focus {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

a {
  color: #fff;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100%;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--top);
  padding: 0.85rem 4vw;
  background: rgba(10, 10, 10, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 28px;
  height: 28px;
  display: block;
}

.topbar nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.15rem 0.2rem;
  margin-left: auto;
  flex-shrink: 0;
}

.topbar nav a,
.topbar .quit {
  color: var(--ink-dim);
  text-decoration: none;
  padding: 0.35em 0.55em;
  font-size: 0.92rem;
  background: none;
  border: 0;
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-weight: 400;
  letter-spacing: 0;
  white-space: nowrap;
  transition: color var(--duration) var(--ease);
}

.topbar nav a:hover,
.topbar .quit:hover {
  color: #fff;
  text-decoration: none;
  background: none;
  filter: none;
}

.topbar nav a[aria-current="page"] {
  color: #fff;
  box-shadow: inset 0 -1px 0 #fff;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: var(--top);
  height: calc(100vh - var(--top));
  overflow: auto;
  background: var(--bg-raise);
  border-right: 1px solid var(--line);
  padding: 1.35rem 0 2rem;
}

.sidebar h2 {
  margin: 0 1.25rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
}

.sidebar a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 0.55rem 1.25rem;
  border: 0;
  font-size: 0.95rem;
  transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  text-decoration: none;
}

.sidebar a.is-on {
  color: #fff;
  background: var(--bg-panel);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100svh - var(--top));
  padding: 2.75rem 3rem 4rem;
}

.page {
  max-width: 42em;
}

.page h1,
.lead,
.hint,
.field-note,
#bot-hint {
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: normal;
}

.page h1 {
  margin: 0 0 0.45rem;
  color: #fff;
  font-size: clamp(1.75rem, 4vw, 2.15rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.lead, .hint {
  color: var(--ink-dim);
  font-size: 1rem;
}

.lead {
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.lead a,
.hint a,
#bot-hint a,
.foot a {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  transition: border-color var(--duration) var(--ease);
}

.lead a:hover,
.hint a:hover,
#bot-hint a:hover,
.foot a:hover {
  border-bottom-color: #fff;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 1.5rem 1.5rem 1.35rem;
  margin: 0 0 1.25rem;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.avatar-face {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-raise);
  object-fit: cover;
  display: block;
}

.profile-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--ink-strong);
  font-weight: 500;
  letter-spacing: -0.015em;
}

.field {
  margin: 0 0 1.05rem;
}

.field label,
form label {
  display: block;
  margin: 0 0 0.4rem;
  color: var(--ink-strong);
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  color: var(--ink-strong);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0.75rem;
  font: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: #fff;
}

input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="email"]:focus-visible,
textarea:focus-visible {
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.readonly {
  margin: 0;
  color: var(--ink);
  word-break: break-all;
}

button,
.button {
  display: inline-block;
  background: #fff;
  color: var(--bg);
  border: 0;
  box-shadow: none;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

button:hover,
.button:hover {
  text-decoration: none;
  filter: none;
  background: #e6e6e6;
  color: var(--bg);
}

button:active,
.button:active {
  background: #d4d4d4;
}

button.secondary,
a.secondary {
  background: transparent;
  color: #fff;
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

button.secondary:hover,
a.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  filter: none;
}

button.secondary:active,
a.secondary:active {
  background: rgba(255, 255, 255, 0.16);
}

button.danger,
a.danger {
  background: #8f2d2d;
  color: #fff;
  border: 0;
  box-shadow: none;
}

button.danger:hover,
a.danger:hover {
  background: #7a2222;
  color: #fff;
  filter: none;
}

button.danger:active,
a.danger:active {
  background: #691c1c;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.message {
  min-height: 0;
  margin: 0;
  color: #e6966e;
}

.message:not(:empty) {
  margin: 0.75rem 0 0;
}

.message.ok {
  color: #9ad1a0;
}

.row {
  margin-top: 1.15rem;
}

.item {
  border-top: 1px solid var(--line);
  padding: 1.15rem 0 1rem;
}

.item:first-child {
  border-top: 0;
  padding-top: 0;
}

.item h2 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink-strong);
  word-break: break-word;
}

.item button {
  margin-top: 0.85rem;
}

.key-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
}

.key-once[hidden],
[hidden] {
  display: none !important;
}

.avatar-fold {
  margin: 0.5rem 0 1rem;
}

.avatar-fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink-dim);
  font-size: 15px;
  list-style: none;
}

.avatar-fold > summary::-webkit-details-marker,
.avatar-fold > summary::marker {
  display: none;
  content: "";
}

.avatar-current-face {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-raise);
  box-shadow: inset 0 0 0 2px #fff;
  object-fit: cover;
}


.avatar-upload {
  display: inline-flex;
  align-items: center;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-strong, #f5f5f5);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.avatar-upload:hover {
  text-decoration: underline;
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  padding: 4px 2px 2px;
  max-height: 220px;
  overflow: auto;
  scroll-margin-top: 72px;
}

.avatar-option {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 3px;
  width: 56px;
  height: 56px;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
}

.avatar-option img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  background: var(--bg-raise);
  object-fit: cover;
  pointer-events: none;
}

.avatar-option:hover {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  filter: none;
}

.avatar-option[aria-selected="true"] {
  border-color: #fff;
  background: transparent;
  box-shadow: none;
}

.avatar-option[aria-selected="true"] img {
  opacity: 1;
  visibility: visible;
}

.field-error {
  margin: 6px 0 0;
  color: #e6966e;
  font-size: 13px;
}

.field-error:empty {
  display: none;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #e6966e;
}

.quiet-link {
  color: var(--ink-dim);
  font-size: 0.95rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  background: none;
  padding: 0;
  font-weight: 400;
  letter-spacing: 0;
  box-shadow: none;
}

.quiet-link:hover {
  color: #fff;
  background: none;
  border-bottom-color: #fff;
  text-decoration: none;
  filter: none;
}

.ticket textarea {
  margin: 8px 0;
}

.account-label {
  margin: 10px 0 0;
}

.button-gap {
  margin-left: 8px;
}

.card > h2 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink-strong);
}

.danger-card {
  margin-top: 1.5rem;
}

.invite-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-row input {
  flex: 1;
  min-width: 0;
}

.invite-row button {
  margin: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.secret-row {
  position: relative;
}

.secret-row input {
  padding-right: 3.4em;
}

.secret-toggle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  margin: 0;
  padding: 0 12px;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

.secret-toggle:hover,
.secret-toggle:active {
  color: #fff;
  background: transparent;
  filter: none;
}

.field-note {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 13px;
}

.empty-note {
  margin: 0 0 16px;
}

#flash:not([hidden]) {
  margin: 0 0 1.25rem;
  padding: 0.95rem 1.1rem;
  background: var(--bg-raise);
  border: 1px solid var(--line);
}

#bot-presence {
  margin: 0 0 1rem;
}

#bot-actions {
  margin: 0 0 1.25rem;
}

input:read-only {
  color: var(--ink);
  background: #101010;
  cursor: default;
}

@media (max-width: 520px) {
  .invite-row button {
    padding-left: 10px;
    padding-right: 10px;
  }
}

footer.foot {
  margin-top: auto;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 15px;
}

footer.foot p {
  margin: 0.35rem 0;
}

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .topbar {
    padding: 0.75rem 5vw;
    gap: 10px;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 5vw;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: var(--bg);
  }

  .sidebar h2 {
    display: none;
  }

  .sidebar a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.7rem 0.75rem;
  }

  .sidebar a.is-on {
    background: transparent;
    box-shadow: inset 0 -1px 0 #fff;
  }

  .main {
    padding: 1.75rem 5vw 3rem;
  }
}

.device-status {
  font-weight: 500;
}

.device-status.is-online {
  color: #9ad1a0;
}

.device-status.is-offline {
  color: var(--ink-dim);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.55em;
  margin: 0 0 16px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.choice input {
  position: static;
  flex: none;
  width: 1em;
  height: 1em;
  margin: 0.2em 0 0;
  accent-color: #fff;
}

.choice span {
  white-space: normal;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
