/* AI 面试引擎控制台 · 暗色产品语言 · 单一蓝色强调 · 系统字体(零构建) */
:root {
  --bg: #0e0f13;
  --surface: #16181e;
  --surface-2: #1c1f27;
  --line: #262a33;
  --line-strong: #333845;
  --txt: #e8eaed;
  --txt-dim: #9aa1ad;
  --txt-faint: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 14px / 1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---- 控件 ---- */
button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 10px 18px;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--txt-dim);
  border-color: var(--line-strong);
  padding: 7px 14px;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--txt);
  border-color: var(--txt-faint);
}

label {
  display: block;
  font-size: 12px;
  color: var(--txt-dim);
  margin: 0 0 6px;
}

input,
textarea,
select {
  width: 100%;
  background: var(--bg);
  color: var(--txt);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
}
input::placeholder,
textarea::placeholder {
  color: var(--txt-faint);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.18);
}
select {
  cursor: pointer;
}

/* ---- 居中卡片(登录 / 设置)---- */
.center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.card h1 {
  font-size: 18px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.card .sub {
  color: var(--txt-dim);
  margin: 0 0 22px;
  font-size: 13px;
}
.field {
  margin-bottom: 16px;
}
.err {
  color: #f0716f;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}
.hint {
  color: var(--txt-faint);
  font-size: 12px;
  margin-top: 12px;
}

/* ---- 骨架:常驻左栏 + 主区 ---- */
.shell {
  --sb-w: 280px;
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  height: 100dvh;
}
.shell.collapsed {
  grid-template-columns: 0 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0b0c10;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.shell.collapsed .sidebar {
  border-right: none;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 8px;
}
.sidebar-head .brand {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-new {
  margin: 4px 14px 10px;
  background: var(--surface-2);
  color: var(--txt);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 13px;
  text-align: left;
  font-weight: 600;
}
.btn-new:hover:not(:disabled) {
  border-color: var(--accent);
}
.recent-label {
  padding: 6px 18px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-faint);
}
.hist-list {
  flex: 1;
  overflow: auto;
  padding: 0 10px 10px;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.user-email {
  flex: 1;
  font-size: 12px;
  color: var(--txt-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--txt-dim);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover:not(:disabled) {
  color: var(--txt);
  border-color: var(--line-strong);
}
/* 菜单按钮:仅在折叠态 / 移动端用于唤出侧栏 */
.menu-btn {
  display: none;
}
.shell.collapsed .menu-btn {
  display: inline-flex;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.main-setup {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}
.main-setup .menu-btn {
  position: absolute;
  top: 16px;
  left: 16px;
}
.main-chat {
  display: none;
  flex: 1;
  min-height: 0;
  grid-template-rows: auto 1fr;
}
.main-chat.active {
  display: grid;
}

/* 移动端抽屉遮罩 */
.scrim {
  display: none;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-size: 14px;
  font-weight: 600;
}
.topbar .role {
  color: var(--txt-dim);
  font-size: 13px;
}
.topbar .spacer {
  flex: 1;
}
.topbar .model-pick {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .model-pick label {
  margin: 0;
  white-space: nowrap;
}
.topbar select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 384px;
  min-height: 0;
}
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.msgs {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bubble {
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble .who {
  font-size: 11px;
  color: var(--txt-faint);
  margin-bottom: 4px;
}
.bubble.ai {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.bubble.me .who {
  color: rgb(255 255 255 / 0.7);
}

.composer {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}
.composer textarea {
  height: 56px;
  resize: none;
}
.composer .btn-primary {
  align-self: stretch;
  padding: 0 20px;
}

/* ---- 调试面板 ---- */
.panel {
  overflow: auto;
  padding: 18px;
  background: #0b0c10;
}
.panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-faint);
  margin: 0 0 8px;
  font-weight: 600;
}
.panel section {
  margin-bottom: 18px;
}
.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  font-size: 13px;
}
.kv b {
  color: var(--txt-dim);
  font-weight: 500;
}
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px / 1.55 var(--mono);
  color: #aab4c2;
}

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.chip-CLARIFY {
  background: #16263b;
  color: #7fb0ff;
}
.chip-PROBE {
  background: #2b2410;
  color: #e0b341;
}
.chip-NEXT_DIM {
  background: #12301b;
  color: #5dd47f;
}
.chip-REDIRECT {
  background: #2e2238;
  color: #c79bff;
}
.chip-DOWNSHIFT {
  background: #33240f;
  color: #f0a55a;
}
.chip-END {
  background: #371a20;
  color: #ff8a8f;
}
.muted {
  color: var(--txt-faint);
}

.dim {
  margin-bottom: 10px;
}
.dim:last-child {
  margin-bottom: 0;
}
.dim .top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.dim .name::before {
  content: "○ ";
  color: var(--txt-faint);
}
.dim.covered .name::before {
  content: "● ";
  color: var(--accent);
}
.bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* 侧栏历史列表 */
.hist-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 2px;
  color: var(--txt);
  cursor: pointer;
}
.hist-row:focus-visible {
  outline: none;
  border-color: var(--accent);
}
.hist-row .del {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  background: var(--surface);
  color: var(--txt-faint);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1;
}
.hist-row:hover .del,
.hist-row:focus-within .del {
  display: inline-block;
}
.hist-row .del:hover {
  color: #f0716f;
  border-color: #f0716f;
}
.hist-row:hover {
  background: var(--surface-2);
}
.hist-row.current {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.hist-row .title {
  min-width: 0;
}
.hist-row .title > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-row .meta {
  font-size: 12px;
  color: var(--txt-faint);
  margin-top: 2px;
}
.hist-row .badge {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--txt-faint);
}
.hist-row .badge.live {
  color: #5dd47f;
}
.hist-list .empty {
  display: block;
  padding: 12px 8px;
  color: var(--txt-faint);
  font-size: 13px;
  line-height: 1.7;
}
.readonly-banner {
  align-self: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 12px;
  color: var(--txt-dim);
}

/* 岗位 JD 折叠块 */
.jd-text {
  margin: 0;
  max-height: 7.5em;
  overflow: hidden;
  transition: max-height 0.2s ease;
}
.jd-block.expanded .jd-text {
  max-height: 2000px;
}
.jd-block:not(.expanded).collapsible .jd-text {
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent);
  mask-image: linear-gradient(180deg, #000 60%, transparent);
}
.jd-toggle {
  display: none;
  margin-top: 8px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 12px;
}
.jd-block.collapsible .jd-toggle {
  display: inline-block;
}
.jd-toggle:hover {
  color: var(--accent-hover);
}

/* 面试阶段进度 */
.phases {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.phases .ph {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--txt-faint);
}
.phases .ph.done {
  color: var(--txt-dim);
  border-color: var(--line);
}
.phases .ph.current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.report-dim {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.score {
  font-weight: 700;
}

/* ---- 加载态 ---- */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.3);
  border-top-color: #fff;
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
}
.thinking {
  color: var(--txt-dim);
  font-size: 13px;
  padding: 4px 2px;
}
.thinking .dot {
  animation: blink 1.2s infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes blink {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* 入场动画(克制) */
.bubble {
  animation: rise 0.22s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .panel {
    border-top: 1px solid var(--line);
    max-height: 42vh;
  }
  .chat {
    border-right: none;
  }

  /* 侧栏改为抽屉式:默认收起,菜单按钮唤出 */
  .shell {
    grid-template-columns: 1fr;
  }
  .shell.collapsed {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--line);
  }
  .shell.sidebar-open .sidebar {
    transform: none;
  }
  #collapseBtn {
    display: none;
  }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgb(0 0 0 / 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .shell.sidebar-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
}
