/* ═══════════════════════════════════════════
   AI科研生存模拟器 - 假教务系统风格
   ═══════════════════════════════════════════ */

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

:root {
  --bg: #f0f2f5;
  --white: #ffffff;
  --sidebar-bg: #1e3a5f;
  --sidebar-text: #c8d6e5;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.6; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
h1,h2,h3,h4 { line-height: 1.3; }
.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ═══ Browser Chrome (fake) ═══ */
.browser-chrome {
  background: #e8ecf0;
  border-bottom: 1px solid var(--border-dark);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.chrome-dots { display: flex; gap: 6px; }
.chrome-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ccc;
}
.chrome-dots span:first-child { background: #ff5f57; }
.chrome-dots span:nth-child(2) { background: #ffbd2e; }
.chrome-dots span:nth-child(3) { background: #28c840; }
.chrome-url {
  flex: 1;
  background: var(--white);
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
}

/* ═══ BUTTONS ═══ */
.btn-submit {
  background: var(--primary);
  color: white;
  padding: 10px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  transition: all .2s;
}
.btn-submit:hover:not(:disabled) { background: var(--primary-dark); }
.btn-submit:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: all .2s;
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-link {
  color: var(--primary);
  font-size: .85rem;
  text-decoration: underline;
  padding: 4px 0;
}
.btn-danger-link { color: var(--danger); }

.btn-action {
  display: flex; align-items: center; gap: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  width: 100%;
  text-align: left;
  transition: all .15s;
}
.btn-action:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }
.btn-action .action-icon { font-size: 1.1rem; }
.btn-action .action-label { font-weight: 500; }
.btn-action .action-cost { margin-left: auto; font-size: .75rem; color: var(--text-muted); font-family: var(--font-mono); }

.btn-choice {
  display: block; width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
  text-align: left;
  transition: all .15s;
  margin-bottom: 8px;
}
.btn-choice:hover { border-color: var(--primary); background: #f8faff; }
.btn-choice .choice-title { font-weight: 600; display: block; margin-bottom: 2px; }
.btn-choice .choice-desc { font-size: .8rem; color: var(--text-secondary); }

/* ═══ START SCREEN (Portal) ═══ */
.portal-layout {
  display: flex;
  min-height: calc(100vh - 42px);
}
.portal-sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.portal-logo { font-size: 3rem; margin-bottom: .5rem; }
.portal-brand { font-size: 1.3rem; font-weight: 700; color: white; margin-bottom: .5rem; }
.portal-brand small { font-size: .75rem; font-weight: 400; color: var(--sidebar-text); display: block; margin-top: .25rem; }
.portal-copy { font-size: .75rem; opacity: .6; margin-bottom: auto; }
.portal-fine { font-size: .65rem; opacity: .4; margin-top: 2rem; }

.portal-main {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 800px;
}
.portal-title { font-size: 1.5rem; margin-bottom: .25rem; }
.portal-sub { color: var(--text-secondary); margin-bottom: 2rem; }

.form-section { margin-bottom: 2rem; }
.form-label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .5rem; color: var(--text-secondary); }
.form-hint { font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; }
.form-fine { font-size: .75rem; color: var(--text-muted); margin-top: .5rem; }
.form-actions { padding-top: 1rem; border-top: 1px solid var(--border); }

.identity-row {
  display: flex; align-items: center; gap: .75rem;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.identity-name { font-size: 1.1rem; font-weight: 600; }
.identity-title { font-size: .85rem; color: var(--text-muted); }

.direction-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
.direction-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.direction-card:hover { border-color: var(--primary); }
.direction-card.selected { border-color: var(--primary); background: var(--primary-light); }
.direction-card .dir-icon { font-size: 1.8rem; margin-bottom: .3rem; }
.direction-card .dir-name { font-weight: 600; font-size: .9rem; }
.direction-card .dir-desc { font-size: .75rem; color: var(--text-secondary); margin-top: .25rem; }

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
.strategy-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all .2s;
}
.strategy-card:hover { border-color: var(--primary); }
.strategy-card.selected { border-color: var(--primary); background: var(--primary-light); }
.strategy-card .strat-name { font-weight: 600; font-size: .95rem; margin-bottom: .25rem; }
.strategy-card .strat-desc { font-size: .8rem; color: var(--text-secondary); line-height: 1.5; }
.strategy-card .strat-passive { font-size: .78rem; color: var(--success); margin-top: .5rem; font-family: var(--font-mono); }

.save-row { display: flex; gap: 1rem; margin-top: 1rem; }
.meta-line { font-size: .8rem; color: var(--text-muted); margin-top: 1rem; }

/* ═══ GAME LAYOUT ═══ */
.game-layout {
  display: flex;
  min-height: calc(100vh - 42px);
}

/* Profile Sidebar */
.profile-sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 42px);
  position: sticky;
  top: 42px;
}
.profile-avatar { font-size: 3rem; text-align: center; margin-bottom: .5rem; }
.profile-name { font-size: 1rem; text-align: center; margin-bottom: .15rem; }
.profile-meta { font-size: .8rem; color: var(--text-secondary); text-align: center; margin-bottom: .25rem; }

.stat-section { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.stat-title { font-size: .75rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .05em; margin-bottom: .5rem; }

.stat-bar-group { display: flex; flex-direction: column; gap: .5rem; }
.stat-row { }
.stat-row-label { display: flex; justify-content: space-between; font-size: .78rem; margin-bottom: .15rem; }
.stat-row-label span:first-child { color: var(--text-secondary); }
.stat-row-label span:last-child { font-family: var(--font-mono); font-weight: 600; }
.stat-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.fill-blue { background: var(--primary); }
.fill-green { background: var(--success); }
.fill-red { background: var(--danger); }
.fill-yellow { background: var(--warning); }
.fill-purple { background: var(--purple); }
.stat-row.danger .stat-row-label { color: var(--danger); }

.action-buttons { display: flex; flex-direction: column; gap: .4rem; }
.achievement-row { font-size: .82rem; color: var(--text-secondary); }

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-left h1 { font-size: 1.1rem; }
.top-meta { font-size: .82rem; color: var(--text-secondary); }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.quarter-badge {
  font-family: var(--font-mono);
  font-size: .82rem;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Tab Nav */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 20px;
}
.tab-btn {
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all .15s;
  position: relative;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-badge {
  font-size: .7rem;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-family: var(--font-mono);
}

/* Tab Panels */
.tab-content { flex: 1; padding: 20px; overflow-y: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Home Grid */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.home-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.home-card h3 { font-size: .95rem; margin-bottom: .5rem; }
.home-card h4 { font-size: .82rem; color: var(--text-secondary); margin: .75rem 0 .4rem; }
.home-card p { font-size: .85rem; color: var(--text-secondary); line-height: 1.6; }

.event-card { border-left: 3px solid var(--warning); grid-column: 1 / -1; }
.event-card h3 { color: var(--warning); }
.event-choices { margin-top: .75rem; }

.season-card { border-left: 3px solid var(--primary); }
.season-actions { margin-top: .75rem; display: flex; flex-direction: column; gap: .4rem; }

.ops-alert {
  background: linear-gradient(135deg, #f8fafc, #eef4ff);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: .75rem 0;
}
.ops-alert h4 { margin-top: 0; }
.ops-alert p { color: var(--text); font-weight: 500; }

.goal-list { display: flex; flex-direction: column; gap: .6rem; }
.goal-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.goal-item.done {
  background: var(--success-light);
  border-color: #86efac;
}
.goal-main { display: flex; gap: .5rem; align-items: center; }
.goal-state {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.goal-item.done .goal-state { color: var(--success); }
.goal-text { font-size: .82rem; color: var(--text); font-weight: 600; }
.goal-reward { margin-top: .25rem; font-size: .75rem; color: var(--text-secondary); }

.project-card h4 { font-size: .9rem; color: var(--text); margin-top: .85rem; }
.project-stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.project-stage {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.project-stage.ready {
  border-color: #93c5fd;
  background: #eff6ff;
}
.stage-note {
  margin-top: .35rem;
  font-size: .73rem;
  color: var(--text-muted);
}

/* Team Grid */
.team-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.team-empty { text-align: center; padding: 3rem; color: var(--text-muted); }
.team-empty .hint { font-size: .82rem; margin-top: .5rem; }

.student-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color .2s;
}
.student-card.trouble { border-left: 3px solid var(--danger); }
.student-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.student-icon { font-size: 1.3rem; }
.student-name { font-weight: 600; }
.student-year { font-size: .75rem; color: var(--text-muted); font-family: var(--font-mono); margin-left: auto; }
.student-trait { font-size: .8rem; color: var(--text-secondary); margin-bottom: .5rem; }
.student-progress { margin-top: .4rem; }
.student-actions { display: flex; gap: .4rem; margin-top: .5rem; }
.student-actions button { font-size: .75rem; padding: 3px 8px; }

/* Research */
.research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.research-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.research-card:last-child { grid-column: 1 / -1; }
.research-card h3 { font-size: .95rem; margin-bottom: .25rem; }
.research-card .hint { font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; }
.tool-list { display: flex; flex-direction: column; gap: .4rem; }

.paper-list { display: flex; flex-direction: column; gap: .5rem; }
.paper-item {
  display: flex; align-items: center; gap: .5rem;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .82rem;
}
.paper-status { font-size: .7rem; padding: 2px 6px; border-radius: 3px; font-weight: 600; }
.paper-status.published { background: var(--success-light); color: var(--success); }
.paper-status.submitted { background: var(--warning-light); color: var(--warning); }
.paper-status.draft { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.paper-status.rejected { background: var(--danger-light); color: var(--danger); }
.paper-meta { font-size: .73rem; color: var(--text-muted); }

/* Rivals */
.rival-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.rival-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.rival-card.ahead { border-left: 3px solid var(--danger); }
.rival-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.rival-avatar { font-size: 1.3rem; }
.rival-name { font-weight: 600; }
.rival-style { font-size: .75rem; color: var(--text-muted); margin-left: auto; font-family: var(--font-mono); }
.rival-stats { font-size: .82rem; color: var(--text-secondary); margin-bottom: .4rem; }
.rival-action { font-size: .78rem; color: var(--text-muted); font-style: italic; }

/* News */
.news-feed { display: flex; flex-direction: column; gap: 10px; max-width: 600px; }
.news-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.news-item .news-time { font-size: .72rem; color: var(--text-muted); font-family: var(--font-mono); }
.news-item .news-text { font-size: .85rem; margin-top: .25rem; }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.modal-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-panel h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.modal-panel p { font-size: .88rem; color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.6; }

/* ═══ END SCREEN ═══ */
.end-layout {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 42px);
  padding: 2rem;
}
.end-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 3rem;
  max-width: 560px;
  width: 100%;
  text-align: center;
}
.end-panel h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.end-copy { color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.7; }
.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.end-stat {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: .75rem;
}
.end-stat span { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; display: block; }
.end-stat strong { font-size: 1.3rem; }
.end-ranking { text-align: left; margin-bottom: 1.5rem; }
.end-rank-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.end-rank-row .rank-num { font-weight: 700; color: var(--primary); width: 2rem; }
.end-rank-row .rank-score { margin-left: auto; font-family: var(--font-mono); color: var(--text-muted); }
.end-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar-bg);
  color: white;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: .85rem;
  z-index: 300;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hint { font-size: .82rem; color: var(--text-muted); }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
  .portal-layout { flex-direction: column; }
  .portal-sidebar { width: 100%; flex-direction: row; padding: 1rem; gap: 1rem; align-items: center; }
  .portal-main { padding: 1.5rem; }
  .direction-grid, .strategy-grid { grid-template-columns: 1fr; }
  .game-layout { flex-direction: column; }
  .profile-sidebar { width: 100%; max-height: none; position: static; flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .home-grid { grid-template-columns: 1fr; }
  .project-stage-grid { grid-template-columns: 1fr; }
  .research-grid { grid-template-columns: 1fr; }
}
