/*! tzpy：应用自身样式（布局/表格/画布尺寸等），来自原版 taez/tools/tzpy/index.html 的 <style>。
 * metro.css 负责外层外观（面板、按钮、页头），本文件只补应用结构与几何，勿随意删减。 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f7f7; color: #222; padding: 20px 14px;
}
.wrap { max-width: 1200px; margin: 0 auto; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.sub { color: #888; font-size: 13px; margin: 0 0 18px; }
.panel {
  background: #fff; border: 1px solid #ddd; border-radius: 2px;
  padding: 14px; margin-bottom: 14px;
}
.hidden { display: none !important; }
.btn {
  padding: 6px 14px; border: 1px solid #bbb; border-radius: 2px;
  background: #fff; color: #222; font-size: 13px; cursor: pointer; font-family: inherit;
  text-decoration: none; display: inline-block;
}
.btn:hover { background: #f0f0f0; }
.btn.primary { background: #2c5fa8; border-color: #2c5fa8; color: #fff; }
.btn.primary:hover { background: #244d8a; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.hint { font-size: 12px; color: #888; }

/* 全局变量设置 */
.var-row {
  display: flex; flex-wrap: wrap; gap: 14px 20px;
}
.var-row label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #666;
}
.var-row input {
  padding: 5px 8px; border: 1px solid #ccc; border-radius: 2px;
  font-size: 13px; font-family: inherit; width: 140px;
}

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid #ddd; margin-bottom: 14px; }
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 14px; color: #666;
  border: 1px solid transparent; border-bottom: none; border-radius: 2px 2px 0 0;
  margin-bottom: -1px; background: transparent; font-family: inherit;
}
.tab.active { background: #fff; border-color: #ddd; color: #222; font-weight: 600; }

/* 工作区 */
.workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
}

.side {
  background: #fff; border: 1px solid #ddd; border-radius: 2px;
  display: flex; flex-direction: column;
  max-height: 82vh;
}
.side-head {
  padding: 10px;
  border-bottom: 1px solid #eee;
  display: flex; flex-direction: column; gap: 8px;
}
.side-head select, .side-head input {
  width: 100%; padding: 5px 8px; border: 1px solid #ccc; border-radius: 2px;
  font-size: 13px; font-family: inherit; background: #fff; color: #222;
}

/* 标签行 */
.cat-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  max-height: 84px; overflow-y: auto;
  flex-shrink: 0;
}
.cat-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; font-size: 11px;
  background: #f0f0f0; color: #555;
  border: 1px solid transparent; border-radius: 2px;
  cursor: pointer; user-select: none;
  white-space: nowrap;
}
.cat-chip:hover { background: #e5e5e5; }
.cat-chip.active { background: #2c5fa8; color: #fff; border-color: #2c5fa8; }
.cat-chip .chip-count {
  margin-left: 4px; opacity: .65;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}
.cat-chip.active .chip-count { opacity: .9; }

.side-list {
  flex: 1; overflow-y: auto; padding: 6px;
}
.list-item {
  padding: 8px 10px; cursor: pointer;
  font-size: 12px; color: #333;
  border-radius: 2px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.list-item:hover { background: #f5f7fb; }
.list-item.selected {
  background: #eef3fb; border-color: #2c5fa8;
}
.list-item .idx {
  display: inline-block; min-width: 28px;
  color: #999; font-size: 11px;
}
.list-item .cat-tag {
  display: inline-block; padding: 0 5px; margin-right: 6px;
  background: #f0f0f0; color: #666; font-size: 10px; border-radius: 2px;
  cursor: pointer;
  border: 1px solid transparent;
}
.list-item .cat-tag:hover {
  background: #2c5fa8; color: #fff; border-color: #2c5fa8;
}
.side-foot {
  padding: 8px 10px; border-top: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #888;
}

.main {
  background: #fff; border: 1px solid #ddd; border-radius: 2px;
  display: flex; flex-direction: column;
}
.main-head {
  padding: 10px 14px; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
}
.main-head .title { font-weight: 600; }
.main-head .counter { color: #888; font-size: 12px; }
.preview-area {
  padding: 14px;
}
.preview-area textarea {
  width: 100%; min-height: 260px; padding: 12px 14px;
  border: 1px solid #ccc; border-radius: 2px;
  font-size: 14px; font-family: inherit; line-height: 1.8;
  background: #fafafa; color: #222; resize: vertical;
}
.main-actions {
  padding: 12px 14px; border-top: 1px solid #eee;
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: flex-end;
}
.status {
  padding: 0 14px 12px; font-size: 12px; min-height: 16px; color: #666;
}
.status.ok { color: #2e7d32; }
.status.err { color: #c62828; }
