/*
MIT License

Copyright (c) 2026 BisChan's Asset Department

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

:root {
  --font-display: 'Manrope', 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --bg: #f6f1ea;
  --bg-2: #fdfaf6;
  --panel: #ffffff;
  --panel-2: #f3ece2;
  --panel-3: #e8dfd2;
  --border: rgba(50, 38, 28, 0.12);
  --text: #1f1b16;
  --muted: #6b6156;
  --accent: #ff7a3d;
  --accent-2: #2cb6a0;
  --accent-3: #f2b94b;
  --accent-soft: rgba(255, 122, 61, 0.18);
  --success: #22c55e;
  --danger: #ef4444;
  --shadow: 0 22px 60px rgba(32, 23, 16, 0.15);
  --shadow-strong: 0 36px 90px rgba(32, 23, 16, 0.22);
  --ring: 0 0 0 4px rgba(255, 122, 61, 0.25);
  --bg-ornament: radial-gradient(circle at 20% 10%, rgba(255, 122, 61, 0.2), transparent 55%),
    radial-gradient(circle at 85% 0%, rgba(44, 182, 160, 0.18), transparent 45%),
    radial-gradient(circle at 10% 85%, rgba(242, 185, 75, 0.22), transparent 55%);
  --bg-grid: linear-gradient(transparent 0 28px, rgba(45, 33, 24, 0.05) 28px 29px),
    linear-gradient(90deg, transparent 0 28px, rgba(45, 33, 24, 0.05) 28px 29px);
  --bg-grid-size: 29px;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --topbar-height: 76px;
  --transition: 180ms ease;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #0e1015;
  --bg-2: #141922;
  --panel: #151a24;
  --panel-2: #1d2430;
  --panel-3: #232c3b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f2f5;
  --muted: #98a3b3;
  --accent: #ff8a55;
  --accent-2: #40d1b7;
  --accent-3: #f6c278;
  --accent-soft: rgba(255, 138, 85, 0.2);
  --success: #34d399;
  --danger: #f87171;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  --shadow-strong: 0 38px 110px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 4px rgba(255, 138, 85, 0.25);
  --bg-ornament: radial-gradient(circle at 20% 12%, rgba(255, 138, 85, 0.2), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(64, 209, 183, 0.2), transparent 45%),
    radial-gradient(circle at 20% 85%, rgba(246, 194, 120, 0.16), transparent 55%);
  --bg-grid: linear-gradient(transparent 0 28px, rgba(255, 255, 255, 0.04) 28px 29px),
    linear-gradient(90deg, transparent 0 28px, rgba(255, 255, 255, 0.04) 28px 29px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-ornament), var(--bg-grid);
  background-size: auto, var(--bg-grid-size) var(--bg-grid-size);
  background-attachment: fixed;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

button, input, textarea {
  font-family: inherit;
}

button {
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #20160f;
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  box-shadow: 0 16px 30px rgba(255, 122, 61, 0.25);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--panel-3);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 60px;
}

#login-view {
  position: relative;
  overflow: hidden;
}

#login-view::before,
#login-view::after {
  content: '';
  position: fixed;
  inset: -20% -10%;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 0, 0, 0.35), transparent 45%),
    radial-gradient(circle at 10% 80%, rgba(168, 0, 255, 0.45), transparent 55%),
    radial-gradient(circle at 90% 10%, rgba(0, 85, 255, 0.5), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(0, 70, 255, 0.4), transparent 55%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}

#login-view::after {
  background:
    radial-gradient(circle at 25% 20%, rgba(0, 0, 0, 0.85), transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(0, 0, 0, 0.85), transparent 55%);
  filter: blur(10px);
  opacity: 0.9;
}

#login-view .auth-shell {
  position: relative;
  z-index: 1;
}

.glass {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.auth-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 28px;
  align-items: stretch;
}

.auth-hero {
  padding: 36px;
  display: grid;
  gap: 18px;
  position: relative;
  overflow: hidden;
  animation: float-in 0.6s ease both;
}

.login-card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 28px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
  animation: float-in 0.6s ease both;
}

.hero-logo {
  display: grid;
  gap: 14px;
  justify-items: start;
}

.hero-logo h1 {
  margin: 0;
  font-size: clamp(2.8rem, 4vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

#login-view .auth-hero {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(0, 0, 0, 0.08);
  color: #1c1620;
  box-shadow: 0 30px 90px rgba(27, 20, 34, 0.22);
}

#login-view .auth-hero .muted {
  color: rgba(34, 24, 42, 0.75);
  font-size: 16px;
}

#login-view .login-card {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 30px 90px rgba(27, 20, 34, 0.22);
}

#login-view .login-card h2 {
  color: #1c1620;
  font-size: clamp(2.2rem, 3.2vw, 3.2rem);
  font-weight: 600;
}

#login-view .field {
  color: rgba(20, 12, 28, 0.7);
}

#login-view .field input {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #1c1620;
  font-size: 16px;
  border-radius: 18px;
  padding: 14px 16px;
}

#login-view .field input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

#login-view .actions button {
  background: linear-gradient(135deg, #ffb86c, #ff7a3d);
  color: #23160f;
  box-shadow: 0 18px 40px rgba(255, 122, 61, 0.35);
  padding: 12px 24px;
  border-radius: 999px;
}

#login-view .link {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1c1620;
  box-shadow: 0 14px 32px rgba(27, 20, 34, 0.2);
}

#login-view .link:hover {
  border-color: rgba(0, 0, 0, 0.22);
  color: #0f0b12;
}

[data-theme='dark'] #login-view::after {
  opacity: 0.9;
}

[data-theme='dark'] #login-view .auth-hero {
  background: rgba(10, 12, 18, 0.72);
  border-color: rgba(255, 255, 255, 0.08);
  color: #f1f1f1;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

[data-theme='dark'] #login-view .auth-hero .muted {
  color: rgba(255, 255, 255, 0.72);
}

[data-theme='dark'] #login-view .login-card {
  background: rgba(14, 18, 28, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

[data-theme='dark'] #login-view .login-card h2 {
  color: #f4f4f4;
}

[data-theme='dark'] #login-view .field {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme='dark'] #login-view .field input {
  background: rgba(180, 180, 180, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #0f1116;
}

[data-theme='dark'] #login-view .link {
  background: rgba(20, 24, 36, 0.85);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f0f0f0;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

[data-theme='dark'] #login-view .link:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.login-card h2 {
  margin: 0;
  font-size: 1.4rem;
}

.logo {
  width: 92px;
  height: 92px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.logo.tiny {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition);
}

.link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.nbfd_header {
  position: fixed;
  top: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}

.nbfd_header:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.theme-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--accent), transparent 70%);
  border: 1px solid var(--border);
}

.top-actions .theme-toggle {
  position: static;
  box-shadow: none;
  background: var(--panel-2);
  padding: 8px 12px;
}

.topbar {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .title {
  font-weight: 700;
}

.brand .subtitle {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.avatar-upload {
  border: 1px dashed var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  transition: border-color var(--transition), color var(--transition);
}

.avatar-upload input {
  display: none;
}

.avatar-upload:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 18px;
  height: calc(100vh - var(--topbar-height));
  padding: 18px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: float-in 0.6s ease both;
}

.chat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  box-shadow: var(--shadow);
  animation: float-in 0.6s ease both;
}

.chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-meta {
  display: grid;
  gap: 4px;
}

.chat-title {
  font-size: 20px;
  font-weight: 700;
}

.messages {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: min(72%, 520px);
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.45;
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.bubble .meta {
  font-size: 12px;
  color: var(--muted);
}

.bubble.me {
  margin-left: auto;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: var(--accent-soft);
}

.bubble.they {
  margin-right: auto;
}

.message-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.message-box input {
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.sidebar .user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  border: 1px solid transparent;
}

.sidebar .user:hover {
  background: var(--panel-2);
}

.sidebar .user.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.typing {
  font-size: 14px;
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  font-size: 13px;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 110px 24px 40px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.hero {
  display: grid;
  gap: 18px;
  padding: 30px;
  animation: float-in 0.6s ease both;
}

.hero h1 {
  font-size: clamp(2rem, 3.2vw, 3.4rem);
  margin: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.hero-grid .chip {
  animation: float-in 0.6s ease both;
}

.hero-grid .chip:nth-child(2) {
  animation-delay: 80ms;
}

.hero-grid .chip:nth-child(3) {
  animation-delay: 160ms;
}

.hero-grid .chip:nth-child(4) {
  animation-delay: 240ms;
}

.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow);
}

.info-card h3 {
  margin: 0 0 8px;
}

.feature-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 24px;
}

.feature-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.admin-shell {
  width: min(900px, 100%);
  padding: 26px;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.admin-user:last-child {
  border-bottom: none;
}

.admin-meta {
  flex: 1;
  display: grid;
  gap: 4px;
}

.admin-actions button {
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.5);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(980px, 100%);
  background: var(--panel);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  padding: 26px;
  display: grid;
  gap: 18px;
  animation: float-in 0.5s ease both;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.settings-card {
  background: var(--panel-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.profile-preview .preview-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--border);
}

.preview-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.preview-meta {
  display: grid;
  gap: 4px;
}

.preview-name {
  font-weight: 700;
  font-size: 16px;
}

.settings-card.danger {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
  background: color-mix(in srgb, var(--danger) 6%, var(--panel-2));
}

.settings-card button {
  justify-self: start;
}

.empty-state {
  text-align: center;
  display: grid;
  gap: 12px;
  padding: 30px 10px;
}

.empty-state h2 {
  margin: 0;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    max-height: 240px;
  }

  .chat {
    min-height: calc(100vh - 360px);
  }
}

@media (max-width: 640px) {
  .theme-toggle {
    top: auto;
    bottom: 16px;
    right: 16px;
  }

  .top-actions .theme-toggle {
    position: static;
  }

  .topbar {
    padding: 16px;
  }

  .message-box {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}