/* 田字格页面样式：沿用汉字小岛“岛屿纸本”的颜色和圆角，去掉孩子页的插画和发光。只有浅色。 */
:root {
  --paper: #f7f2e7;
  --paper-2: #efe7d6;
  --card: #fffdf8;
  --ink: #2b3442;
  --muted: #6d624f;
  --line: #e6dccb;
  --sea: #1f6f68;
  --sea-ink: #175a54;
  --sea-soft: #e3f0ec;
  --sun-soft: #fff3d6;
  --coral: #a4513a;
  --shadow: 0 1px 0 rgba(120, 95, 50, .06), 0 8px 22px rgba(80, 62, 24, .06);
  color-scheme: only light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
h2 { font-size: 1rem; margin: 0 0 10px; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--sea); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px max(16px, calc((100vw - 1200px) / 2)); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 1.05rem; min-height: 44px; }
.brand .dot, .brand .tool { color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill { min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: #f6f0e4; color: var(--muted); display: inline-flex; align-items: center; font-size: .9rem; }

.layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; max-width: 1200px; margin: 0 auto; padding: 20px 16px 32px; align-items: start; }
.left { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid #ece7dc; border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }

.note { font-size: .82rem; color: var(--muted); margin: 6px 0; }
.warn { font-size: .82rem; color: var(--coral); margin: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; }
.chip { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-family: "Kaiti SC", KaiTi, STKaiti, serif; font-size: 1.45rem; display: grid; place-items: center; padding: 0; }
.chip.missing { border-style: dashed; color: var(--coral); }
.chip { position: relative; }
/* 右上角小叉：告诉家长点一下能去掉 */
.chip .x { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); color: #fff; font: 600 12px/18px system-ui, sans-serif; text-align: center; }
.effect { margin-top: 6px; }
.add { display: flex; gap: 6px; margin-top: 6px; }
.add input { flex: 1; min-width: 0; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0 12px; }
.soft { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px dashed #b79a70; background: transparent; color: #8a5f0a; }

.seg { display: flex; flex-wrap: wrap; background: #f6f0e4; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 44px; min-width: 44px; border: 0; background: transparent; color: var(--muted); border-radius: 10px; font-size: .88rem; padding: 0 8px; }
.seg button.on { background: #fff; color: var(--sea-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
#settings details { margin-top: 12px; }
#settings summary { min-height: 44px; display: flex; align-items: center; color: var(--sea); cursor: pointer; }
.row { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); align-items: center; gap: 8px; margin: 8px 0; font-size: .88rem; color: var(--muted); }
.row input { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0 10px; min-width: 0; }
.row .soft { grid-column: 2; }

.primary { min-height: 52px; border: 0; border-radius: 14px; background: var(--sea); color: #fff; font-size: 1.05rem; font-weight: 600; box-shadow: 0 3px 0 var(--sea-ink); }
.primary:disabled { opacity: .7; }

.right { background: var(--paper-2); border-radius: 20px; padding: 14px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.preview-head h2 { display: inline; }
.primary.slim { min-height: 44px; padding: 0 16px; font-size: .95rem; flex-shrink: 0; }
.hint { margin: -4px 4px 0; font-size: .85rem; color: var(--muted); }
.preview-head span { font-size: .85rem; color: var(--muted); }
#pages { display: flex; flex-direction: column; gap: 14px; }
.paper { background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgba(80, 62, 24, .12); overflow: hidden; }
.paper svg { display: block; }

.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 28px; }
.foot p { margin: 4px 0; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 14px; }
  #generate-top { display: none; } /* 一栏时预览在按钮下面，不用再放一个 */
  .right { order: 0; }
  .brand { font-size: .98rem; }
}

/* 第一组工具共用 */
.tool-desc { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.6; }
#picker h2 { margin-bottom: 8px; }
#picker textarea, #picker > input, #picker select { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 10px 12px; font-size: 1.05rem; }
#picker textarea { min-height: 88px; resize: vertical; font-family: "Kaiti SC", KaiTi, STKaiti, serif; font-size: 1.3rem; line-height: 1.5; }
#picker > input { min-height: 44px; }
#picker select { margin-top: 8px; font-size: .95rem; }
#picker .soft { margin-top: 8px; }
#settings .row:first-child { margin-top: 0; }

/* 总入口页 */
.hub { max-width: 1100px; margin: 0 auto; padding: 24px 16px 36px; }
.hub h1 { font-size: 1.5rem; margin: 0 0 6px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.tool-card { display: flex; flex-direction: column; gap: 6px; min-height: 104px; padding: 16px; border-radius: 18px; background: var(--card); border: 1px solid #ece7dc; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.tool-card b { font-size: 1.05rem; color: var(--sea-ink); }
.tool-card span { font-size: .86rem; color: var(--muted); line-height: 1.5; }
.tool-card[data-id="tianzige"] { border: 2px solid var(--sea); }

/* 窄屏顶栏：只留 logo 和工具名，文字不折行 */
.brand span, .pill { white-space: nowrap; }
@media (max-width: 440px) {
  .topbar { gap: 8px; }
  .brand #brand-name, .brand .dot { display: none; }
  .pill { padding: 0 10px; }
}

/* 多音字按钮 */
.poly { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.poly-chip { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: .95rem; }
.poly-chip b { font-family: "Kaiti SC", KaiTi, STKaiti, serif; font-size: 1.25rem; font-weight: 400; margin-right: 4px; }
.poly-chip.on { border-color: var(--sea); background: var(--sea-soft); color: var(--sea-ink); }

/* 界面语言选择框 */
select.pill { -webkit-appearance: none; appearance: none; cursor: pointer; padding: 0 28px 0 12px; background: #f6f0e4 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236d624f'/%3E%3C/svg%3E") no-repeat right 10px center; font-size: .9rem; color: var(--muted); }

/* 顶栏挤不下时（英文工具名比较长）：工具名缩短加省略号，右边的按钮保持完整 */
.brand { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.brand .tool { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand img { flex-shrink: 0; }
.top-actions { flex-shrink: 0; }

/* 工具条（2026-11-21 Neil：全部工具不藏起来，第一次进来就看到）：顶栏下面一排，当前的高亮；手机上一行左右滑。按钮不小于 44px */
.tool-strip { display: flex; flex-wrap: wrap; gap: 8px; min-height: 64px; padding: 10px max(16px, calc((100vw - 1200px) / 2)); background: var(--card); border-bottom: 1px solid var(--line); }
.tool-strip a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; background: #f6f0e4; color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .9375rem; }
.tool-strip a[aria-current] { background: var(--sea-soft); color: var(--sea-ink); font-weight: 650; box-shadow: inset 0 0 0 1.5px #c6e0d8; }
.tool-strip a.all { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.tool-strip a:focus-visible { outline: 3px solid var(--sea-ink); outline-offset: 2px; }
@media (max-width: 720px) {
  .tool-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-top: 8px; padding-bottom: 8px; }
  .tool-strip::-webkit-scrollbar { display: none; }
}
@media print { .tool-strip { display: none; } }

/* 2026-11-21 加载优化：字帖画出来以前，先占好一张 Letter 纸的位置，页面不跳 */
.paper-wait { aspect-ratio: 215.9 / 279.4; }
/* 程序把左边的卡片画好以前，中间内容和页脚先不显示（占着位置但看不见），画好一次出现，不会先空着再被撑开。
   顶栏和工具条照常立刻显示。万一程序出错，2 秒后也照常显示。（2026-11-21，线上实测：不这样做时页面跳动 0.22） */
body[data-wait] .layout, body[data-wait] .foot { visibility: hidden; animation: tzg-show 0s 2s forwards; }
@keyframes tzg-show { to { visibility: visible; } }
