:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --border: #e5e7ef;
  --text: #1f2430;
  --muted: #7b8194;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden {
  display: none !important;
}

.app {
  height: 100%;
}

/* ---------- 入口页：账号登录 / 本地使用 ---------- */
.gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 28px 18px 40px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(79, 70, 229, 0.16), transparent 70%),
    linear-gradient(180deg, #fafbff 0%, #f2f3fa 100%);
}

.gate-card {
  width: 420px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 50px rgba(31, 36, 48, 0.09);
}

.gate-brand {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: center;
}

.gate-brand span {
  color: var(--primary);
}

.gate-sub {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.gate-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.mode-card:hover {
  border-color: rgba(79, 70, 229, 0.45);
  background: rgba(79, 70, 229, 0.04);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(31, 36, 48, 0.07);
}

.mode-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.mode-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-title {
  font-size: 15px;
  font-weight: 600;
}

.mode-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.gate-tip {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.gate-tip b {
  color: var(--text);
}

.gate-title {
  margin: 0 0 4px;
  font-size: 17px;
}

.gate-foot {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.link-btn {
  align-self: flex-start;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
}

.link-btn:hover {
  background: transparent;
  color: var(--primary);
}

.form-error {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}

button.block {
  width: 100%;
  margin-top: 4px;
  padding: 10px 14px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

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

.mode-badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #f4f5fa;
}

.mode-badge.cloud {
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.24);
  background: rgba(79, 70, 229, 0.08);
}

.mode-badge.local {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.08);
}


.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand span {
  color: var(--primary);
}

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

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
}

.username {
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 通用控件 ---------- */
input,
textarea {
  width: 100%;
  padding: 8px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

textarea {
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  line-height: 1.7;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  background: #eef0f6;
  color: var(--text);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

button:hover {
  background: #e3e6f0;
}

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

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.ghost:hover {
  background: #f1f2f8;
  color: var(--text);
}

.small {
  padding: 5px 10px;
  font-size: 13px;
}

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: calc(100vh - 60px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 12px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.project-item:hover {
  background: #f2f3fa;
}

.project-item.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.project-item .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item .ops {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.project-item:hover .ops {
  opacity: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  padding: 2px 5px;
  font-size: 13px;
  border-radius: 6px;
  color: var(--muted);
  line-height: 1.2;
}

.icon-btn:hover {
  background: #e6e8f2;
  color: var(--text);
}

.icon-btn.danger:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.content {
  padding: 24px 28px;
  overflow-y: auto;
}

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.content-head h2 {
  margin: 0;
  font-size: 20px;
  word-break: break-word;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.search-row input {
  max-width: 420px;
}

/* ---------- 提示词卡片 ---------- */
.prompt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prompt-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt-card:hover {
  border-color: #d3d7e6;
  box-shadow: 0 6px 18px rgba(31, 36, 48, 0.06);
}

.prompt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.prompt-head h3 {
  margin: 0;
  font-size: 15px;
  flex: 1;
  word-break: break-word;
}

.badge {
  flex: none;
  font-size: 12px;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  border-radius: 999px;
  padding: 1px 9px;
}

.prompt-content {
  margin: 0;
  color: #4b5163;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 96px;
  overflow: hidden;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
}

.prompt-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- 空状态 / 弹窗 / 提示 ---------- */
.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
  margin: 0;
}

.empty.big {
  padding-top: 30vh;
}

.local-hint {
  margin: 14px 6px 0;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.6;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
}

.modal {
  border: none;
  border-radius: 14px;
  padding: 22px;
  width: 400px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 60px rgba(20, 24, 40, 0.24);
}

.modal.wide {
  width: 640px;
}

.modal::backdrop {
  background: rgba(20, 24, 40, 0.42);
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 14px);
  padding: 10px 18px;
  border-radius: 8px;
  background: #1f2430;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 80vw;
}

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

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: #16a34a;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 18px;
  }

  .username {
    max-width: 96px;
  }

  .gate-card {
    padding: 22px 18px 20px;
  }
}
