/*
  Emoji 月历 样式
  字体：Parisienne (v14), SIL Open Font License 1.1
  来源：https://fonts.google.com/specimen/Parisienne
  授权：https://github.com/google/fonts/blob/main/ofl/parisienne/OFL.txt
  仅打包 .woff2，无任何外链字体（容器零网络）。
*/
@font-face {
  font-family: 'Parisienne';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('./fonts/Parisienne-Regular.woff2') format('woff2');
}
/*
  中文手写体：Ma Shan Zheng（马善政楷书），SIL Open Font License 1.1
  来源：https://fonts.google.com/specimen/Ma+Shan+Zheng
  授权：https://github.com/google/fonts/blob/main/ofl/mashanzheng/OFL.txt
  已用 pyftsubset 子集化（约 520 常用字+标点，见 fonts/subset-charset.txt），
  仅打包子集 .woff2；字集外汉字回退系统中文字体（PingFang/宋体），不出方框。
*/
@font-face {
  font-family: 'Ma Shan Zheng';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/MaShanZheng-subset.woff2') format('woff2');
}

:root {
  --bg: #ece7de;
  --cream: #f5f2ec;
  --card: #ffffff;
  --ink: #171717;
  --ink-weekend: #c7c3bb;
  --muted: #b3aea4;
  --line: #efebe3;
  --accent: #1a1a1a;
  --serif: Georgia, 'Times New Roman', 'Songti SC', serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden 属性优先级：display 布局规则不得覆盖它 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.tb-selects { display: flex; gap: 8px; }
.sel-wrap {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.sel-wrap::after {
  content: '▾';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 12px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  padding: 9px 30px 9px 14px;
  font-size: 15px;
  color: var(--ink);
  border-radius: 12px;
  font-family: inherit;
}
.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  flex: none;
}
.btn-primary:active { opacity: .8; }

/* ---------- 日历卡片 ---------- */
.stage { margin-bottom: 12px; }
.calendar-card {
  background: var(--card);
  border-radius: 28px;
  padding: 26px 22px 20px;
  box-shadow: 0 10px 30px rgba(60,50,35,.08);
}
.cal-owner {
  font-family: 'Parisienne', cursive;
  font-size: 19px;              /* v1.1 缩小：月份名 > 标题 > 星期行 */
  line-height: 1.15;
  color: #6f6a61;
  margin-bottom: 2px;
  min-height: 24px;
  word-break: break-word;
}
.cal-owner.empty { color: #ccc6bb; }
.cal-title {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--accent);
  margin-bottom: 14px;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 12px;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 500;
}
.cal-weekdays span.wend { color: #cfcac1; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: auto;
}
/* 日期格：上下两层——数字在上，内容在下（对齐参考图的高留白结构） */
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1.34;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 9px;
  overflow: hidden;
}
.cal-cell .date {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  line-height: 1;
}
.cal-cell.wend .date { color: var(--ink-weekend); }
.cal-cell .content {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.cal-cell .glyph {
  font-size: 30px;
  line-height: 1;
}
.cal-cell canvas.thumb {
  width: 80%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: contain;
}
.cal-cell.filled:active { background: #faf8f4; }

/* 空白区手写标注（占据空白格，跨列）：内层绝对定位，不撑高日历行 */
.note-cell {
  position: relative;
  border-top: 1px solid var(--line);
}
.note-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 5px 8px;
}
.note-text {
  font-family: 'Parisienne', cursive;
  font-size: 28px;
  line-height: 1.4;           /* 加大行高：容纳花体引号上缘，避免裁切（不放大字号） */
  color: #2b2b2b;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* 放置区最多两行 */
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;    /* 中文/超长词也能换行 */
  word-break: break-word;
}
/* 无任何空白格时，标注回退到卡片下方 */
.note-below {
  font-family: 'Parisienne', cursive;
  font-size: 28px;
  line-height: 1.4;           /* 同上：容纳花体引号上缘 */
  color: #2b2b2b;
  text-align: center;
  padding: 14px 10px 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stage-hint {
  text-align: center;
  color: #a49f95;
  font-size: 12px;
  margin: 10px 0 0;
}

/* ---------- 标题 / 手写标注编辑 ---------- */
.text-editor { margin: 4px 0 0; }
.te-label {
  display: block;
  font-size: 11px;
  color: #a49f95;
  margin: 8px 2px 4px;
}
.text-editor input {
  width: 100%;
  border: 1px solid #e4dfd6;
  background: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
}
.text-editor input:focus { outline: none; border-color: #cfc7ba; }

/* 中文标题字体切换（分段控件，风格对齐现有 chip） */
.font-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.font-toggle .ft-label { font-size: 11px; color: #a49f95; }
.seg {
  display: inline-flex;
  background: #f2efe9;
  border-radius: 999px;
  padding: 2px;
}
.seg button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: #6f6a61;
  font-family: inherit;
}
.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ---------- 编辑面板 ---------- */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20,16,10,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
}
.panel {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideup .18s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.panel-close {
  border: none; background: #f2efe9;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 20px; line-height: 1; color: #8a857b;
}
.panel-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid #e6e1d8;
  background: #faf8f4;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--ink);
  font-family: inherit;
}
.chip:active { background: #efeae1; }
.chip-clear { color: #b5544b; border-color: #eddad6; background: #fbf3f1; }

.kb-row { display: flex; gap: 8px; margin-bottom: 12px; }
.kb-input {
  flex: 1;
  border: 1px solid #e4dfd6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 20px;
  font-family: inherit;
}
.kb-input:focus { outline: none; border-color: #cfc7ba; }

.emoji-panel-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.emoji-grid button {
  border: none;
  background: transparent;
  font-size: 26px;
  padding: 6px 0;
  border-radius: 8px;
  line-height: 1;
}
.emoji-grid button:active { background: #f2efe9; }

/* ---------- 轻量提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(23,19,13,.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 导出预览全屏 ---------- */
.export-overlay {
  position: fixed;
  inset: 0;
  background: #17130d;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
}
.export-guide {
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-bottom: 12px;
}
.export-guide-emoji { font-size: 22px; }
.export-guide > span:nth-child(2) { font-size: 16px; font-weight: 600; }
.export-guide-sub { font-size: 12px; color: #b9b3a8; font-weight: 400; }
.export-canvas-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.export-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.export-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.btn-share {
  border: none;
  background: #fff;
  color: #17130d;
  padding: 12px 30px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
}
.btn-share:active { opacity: .85; }
.btn-ghost {
  border: 1px solid rgba(255,255,255,.3);
  background: transparent;
  color: #fff;
  padding: 10px 26px;
  border-radius: 999px;
  font-size: 15px;
  font-family: inherit;
}


/* ============================================================
   字体授权全文 · Parisienne (v14)
   SIL Open Font License, Version 1.1
   来源: https://fonts.google.com/specimen/Parisienne
   为符合「包内仅允许特定文件类型」约束，OFL 全文以 CSS 注释随包留存。
   ------------------------------------------------------------
Copyright (c) 2012 by Brian J. Bonislawsky DBA Astigmatic (AOETI)
(astigma@astigmatic.com), with Reserved Font Names "Parisienne"

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded, 
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
   ============================================================ */


/* ============================================================
   字体授权全文 · Ma Shan Zheng（马善政楷书）
   SIL Open Font License, Version 1.1
   来源: https://fonts.google.com/specimen/Ma+Shan+Zheng
   本包内为 pyftsubset 子集（约 520 常用字+标点，见 fonts/subset-charset.txt）。
   ------------------------------------------------------------
Copyright 2018 The Ma Shan Zheng Project Authors (https://github.com/googlefonts/mashanzheng)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded, 
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
   ============================================================ */
