/* ============================================================
   公交站牌工坊 · 样式
   设计方向：公交站台 —— 浅色候车厅基底 + 深色站牌焦点
   ============================================================ */

:root {
  --bg: #F1F3EE;
  --surface: #FFFFFF;
  --ink: #1D2320;
  --muted: #6C746E;
  --line: #DFE3DC;
  --accent: #0E7A3C;
  --accent-deep: #0A5F2F;
  --danger: #B5433A;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29,35,32,.05), 0 12px 32px rgba(29,35,32,.09);

  --theme-green: #0E7A3C;
  --theme-blue: #1466B8;
  --theme-red: #C4302B;
  --theme-night: #2C3E8F;
  --theme-orange: #D97A0E;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ===== 页首 ===== */
.site-header {
  background: var(--ink);
  color: #F4F6F1;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 20px; font-weight: 900; letter-spacing: .5px; }
.brand-text em { font-style: normal; font-size: 12.5px; color: #A9B2AB; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }

.btn-ghost { background: transparent; border-color: #37403A; color: #E8ECE6; }
.btn-ghost:hover { background: #2A322C; }

.btn-dashed {
  background: transparent;
  border-style: dashed;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 500;
}
.btn-dashed:hover { border-color: var(--accent); color: var(--accent); background: rgba(14,122,60,.05); }

.btn-full { width: 100%; }

/* ===== 主体布局 ===== */
.workspace {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}

.panel, .stage, .library {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { padding: 18px 20px; }

.panel-block { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.panel-block:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: none; }

.panel-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--ink);
  text-transform: none;
}
.panel-title::before { content: ""; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-row { display: flex; gap: 12px; margin-bottom: 12px; }
.field-row .field { flex: 1; }

label { font-size: 12.5px; font-weight: 700; color: #4A524C; }

input[type="text"], input[type="time"], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
  background: #FAFBF8;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,122,60,.12); background: #fff; }

.hint { color: var(--muted); font-weight: 400; }

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: #3A413C;
  margin: 10px 0 0;
  cursor: pointer;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.panel-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* 站点编辑器 */
.stops-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.stop-row {
  display: grid;
  grid-template-columns: 28px 1fr 64px auto;
  gap: 8px;
  align-items: center;
  background: #FAFBF8;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 8px;
}

.stop-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.stop-row.current .stop-index { background: var(--accent); }

.stop-row input[type="text"] { padding: 6px 8px; font-size: 13.5px; }

.stop-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.stop-current input { accent-color: var(--accent); margin: 0; }

.stop-actions { display: flex; gap: 4px; }
.stop-actions button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.stop-actions button:hover { border-color: var(--ink); color: var(--ink); }
.stop-actions button.del:hover { border-color: var(--danger); color: var(--danger); }

/* 换乘图标选择行 */
.stop-icons {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  padding-top: 4px;
}
.ico-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}
.ico-btn:hover { border-color: var(--ink); color: var(--ink); }
.ico-btn.active { border-color: var(--accent); background: rgba(14,122,60,.1); color: var(--accent); }
.ico-btn svg { width: 15px; height: 15px; }

/* ===== 预览舞台 ===== */
.stage {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  overflow: hidden;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #FAFBF8;
}

.stage-caption { font-size: 13px; font-weight: 900; letter-spacing: 1px; }
.stage-tag { font-size: 11.5px; color: var(--muted); }

.board-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background:
    radial-gradient(circle at 1px 1px, rgba(29,35,32,.07) 1px, transparent 0) 0 0 / 22px 22px,
    linear-gradient(180deg, #EDF0EA, #E6E9E3);
}

.board-note { font-size: 12px; color: var(--muted); text-align: center; padding: 12px 18px; border-top: 1px solid var(--line); background: #FAFBF8; }

/* ===== 站牌卡片 ===== */
.board-card {
  background: #fff;
  border: 1px solid #D8DDD5;
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(29,35,32,.18);
  width: 340px;
  padding: 10px;
  transition: width .2s ease;
}
.board-card.landscape { width: 620px; }

.stopboard {
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 顶栏 */
.sb-head {
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.sb-line-num {
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 1px;
  flex: none;
  align-self: center;
  min-width: 88px;
  text-align: center;
}

.sb-head-meta { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.sb-line-name { font-size: 15px; font-weight: 700; letter-spacing: 2px; }
.sb-route { font-size: 13px; font-weight: 500; opacity: .92; display: flex; align-items: center; gap: 6px; }
.sb-route .route-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.22); flex: none;
}
.sb-route .route-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 标题栏 */
.sb-crest {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 6px;
  color: #fff;
  opacity: .9;
  padding: 3px 0 5px;
}
.board-card.landscape .sb-crest { display: none; }

/* 站点区 */
.sb-stops {
  background: #fff;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-stop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 14.5px;
  font-weight: 500;
  color: #232926;
  border-radius: 6px;
  min-width: 0;
}

.sb-stop-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--stop-color, var(--accent));
  flex: none;
}

.sb-stop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 换乘图标（站牌上） */
.sb-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  flex: none;
}
.sb-ico { display: inline-flex; color: var(--stop-color, var(--accent)); }
.sb-stop.current .sb-ico { color: #fff; }
.sb-stop.next .sb-ico { color: var(--stop-color, var(--accent)); }

.sb-stop.current {
  background: var(--stop-color, var(--accent));
  color: #fff;
  font-weight: 700;
  padding: 5px 8px;
}
.sb-stop.current .sb-stop-dot { background: #fff; border-color: #fff; }
.sb-stop.current .sb-stop-tag { color: rgba(255,255,255,.92); }

.sb-stop.next .sb-stop-dot { background: var(--stop-color, var(--accent)); }

.sb-stop-tag { margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--muted); flex: none; }

/* 底栏 */
.sb-foot {
  color: #fff;
  padding: 9px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .5px;
}
.sb-foot b { font-weight: 900; }
.sb-foot-op { flex-basis: 100%; color: rgba(255,255,255,.88); }

/* 横版 */
.board-card.landscape .sb-head { padding: 10px 16px; }
.board-card.landscape .sb-line-num { font-size: 40px; min-width: 80px; }
.board-card.landscape .sb-stops {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  padding: 12px 16px;
  gap: 8px;
}
.board-card.landscape .sb-stop {
  flex: 1 1 150px;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  gap: 6px;
}
.board-card.landscape .sb-stop.current { border-color: transparent; }
.board-card.landscape .sb-stop-tag { margin-left: 0; }
.board-card.landscape .sb-foot { font-size: 12px; }

/* ===== 站牌库 ===== */
.library { grid-column: 1 / -1; padding: 18px 20px; }
.library-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.lib-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.lib-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(29,35,32,.12); }

.lib-thumb {
  height: 120px;
  background: #EEF0EB;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.lib-thumb .mini-board {
  width: 86px;
  transform: scale(1);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(29,35,32,.22);
}
.lib-thumb .mini-head {
  color: #fff;
  text-align: center;
  padding: 6px 4px 5px;
}
.lib-thumb .mini-num { font-size: 20px; font-weight: 900; line-height: 1; }
.lib-thumb .mini-name { font-size: 8px; font-weight: 500; margin-top: 2px; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-thumb .mini-stops { background: #fff; padding: 6px 6px 7px; display: flex; flex-direction: column; gap: 3px; }
.lib-thumb .mini-stop { height: 7px; border-radius: 3.5px; background: #DDE2DA; }
.lib-thumb .mini-stop.on { background: var(--mini-color, var(--accent)); }

.lib-meta { padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lib-meta strong { font-size: 13.5px; font-weight: 700; }
.lib-meta span { font-size: 11px; color: var(--muted); }

.lib-del {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  flex: none;
}
.lib-del:hover { border-color: var(--danger); color: var(--danger); }

.library-empty { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
.library-empty.hidden { display: none; }

.library-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ===== 页尾 ===== */
.site-footer { background: var(--ink); color: #C9CFC9; }

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px;
  font-size: 13px;
  line-height: 1.7;
}
.footer-inner strong { color: #F4F6F1; }
.footer-sub { font-size: 12px; color: #8A938B; margin: 4px 0 0; }

/* ===== 动效（尊重 reduced motion） ===== */
@media (prefers-reduced-motion: no-preference) {
  .board-card { animation: boardIn .28s ease both; }
  @keyframes boardIn {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: none; }
  }
  .sb-stop.current { transition: background .2s ease; }
}

/* ===== 响应式 ===== */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .library { grid-column: 1; }
}

@media (max-width: 640px) {
  .header-inner { padding: 12px 16px; }
  .brand-text em { display: none; }
  .header-actions .btn { padding: 8px 12px; font-size: 13px; }
  .workspace { padding: 18px 14px 36px; }
  .board-card, .board-card.landscape { width: 100%; max-width: 340px; }
  .field-row { flex-direction: column; gap: 12px; }
}

/* ===== 打印：只输出站牌 ===== */
@media print {
  body { background: #fff; }
  .site-header, .panel, .library, .site-footer, .stage-toolbar, .board-note { display: none !important; }
  .workspace { display: block; padding: 0; max-width: none; }
  .stage { display: block; box-shadow: none; border: none; min-height: 0; }
  .board-viewport { padding: 0; background: #fff; display: block; }
  .board-card { width: 340px; border: none; box-shadow: none; animation: none; }
  .board-card.landscape { width: 620px; }
  .sb-stop { page-break-inside: avoid; }
  @page { margin: 14mm; }
}
