:root {
  --bg-0: #0e1a1f;
  --bg-1: #12252e;
  --bg-2: #203743;
  --panel: rgba(10, 18, 24, 0.72);
  --line: rgba(130, 179, 195, 0.24);
  --text: #eaf5f7;
  --muted: #a5bec7;
  --accent: #ffb347;
  --ok: #5ad8a6;
  --danger: #ff7b72;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Manrope", "Microsoft JhengHei", "PingFang TC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(58, 93, 109, 0.36), transparent 48%),
    radial-gradient(circle at 85% 10%, rgba(241, 157, 82, 0.22), transparent 40%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
}

.topbar {
  height: 64px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(10, 18, 24, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(255, 179, 71, 0.7);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.user-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

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

.logout-form {
  margin: 0;
}

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(680px, 95vw);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  padding: 32px;
}

.login-tag {
  display: inline-block;
  border: 1px solid rgba(255, 179, 71, 0.45);
  color: #ffd09a;
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 10px;
  margin-bottom: 16px;
}

.login-title {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  line-height: 1.12;
}

.login-desc {
  margin-top: 14px;
  color: var(--muted);
  max-width: 58ch;
}

.login-btn {
  margin-top: 16px;
}

.chat-layout {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
}

.sidebar-left,
.sidebar-right {
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: rgba(10, 18, 24, 0.53);
  backdrop-filter: blur(8px);
  overflow: auto;
}

.sidebar-left {
  border-left: 0;
}

.sidebar-right {
  border-right: 0;
  padding: 14px;
}

.panel-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-body {
  padding: 10px 12px 16px;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7ea3b1;
  margin-bottom: 8px;
}

.chat-list,
.template-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.chat-list li,
.template-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-list li:hover,
.template-list li:hover {
  border-color: rgba(255, 179, 71, 0.56);
  background: rgba(255, 179, 71, 0.09);
}

.chat-list li.active {
  border-color: rgba(90, 216, 166, 0.66);
  background: rgba(90, 216, 166, 0.11);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.chat-main-header h2 {
  margin: 0;
  font-size: 20px;
}

.chat-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.message-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
}

.msg {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  max-width: 86ch;
}

.msg.role-user {
  margin-left: auto;
  background: rgba(255, 179, 71, 0.1);
  border-color: rgba(255, 179, 71, 0.45);
}

.msg.role-assistant {
  background: rgba(90, 216, 166, 0.09);
  border-color: rgba(90, 216, 166, 0.4);
}

.msg .msg-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}

.msg .msg-content {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.composer-box {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  background: rgba(10, 18, 24, 0.6);
}

#message-input {
  background: rgba(6, 14, 18, 0.8);
  border: 1px solid var(--line);
  color: var(--text);
  resize: vertical;
}

#message-input:focus {
  border-color: rgba(255, 179, 71, 0.7);
  box-shadow: 0 0 0 0.14rem rgba(255, 179, 71, 0.2);
}

.composer-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
}

.sidebar-right label {
  font-size: 12px;
  color: var(--muted);
}

.sidebar-right .form-control {
  background: rgba(6, 14, 18, 0.78);
  border: 1px solid var(--line);
  color: var(--text);
}

.sidebar-right .form-control:focus {
  border-color: rgba(90, 216, 166, 0.7);
  box-shadow: 0 0 0 0.12rem rgba(90, 216, 166, 0.18);
}

.toast-msg {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  min-width: 240px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 18, 24, 0.94);
  padding: 10px 12px;
  font-size: 13px;
}

.toast-msg.ok {
  border-color: rgba(90, 216, 166, 0.7);
}

.toast-msg.error {
  border-color: rgba(255, 123, 114, 0.7);
}

@media (max-width: 1140px) {
  .chat-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .sidebar-right {
    position: fixed;
    top: 64px;
    right: 0;
    width: min(330px, 90vw);
    height: calc(100vh - 64px);
    transform: translateX(100%);
    transition: transform 0.24s ease;
    z-index: 40;
  }

  .sidebar-right.open {
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 8px 10px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 64px);
  }

  .sidebar-left {
    display: none;
  }

  .chat-main-header h2 {
    font-size: 17px;
  }

  .msg {
    max-width: 100%;
  }
}
