* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; fill: currentColor; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.strong { font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--bg-soft); color: var(--text); font-weight: 600; font-size: 15px;
  transition: background .15s ease, opacity .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  background: linear-gradient(135deg, #5eb5f7, #3390ec);
  color: #fff; font-weight: 600; flex: 0 0 auto; overflow: hidden; user-select: none;
  width: 46px; height: 46px; font-size: 18px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 40px; height: 40px; font-size: 16px; }
.avatar-xs { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 74px; height: 74px; font-size: 28px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }
.avatar[data-color="1"] { background: linear-gradient(135deg, #f6a35c, #e07b39); }
.avatar[data-color="2"] { background: linear-gradient(135deg, #7ed957, #31a24c); }
.avatar[data-color="3"] { background: linear-gradient(135deg, #f28ab2, #d64d8a); }
.avatar[data-color="4"] { background: linear-gradient(135deg, #b69cf5, #7d5cd6); }
.avatar[data-color="5"] { background: linear-gradient(135deg, #65d6c9, #239b8e); }
.avatar[data-color="6"] { background: linear-gradient(135deg, #f0c75e, #c58f1b); }
.avatar[data-color="7"] { background: linear-gradient(135deg, #8fa9c9, #4c6d94); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field small { color: var(--text-tertiary); font-size: 12px; }
input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="number"], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
textarea { resize: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input[type="file"] { font-size: 13px; color: var(--text-secondary); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 28px 16px;
  background:
    radial-gradient(circle at 15% 10%, rgba(51, 144, 236, .18), transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(49, 162, 76, .12), transparent 40%),
    var(--bg-soft);
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 22px; padding: 30px 26px 24px; box-shadow: var(--shadow); text-align: center;
}
.auth-logo {
  width: 76px; height: 76px; border-radius: 24px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #54b3f5, #2b7fd0); color: #fff;
  font-size: 36px; font-weight: 700; box-shadow: 0 8px 20px rgba(51, 144, 236, .3);
}
.auth-logo-error { background: linear-gradient(145deg, #f17676, #d32f2f); font-size: 30px; }
.auth-card h1 { font-size: 25px; margin: 8px 0 6px; letter-spacing: -.02em; }
.auth-card > .muted { margin: 0 0 22px; font-size: 14px; }
.auth-form { text-align: left; margin-top: 6px; }
.auth-note { color: var(--text-tertiary); font-size: 12.5px; margin: 18px 0 0; }
.auth-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; display: block; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 9px 11px; font-size: 13.5px; margin: 0 0 12px; }
.noscript { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 999; }

.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-bottom)); z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(16, 24, 32, .92); color: #fff; padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; animation: toast-in .18s ease; max-width: 90vw;
}
.toast-error { background: rgba(180, 40, 40, .95); }
.toast-success { background: rgba(30, 120, 60, .95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 500; backdrop-filter: blur(2px); }
.modal {
  position: fixed; z-index: 501; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px)); max-height: min(82dvh, 760px);
  background: var(--bg-elevated); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-footer:empty { display: none; }
.modal-footer .btn { flex: 1; }

.connection-banner {
  position: fixed; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: #b26a00; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 13px;
  z-index: 900; box-shadow: var(--shadow); max-width: calc(100vw - 24px); text-align: center;
}

@media (max-width: 700px) {
  .auth-card { padding: 26px 20px 20px; border: 0; box-shadow: none; background: transparent; max-width: 440px; }
  .auth-page { align-items: flex-start; padding-top: 40px; background: var(--bg); }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 90dvh; border-radius: 18px 18px 0 0; }
  .modal-footer { padding-bottom: calc(16px + var(--safe-bottom)); }
}

.modal-footer-inner { display: flex; gap: 10px; width: 100%; }
.modal-footer-inner .btn { flex: 1; }

.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 0 14px; text-align: center; }
.profile-head h3 { margin: 2px 0 0; font-size: 18px; }
.profile-head p { margin: 0; }
.profile-sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0 8px; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 4px 0 14px; font-size: 14px; color: var(--text); }
.section-title { font-size: 15px; margin: 18px 0 6px; }
.search-results { max-height: 320px; overflow-y: auto; margin-top: 6px; }
.catalog-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.catalog-row:last-child { border-bottom: 0; }
.catalog-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.catalog-meta strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-meta small { font-size: 12px; color: var(--text-secondary); }
.member-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.hidden-file { display: none; }
