* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
  overflow: hidden;
  background: #f5f7fa;
  user-select: none;
  -webkit-user-select: none;
}
.titlebar {
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  -webkit-app-region: drag;
}
.titlebar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-toggle-btn {
  -webkit-app-region: no-drag;
}
.app-title {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.titlebar-btn-jail {
  -webkit-app-region: no-drag;
  width: 28px;
  height: 28px;
  padding: 0;
}

.titlebar-btn-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}
.titlebar-controls {
  display: flex;
  gap: 8px;
  -webkit-app-region: no-drag;
}
.titlebar-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.titlebar-btn:hover {
  background: rgba(255,255,255,0.2);
}
.titlebar-btn.close:hover {
  background: #e74c3c;
}
.app-container {
  display: flex;
  height: calc(100vh - 32px);
}
.sidebar {
  width: 200px;
  background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
  padding: 20px 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}
.sidebar-backdrop {
  display: none;
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all 0.3s;
  position: relative;
}

.menu-item-button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.menu-footer {
  padding: 14px 14px 12px;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.menu-item-logout {
  color: #fff;
  justify-content: center;
  gap: 8px;
  margin: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, rgba(235, 51, 73, 0.92) 0%, rgba(244, 92, 67, 0.92) 100%);
  box-shadow: 0 10px 22px rgba(235, 51, 73, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.menu-item-logout::before {
  display: none;
}

.menu-item-logout:hover {
  background: linear-gradient(135deg, rgba(235, 51, 73, 1) 0%, rgba(244, 92, 67, 1) 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(235, 51, 73, 0.38);
}

.menu-item-logout:active {
  transform: translateY(0);
  box-shadow: 0 10px 22px rgba(235, 51, 73, 0.28);
}

.menu-item-logout:focus-visible {
  outline: none;
  box-shadow:
    0 14px 28px rgba(235, 51, 73, 0.38),
    0 0 0 3px rgba(244, 92, 67, 0.28);
}

.menu-item-logout .menu-text {
  flex: 0 0 auto;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.menu-logout-icon {
  width: 18px;
  height: 18px;
}
.menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #3498db;
  transform: scaleY(0);
  transition: transform 0.3s;
}
.menu-item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.menu-item.active {
  background: rgba(52,152,219,0.2);
  color: #fff;
}
.menu-item.active::before {
  transform: scaleY(1);
}
.menu-item-hidden {
  display: none;
}
.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.menu-icon-img {
  object-fit: contain;
  opacity: 0.92;
  filter: invert(1) brightness(1.15);
  transition: opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}
.menu-item:hover .menu-icon-img {
  opacity: 1;
  filter: invert(1) brightness(1.25);
}
.menu-item.active .menu-icon-img {
  opacity: 1;
  filter: invert(1) brightness(1.35);
}
.menu-text {
  font-size: 14px;
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
}

.menu-vip {
  margin-left: auto;
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
}

.menu-vip.is-visible {
  display: inline-flex;
}

.menu-vip-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.22));
}

.menu-vip-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.menu-vip-tooltip::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: rgba(17, 24, 39, 0.92);
}

.menu-item:hover .menu-vip-tooltip {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .menu-vip {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }
  .menu-vip-img {
    width: 20px;
    height: 20px;
  }
  .menu-vip-tooltip {
    font-size: 11px;
    padding: 7px 9px;
  }
}
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #f5f7fa;
}

/* Desktop collapsed sidebar (fully hidden) */
body.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  box-shadow: none;
}
body.sidebar-collapsed .menu-item {
  padding: 0;
}
body.sidebar-collapsed .menu-item::before {
  display: none;
}
body.sidebar-collapsed .menu-text {
  display: none;
}

/* Mobile: sidebar becomes a drawer */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }
  .content {
    padding: 12px;
  }
  .page-card {
    padding: 12px;
    border-radius: 10px;
  }
  .page-title {
    font-size: 18px;
    margin-bottom: 10px;
    padding-bottom: 6px;
  }
  .sidebar {
    position: fixed;
    top: 32px;
    left: 0;
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
    width: 220px;
    padding: 16px 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    z-index: 10001;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 32px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 10000;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  /* collapsed state doesn't apply on mobile */
  body.sidebar-collapsed .sidebar {
    width: 220px;
  }
  body.sidebar-collapsed .menu-text {
    display: inline;
  }
  body.sidebar-collapsed .menu-item {
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 20px;
  }

  .menu-footer {
    display: flex;
    justify-content: center;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .menu-item-logout {
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 18px;
  }

  .menu-item-logout .menu-text {
    display: none;
  }
}
.page-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e0e6ed;
}
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #34495e;
  margin-bottom: 8px;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  font-size: 14px;
  color: #2c3e50;
  transition: all 0.3s;
  background: #fff;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}
.form-textarea {
  resize: vertical;
  min-height: 100px;
}
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}
.btn-success {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: #fff;
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(17,153,142,0.4);
}
.btn-danger {
  background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
  color: #fff;
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(235,51,73,0.4);
}
.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.list-item {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  border-left: 4px solid #3498db;
  transition: all 0.3s;
}
.list-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.list-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.list-item-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
}
.list-item-actions {
  display: flex;
  gap: 8px;
}
.list-item-content {
  font-size: 14px;
  color: #7f8c8d;
  line-height: 1.6;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #95a5a6;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.empty-state-text {
  font-size: 16px;
}

.aigame-summary-indicator {
  position: fixed;
  right: 18px;
  /* Avoid covering the game input area (send button sits bottom-right) */
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 10010;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: min(360px, calc(100vw - 36px));
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.aigame-summary-indicator.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.aigame-summary-indicator__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.aigame-summary-indicator__sub {
  font-size: 11px;
  opacity: 0.9;
  margin-top: 2px;
}

@media (max-width: 768px) {
  .aigame-summary-indicator {
    right: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    padding: 10px 12px;
    border-radius: 12px;
    max-width: min(300px, calc(100vw - 28px));
  }
  .aigame-summary-indicator__title {
    font-size: 12px;
  }
  .aigame-summary-indicator__sub {
    font-size: 10px;
  }
}

.aigame-summary-indicator__spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  animation: aigameSummarySpin 0.9s linear infinite;
  flex: 0 0 auto;
}

.aigame-summary-indicator__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

@keyframes aigameSummarySpin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

