:root {
  --page-background: none;
  --page-overlay: rgba(255, 255, 255, 0.08);
  --surface: rgba(255, 255, 255, 0.08);
  --surface-input: rgba(255, 255, 255, 0.86);
  --surface-hover: rgba(255, 255, 255, 0.18);
  --line: rgba(255, 255, 255, 0.58);
  --line-soft: rgba(255, 255, 255, 0.28);
  --text: #182026;
  --muted: rgba(24, 32, 38, 0.68);
  --muted-strong: rgba(20, 22, 24, 0.62);
  --ink: #151719;
  --button: #f4f4f5;
  --button-text: #101114;
  --danger: #9f1d1d;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background-color: #e6e2d9;
  background-image: linear-gradient(var(--page-overlay), var(--page-overlay)), var(--page-background);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body,
button,
input,
textarea {
  font: inherit;
}

button,
input {
  appearance: none;
}

button {
  cursor: pointer;
}

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

img,
svg {
  display: block;
}

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

.hidden {
  display: none !important;
}

.login-container {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.card,
.modal-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--surface);
  border: 1px solid var(--line);
}

.card,
.modal-card {
  border-radius: 24px;
}

.welcome-quote-card {
  margin-top: 32px;
  width: 100%;
  max-width: 560px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.sidebar,
.chat-sidebar,
.chat-content {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

[data-liquid-glass] {
  border: 0;
  border-radius: 60px;
}

.card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
}

.quote-card {
  max-width: 560px;
  text-align: center;
}

.quote-title {
  margin-bottom: 12px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.quote-text {
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  font-size: 1.45rem;
  line-height: 1.5;
}

.quote-btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn,
.btn-icon,
.btn-send,
.close-btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

.btn {
  border: 1px solid var(--line);
  background: var(--button);
  color: var(--button-text);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
}

.btn:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

.form-input,
.search-input,
.chat-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--surface-input);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
}

.form-input:focus,
.search-input:focus,
.chat-input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.18);
  outline-offset: 1px;
  border-color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.94);
}

.form-input::placeholder,
.search-input::placeholder,
.chat-input::placeholder {
  color: var(--muted-strong);
}

.login-title {
  margin-bottom: 8px;
  font-size: 1.9rem;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
}

.login-subtitle {
  margin-bottom: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.modal-note {
  text-align: left;
  margin-bottom: 20px;
}

.login-btn {
  width: 100%;
  margin-top: 4px;
}

.error-message {
  min-height: 1.25rem;
  margin-top: 10px;
  color: var(--danger);
  font-size: 0.88rem;
  text-align: center;
}

.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  min-width: 0;
  gap: 8px;
  padding: 8px;
}

.sidebar {
  flex: 0 0 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 24px;
}

.logo-container {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-item {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-item.active {
  border-color: var(--line);
}

.profile-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.avatar-circle,
.chat-item-avatar,
.chat-header-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.16);
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.chat-sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.chat-sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chat-sidebar-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--surface-hover);
}

.search-bar {
  display: block;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.chat-list::-webkit-scrollbar,
.message-area::-webkit-scrollbar,
.student-select-list::-webkit-scrollbar {
  width: 4px;
}

.chat-list::-webkit-scrollbar-thumb,
.message-area::-webkit-scrollbar-thumb,
.student-select-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.42);
  border-radius: 999px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.chat-item.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--line);
}

.chat-item-info {
  min-width: 0;
  flex: 1;
}

.chat-item-name-row,
.chat-item-message-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-item-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-item-message {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.24);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}

.chat-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-content-placeholder {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.welcome-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.welcome-title {
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 10px;
}

.welcome-subtitle {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.6;
}

.chat-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-subtitle,
.message-sender,
.message-time {
  color: var(--muted);
}

.message-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-group {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.message-group.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.message-group.other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-sender {
  margin: 0 0 4px 12px;
  font-size: 0.78rem;
}

.message-bubble-wrapper {
  position: relative;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
  line-height: 1.5;
  word-break: break-word;
}

.mine .message-bubble {
  background: rgba(255, 255, 255, 0.28);
}

.other .message-bubble {
  background: rgba(255, 255, 255, 0.18);
}

.like-badge {
  position: absolute;
  right: 12px;
  bottom: -10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.like-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.like-icon-svg {
  width: 12px;
  height: 12px;
  fill: var(--text);
  opacity: 0.85;
}

.message-time {
  margin-top: 6px;
  font-size: 0.72rem;
}

.mine .message-time {
  margin-right: 4px;
}

.other .message-time {
  margin-left: 4px;
}

.chat-input-area {
  padding: 18px 24px 24px;
  border-top: 1px solid var(--line-soft);
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-input-wrapper {
  flex: 1;
  min-width: 0;
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--button);
  color: var(--button-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(100%, 480px);
  padding: 28px;
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text);
}

.modal-body {
  margin-bottom: 20px;
}

.student-select-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
}

.student-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.student-select-item:hover {
  background: rgba(255, 255, 255, 0.16);
}

.student-select-item.selected {
  background: rgba(255, 255, 255, 0.22);
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.student-select-item.selected .checkbox-custom {
  background: rgba(255, 255, 255, 0.28);
}

.checkbox-icon {
  width: 10px;
  height: 10px;
  fill: var(--text);
  display: none;
}

.student-select-item.selected .checkbox-icon {
  display: block;
}

.student-select-name {
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120%);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  z-index: 2000;
  pointer-events: none;
  transition: transform 0.15s ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    height: 72px;
    padding: 0 16px;
    flex-direction: row;
  }

  .nav-menu {
    flex-direction: row;
    gap: 12px;
  }

  .profile-container {
    flex-direction: row;
  }

  .chat-sidebar {
    flex: 0 0 280px;
    width: 100%;
  }

  .chat-content {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .login-container {
    padding: 16px;
  }

  .card,
  .modal-card {
    padding: 24px;
    border-radius: 20px;
  }

  .quote-card {
    max-width: 100%;
  }

  .quote-text {
    font-size: 1.2rem;
  }

  .quote-btn-group {
    width: 100%;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .chat-sidebar {
    flex-basis: 240px;
  }

  .chat-sidebar-header,
  .chat-header,
  .chat-input-area,
  .message-area,
  .welcome-screen {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-input-area {
    padding-bottom: 16px;
  }

  .message-group {
    max-width: 86%;
  }

  .welcome-screen {
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .welcome-title {
    font-size: 1.6rem;
  }

  .message-area {
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    height: 64px;
  }

  .chat-sidebar {
    flex-basis: 220px;
  }

  .chat-input-form {
    gap: 10px;
  }

  .chat-header {
    gap: 12px;
  }

  .message-group {
    max-width: 92%;
  }
}
