/* 两地日程 设计稿样式
   规则：粉/奶油只代表两个人（就是猪猪、兔兔的颜色）；红只代表“此刻”；其余界面是带一点暖意的中性灰。
   圆角分层：看板 24 / 时钟卡 20 / 弹层 28 / 日程卡 7 / 胶囊 999。 */

@font-face {
  font-family: "LD Num";
  src: url("fonts/nunito-numerals.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+20, U+2B, U+2D-2F, U+30-3A, U+2013, U+2212;
}

:root {
  color-scheme: light;

  --paper: #F7F3F1;
  --surface: #FFFFFF;
  --ink: #2E2627;
  --ink-2: #5B5052;
  --ink-3: #776B6C;
  --ink-4: #ABA0A0;
  --hair: #ECE5E2;
  --hair-2: #F4EFED;
  --rule: #DFD5D1;   /* 日与日之间的竖线：要比整点横线明显 */
  --night: #E8ECF6;
  --night-ink: #5E6A88;

  /* 猪猪：草莓牛奶粉；兔兔：奶油白（纯白在白底上看不见，取她毛色在暖光下的奶油色） */
  --pig-fill: #FFE3EA; --pig-line: #F4BCCB; --pig-ink: #8C2D4E; --pig-strong: #C9467A; --pig-soft: #FFF1F5; --pig-glow: rgba(201, 70, 122, .32);
  --bunny-fill: #FFF1D6; --bunny-line: #EBCF96; --bunny-ink: #6B4A1E; --bunny-strong: #9A6420; --bunny-soft: #FFF8EA; --bunny-glow: rgba(154, 100, 32, .3);

  --now: #E8483F;
  --danger: #C2383C; --danger-bg: #FCEDED;

  --r-board: 24px; --r-clock: 20px; --r-sheet: 28px; --r-card: 7px; --r-field: 14px;

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB",
          "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --num: "LD Num", var(--sans);

  --ax: 30px;        /* 两侧时间轴宽 */
  --ease: cubic-bezier(.3, .7, .2, 1);
}

/* “我”的颜色随登录者变化：添加按钮、选中态都用它 */
[data-viewer="a"] { --me-strong: var(--pig-strong); --me-soft: var(--pig-soft); --me-ink: var(--pig-ink); --me-line: var(--pig-line); --me-glow: var(--pig-glow); }
[data-viewer="b"] { --me-strong: var(--bunny-strong); --me-soft: var(--bunny-soft); --me-ink: var(--bunny-ink); --me-line: var(--bunny-line); --me-glow: var(--bunny-glow); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
h1, h2, h3, p, dl, dd, fieldset { margin: 0; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ava { flex: none; }

/* ───────── 页面骨架：顶栏 + 一屏放下的一周 ───────── */

/* 还不知道登没登录时先不露出页面，免得闪一下空网格 */
[data-page="boot"] .app { visibility: hidden; }

.app {
  max-width: 1320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
}

.top {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand actions" "clocks clocks";
  align-items: center; gap: 4px 10px;
  padding: 6px 0 8px;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; font-weight: 650; letter-spacing: .08em; }
.logo { width: 50px; height: 32px; flex: none; }

.actions { grid-area: actions; display: flex; align-items: center; gap: 8px; }
.later-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 12px;
  border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.later-btn:hover { color: var(--ink); }
.later-btn b {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--paper);
  color: var(--ink); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}
.lb-short { display: none; }
.add-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 36px; padding: 0 15px 0 11px; border-radius: 999px;
  background: var(--me-strong); color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 8px 18px -10px var(--me-glow);
  transition: transform .2s var(--ease);
}
.add-btn .i { font-size: 19px; stroke-width: 2.4; }
.add-btn:active { transform: scale(.95); }

.menu-wrap { position: relative; }
.ava-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
}
.ava-btn .ava { width: 30px; height: 30px; }
.ava-btn[aria-expanded="true"] { box-shadow: inset 0 0 0 1.5px var(--me-strong); }
.menu {
  position: absolute; right: 0; top: 46px; z-index: 50; width: 268px; padding: 6px;
  background: var(--surface); border-radius: 18px;
  box-shadow: 0 0 0 1px var(--hair), 0 18px 40px -18px rgba(46, 38, 39, .35);
}
.menu > button { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 40px; padding: 0 12px; border-radius: 12px; font-size: 14px; }
.menu > button:hover { background: var(--paper); }
.menu-meta { color: var(--ink-3); font-size: 12.5px; }

/* ───────── 两地时钟：深色、更大的那一边就是现在的排法 ───────── */

.clocks { grid-area: clocks; display: flex; align-items: stretch; min-width: 0; }
.seam { position: relative; z-index: 2; flex: 0 0 10px; }
.swap {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); color: var(--ink-2); font-size: 17px;
  box-shadow: 0 0 0 4px var(--paper), inset 0 0 0 1px var(--hair);
  transition: transform .45s var(--ease);
}
.swap:hover { color: var(--ink); }
[data-primary="uk"] .swap { transform: translate(-50%, -50%) rotate(180deg); }

.clock {
  flex: 1 1 0; min-width: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ava meta time" "st st st";
  align-items: center; gap: 4px 7px;
  padding: 9px 14px 9px 10px; border-radius: var(--r-clock); background: var(--surface);
  transition: flex-grow .45s var(--ease);
}
.clock[data-zone="uk"] { grid-template-areas: "time meta ava" "st st st"; padding: 9px 10px 9px 14px; text-align: right; }
.clock-ava { grid-area: ava; width: 28px; height: 28px; }
.clock-meta { grid-area: meta; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.clock-place { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.clock-date { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.cd-md { display: none; }
.clock-time {
  grid-area: time; font-size: 20px; font-weight: 400; line-height: 1; color: var(--ink-3);
  transition: font-size .45s var(--ease), color .3s;
}
.clock[aria-pressed="true"] .clock-time { font-size: 26px; font-weight: 350; color: var(--ink); }
.clock-st { grid-area: st; display: flex; gap: 5px; min-width: 0; font-size: 12px; line-height: 1.35; white-space: nowrap; }
.clock[data-zone="uk"] .clock-st { justify-content: flex-end; }
.st-main, .st-sub { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.st-main { color: var(--ink); font-weight: 550; }
.st-sub { color: var(--ink-3); }
.clock[data-state="sleep"] .st-main { color: var(--night-ink); }

.caption { margin: -2px 0 8px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ───────── 一周网格：七列是主线的七天，每列是主线的 0–24 点 ───────── */

.week {
  flex: 1 1 auto; min-height: 420px;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-board); overflow: hidden;
}

/* 翻周：两侧箭头翻前后一周，中间写这一屏的日期范围；不在本周时多一个“回到本周”。
   看的是过去或将来时，网格里不画此刻线（此刻不在这七天里）。 */
.week-nav {
  flex: none;
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 2px;
  padding: 7px 8px 0;
}
.wn-arrow {
  display: grid; place-items: center; width: 34px; height: 26px; border-radius: 9px;
  color: var(--ink-3); transition: color .2s, background-color .2s;
}
.wn-arrow .i { font-size: 17px; stroke-width: 1.9; }
.wn-arrow:hover { color: var(--ink); background: var(--paper); }
.wn-arrow:disabled { color: var(--ink-4); background: none; opacity: .5; cursor: default; }
.wn-mid { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.wn-range {
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wn-today {
  flex: none; height: 23px; padding: 0 9px; border-radius: 999px;
  background: var(--paper); color: var(--ink-2); font-size: 11.5px; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--hair); transition: color .2s, background-color .2s;
}
.wn-today:hover { color: var(--ink); background: var(--hair-2); }
[data-week="past"] .wn-range, [data-week="future"] .wn-range { color: var(--ink); }
.week-head {
  flex: none; display: grid; grid-template-columns: var(--ax) repeat(7, minmax(0, 1fr)) var(--ax);
  align-items: end; padding: 8px 0 7px; border-bottom: 1px solid var(--hair);
}
.wh-ax { padding-bottom: 4px; font-size: 10.5px; line-height: 1.2; text-align: center; color: var(--ink-4); transition: color .3s; }
.wh-ax.is-prim { color: var(--ink); font-weight: 650; }
.wh-day { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.wh-w { font-size: 10.5px; line-height: 1.2; color: var(--ink-3); }
.wh-zhou { display: none; }
.wh-d {
  display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 999px;
  font-size: 14px; font-weight: 650; line-height: 1; color: var(--ink);
}
.wh-day.is-today .wh-w { color: var(--now); font-weight: 600; }
.wh-day.is-today .wh-d { background: var(--now); color: #fff; }

.week-body {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: grid; grid-template-columns: var(--ax) minmax(0, 1fr) var(--ax);
  margin: 9px 0 10px;
}

/* 时间轴：左北京、右英国，同一行是同一时刻；主线那一侧的数字更深 */
.ax { position: relative; }
.tk {
  position: absolute; left: 0; right: 0; transform: translateY(-50%);
  font-size: 9.5px; line-height: 13px; text-align: center; white-space: nowrap; color: var(--ink-4);
}
.ax.is-prim .tk { color: var(--ink-2); font-weight: 650; }
.tk.tk-mid { left: 3px; right: 3px; border-radius: 6px; background: var(--hair-2); color: var(--ink-2); }
/* 作息：左轴是猪猪的夜里，右轴是兔兔的夜里；两边都没染色的行就是两人都醒着 */
.ax-night { position: absolute; left: 3px; right: 3px; border-radius: 9px; background: var(--night); }
.ax-moon { position: absolute; left: 0; right: 0; transform: translateY(-50%); display: grid; place-items: center; font-size: 11px; line-height: 1; color: var(--night-ink); }
.ax-moon .i { fill: currentColor; stroke: none; }
.now-pill {
  position: absolute; left: 1px; right: 1px; z-index: 3; transform: translateY(-50%);
  height: 18px; border-radius: 999px; background: var(--now); color: #fff;
  font-size: 9.5px; font-weight: 750; line-height: 18px; text-align: center; letter-spacing: -.02em;
}

.cols {
  position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--hair);
}
.lines { position: absolute; inset: 0; pointer-events: none; }
.lines i { position: absolute; left: 0; right: 0; border-top: 1px solid var(--hair-2); }
.lines i.l-mid { border-top: 1px dashed #CDC2BE; } /* 次要一侧的零点：那边在这一行换日 */
.col { position: relative; min-width: 0; cursor: pointer; }
.col + .col { border-left: 1px solid var(--rule); }

.past { position: absolute; left: 0; right: 0; top: 0; background: rgba(247, 243, 241, .72); pointer-events: none; }
.now-line { position: absolute; left: -1px; right: 0; z-index: 6; height: 2px; margin-top: -1px; background: var(--now); pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }
.now-trail { position: absolute; left: calc(100% / 7); right: 0; z-index: 1; border-top: 1px dashed rgba(232, 72, 63, .3); pointer-events: none; }

/* 日程卡：颜色=添加者；两人同时有事时猪猪在左、兔兔在右 */
.ev {
  position: absolute; z-index: 2;
  padding: 0; border: 1px solid; border-radius: var(--r-card);
  text-align: left;
}
.ev-box { display: block; width: 100%; height: 100%; overflow: hidden; border-radius: inherit; container-type: size; }
.ev-in { display: flex; flex-direction: column; gap: 1px; padding: 3px 6px; }
.ev-title {
  font-size: 12px; font-weight: 600; line-height: 1.3; word-break: break-all; text-wrap: pretty; /* 末行不只剩一个字 */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;
}
.ev-meta { display: flex; align-items: center; gap: 4px; font-size: 10.5px; line-height: 13px; white-space: nowrap; overflow: hidden; }
.ev-time { opacity: .85; }
.ev-time sup { font-size: 8px; margin-left: 1px; }
.ev-marks { display: inline-flex; gap: 2px; font-size: 11px; }
.ev-marks .i { stroke-width: 2; }

/* 卡片里放多少字，由卡片自己的大小决定：高度够才显示时间，标题按能完整放下的行数截断 */
@container (height < 36px) { .ev-meta { display: none; } .ev-in { padding-top: 2px; padding-bottom: 1px; } }
@container (height >= 52px) { .ev-title { -webkit-line-clamp: 2; } }
@container (height >= 67px) { .ev-title { -webkit-line-clamp: 3; } }
@container (height >= 83px) { .ev-title { -webkit-line-clamp: 4; } }
@container (width < 72px) { .ev-in { padding: 2px 4px; } .ev-marks, .ev-end { display: none; } }
/* 窄卡（手机上一列不到 44px）：只放标题，按字往下排，只露出完整的行；时间看两侧刻度 */
@container (width < 44px) {
  .ev-in { padding: 2px 3px; }
  .ev-meta { display: none; }
  .ev-title { display: block; font-size: 10px; line-height: 1.25; max-height: max(1lh, round(down, calc(100cqh - 4px), 1lh)); }
}
@container (width < 30px) { .ev-in { padding: 2px; } .ev-title { line-height: 1.15; } }

.tone-pig { --fill: var(--pig-fill); --line: var(--pig-line); --strong: var(--pig-strong); background: var(--fill); border-color: var(--line); color: var(--pig-ink); }
.tone-bunny { --fill: var(--bunny-fill); --line: var(--bunny-line); --strong: var(--bunny-strong); background: var(--fill); border-color: var(--line); color: var(--bunny-ink); }

.ev:hover { filter: saturate(1.15) brightness(.98); }
.ev.is-now { border-color: var(--strong); box-shadow: inset 0 0 0 1px var(--strong); }
.ev.is-now .ev-time::before {
  content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 4px 1px 0;
  border-radius: 50%; background: var(--strong); vertical-align: middle;
}
.ev.is-past { opacity: .45; }
.ev.is-off { background: var(--surface); border-style: dashed; }
.ev.is-off .ev-title { display: block; white-space: nowrap; text-overflow: ellipsis; } /* 行数截断的盒子里 Chrome 不画删除线 */
.ev-title s { text-decoration-thickness: 1px; }
.ev.clip-top { border-top-left-radius: 2px; border-top-right-radius: 2px; border-top-style: dashed; }
.ev.clip-bot { border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-bottom-style: dashed; }
.ev-dot { /* 新：对方加的或改过、你还没看的 */
  position: absolute; top: -3px; right: -3px; z-index: 3; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface);
}

/* 异形卡片：只在和别人重叠的那几段变窄。轮廓用 SVG 画，文字放在第一段够高的地方；
   外框之外的空白不接点击（点下去是在那里添加） */
.ev.is-shape { border: 0; background: none; box-shadow: none; pointer-events: none; }
.ev.is-shape .ev-box { position: absolute; pointer-events: auto; }
.ev-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ev-shape .sf { fill: var(--fill); pointer-events: auto; }
.ev-shape .ss, .ev-shape .sd { fill: none; stroke: var(--line); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ev-shape .sd { stroke-dasharray: 3 2; }
.ev.is-now .ev-shape .ss, .ev.is-now .ev-shape .sd { stroke: var(--strong); stroke-width: 2; }
.ev.is-off .ev-shape .sf { fill: var(--surface); }
.ev.is-off .ev-shape .ss { stroke-dasharray: 3 2; }
.ev.is-shape:focus-visible { outline: none; }
.ev.is-shape:focus-visible .ev-shape .ss, .ev.is-shape:focus-visible .ev-shape .sd { stroke: var(--ink); stroke-width: 2; }

/* 拖去取消：自己的卡片可以拖；拖着的那张跟着手指，原位置留一个淡影 */
.ev[data-mine] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.ev.is-lifted { opacity: .3; }
.ev.drag-ghost {
  position: fixed; z-index: 64; pointer-events: none; will-change: transform; transition: none; animation: none;
  box-shadow: 0 18px 34px -14px rgba(46, 38, 39, .5);
}
.ev.drag-ghost.is-shape { box-shadow: none; filter: drop-shadow(0 10px 14px rgba(46, 38, 39, .3)); }
.drag-ghost * { pointer-events: none !important; }

.ev.landed { z-index: 4; animation: landed .7s var(--ease); }
.ev.is-shape.landed { animation-name: landed-shape; }
@keyframes landed {
  0% { transform: scale(.9); box-shadow: 0 0 0 8px var(--me-soft); }
  100% { transform: none; box-shadow: 0 0 0 0 transparent; }
}
@keyframes landed-shape {
  0% { transform: scale(.95); filter: drop-shadow(0 0 6px var(--me-glow)); }
  100% { transform: none; filter: none; }
}

/* 鼠标停在空白处：提示点一下就在这里添加 */
.ghost {
  position: absolute; z-index: 1; width: calc(100% / 7 - 6px); margin-left: 3px; padding: 2px 6px;
  border: 1.5px dashed var(--me-line); border-radius: var(--r-card); background: var(--me-soft);
  color: var(--me-ink); font-size: 11px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden;
  pointer-events: none;
}

.empty {
  position: absolute; left: 50%; z-index: 7; transform: translate(-50%, -50%);
  width: min(300px, 82%); padding: 16px 18px; border-radius: 18px;
  background: rgba(255, 255, 255, .95); box-shadow: inset 0 0 0 1px var(--hair), 0 16px 34px -22px rgba(46, 38, 39, .45);
  font-size: 13.5px; line-height: 1.55; text-align: center; color: var(--ink-2); pointer-events: none;
}
.empty b { display: block; margin-bottom: 2px; font-size: 15px; color: var(--ink); }
.empty span { display: inline-block; } /* 在逗号处换行，不把“空白处”拆开 */

/* ───────── 弹层 ───────── */

dialog.sheet {
  width: min(520px, calc(100vw - 32px)); max-width: none; max-height: min(92dvh, 880px);
  padding: 0; border: 0; border-radius: var(--r-sheet);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px -24px rgba(46, 38, 39, .4);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .32s var(--ease); }
dialog.sheet::backdrop { background: rgba(46, 38, 39, .3); backdrop-filter: blur(2px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.sheet form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 6px 22px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-head [tabindex="-1"]:focus { outline: none; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 22px 10px; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 22px 20px; border-top: 1px solid var(--hair-2); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: var(--ink-2); font-size: 20px; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 20px; border-radius: var(--r-field); font-size: 15px; font-weight: 550; white-space: nowrap;
}
.btn-primary { background: var(--me-strong); color: #fff; }
.btn-ghost { background: var(--paper); color: var(--ink-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-quiet { color: var(--ink-2); padding: 0 12px; }
.btn-block { width: 100%; }
.foot-spacer { flex: 1; }
.foot-note { flex: 1; font-size: 13.5px; color: var(--ink-2); }

/* 表单 */
.f-title input {
  width: 100%; padding: 8px 0 10px; border: 0; border-bottom: 1.5px solid var(--hair); border-radius: 0;
  background: none; font-size: 20px; font-weight: 550; outline: none;
}
.f-title input::placeholder { color: var(--ink-4); font-weight: 400; }
.f-title input:focus { border-bottom: 2px solid var(--me-strong); padding-bottom: 9.5px; }
.f-group { display: block; margin-top: 18px; }
.f-label { display: block; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-3); }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper); }
.seg button { padding: 6px 14px; border-radius: 999px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-checked="true"], .seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: 0 1px 2px rgba(46, 38, 39, .14);
}
.seg-sm button { padding: 4px 10px; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 13px;
  border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
  font-size: 13.5px; color: var(--ink-2); white-space: nowrap;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--me-soft); color: var(--me-ink); box-shadow: inset 0 0 0 1.5px var(--me-strong); font-weight: 550; }
.chip-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.chip-quiet { box-shadow: none; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-4); }

.f-days { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.f-days .chip { flex-direction: column; gap: 0; height: 50px; min-width: 0; padding: 0 2px; border-radius: 16px; line-height: 1.2; }
.f-days .chip .num { font-size: 15px; font-weight: 650; }
.f-days .chip small { font-size: 11px; }
.f-other { position: relative; cursor: pointer; }
.f-other input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.f-other:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.f-other.is-on { background: var(--me-soft); color: var(--me-ink); box-shadow: inset 0 0 0 1.5px var(--me-strong); font-weight: 550; }

.f-times { display: flex; align-items: flex-end; gap: 10px; margin-top: 18px; }
.f-time { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.f-time input {
  height: 52px; padding: 0 12px; border: 0; border-radius: var(--r-field);
  background: var(--paper); font-family: var(--num); font-size: 22px; font-weight: 600; color: var(--ink);
}
.f-time input:focus { outline: 2px solid var(--me-strong); outline-offset: 0; }
.f-dash { padding-bottom: 12px; font-size: 20px; color: var(--ink-4); }
.f-next { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--me-soft); color: var(--me-ink); font-style: normal; font-size: 11px; }
.f-durs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.f-enddate { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.f-enddate input { height: 38px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--paper); font-size: 14px; }
.f-conv { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--paper); font-size: 13px; color: var(--ink-2); }
.f-conv b { font-weight: 600; color: var(--ink); }
.f-conv .warn { display: block; margin-top: 2px; color: var(--night-ink); }
.f-rep { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.f-until { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.f-until input { height: 36px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--paper); font-size: 14px; }
.f-until input:focus { outline: 2px solid var(--me-strong); outline-offset: 0; }
.f-hint { margin-top: 8px; font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }

.marks { display: flex; flex-wrap: wrap; gap: 6px; }
.marks .chip .i { font-size: 14px; }

.f-note textarea {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-field);
  background: var(--paper); font-size: 14px; line-height: 1.55; resize: vertical;
}
.f-note textarea:focus { outline: 2px solid var(--me-strong); outline-offset: 0; }
.form-err { min-height: 0; margin-top: 10px; font-size: 13.5px; color: var(--danger); }
.form-err:empty { display: none; }
/* 表单长、要滚动时，错误提示贴在底部按钮上方，光标跳去的那一栏和提示都看得见 */
.sheet-body > .form-err { position: sticky; bottom: -10px; margin: 10px -22px 0; padding: 9px 22px; background: var(--surface); }
.sheet-body :is(input, textarea, button) { scroll-margin-bottom: 52px; }

/* 详情 */
.det-who { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.det-who .ava { width: 26px; height: 26px; }
.det-who .tag-new { padding: 0 7px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; line-height: 18px; }
.det-title { margin-top: 4px; font-size: 22px; font-weight: 600; line-height: 1.35; }
.det-title.is-off { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--ink-2); }
.det-state { margin-top: 4px; font-size: 13.5px; color: var(--ink-2); }
.det-times { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--paper); }
.det-times dt { font-size: 13px; color: var(--ink-3); }
.det-times dd { font-size: 14.5px; color: var(--ink-2); }
.det-times .is-home { font-weight: 600; color: var(--ink); }
.det-repeat { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.det-repeat:empty { display: none; }
.det-repeat .i { font-size: 15px; }
.det-marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.det-marks:empty, .det-note:empty { display: none; }
.mark-pill { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 999px; font-size: 12.5px; }
.det-note { margin-top: 14px; font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; }
.det-meta { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }

/* 一周以后 */
.later-list { list-style: none; margin: 0; padding: 0 0 14px; }
.later-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 8px; border-radius: 14px; font-size: 14.5px; }
.later-list button:hover { background: var(--paper); }
.later-list .ava { width: 28px; height: 28px; }
.later-when { flex: none; min-width: 126px; color: var(--ink-2); font-size: 13px; }
.later-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.later-title .i { margin-right: 5px; font-size: 13px; vertical-align: -2px; color: var(--ink-3); }

/* 作息、修改密码：小弹层 */
.sheet-fields { display: flex; flex-direction: column; gap: 12px; padding-top: 10px; }
.sheet .field input { background: var(--paper); box-shadow: none; }
.fine-left { text-align: left; }

/* ───────── 登录 ───────── */

/* 登录前还不知道是谁，按钮和焦点框用中性色 */
.login { --me-strong: var(--ink); position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; overflow: auto; background: var(--paper); }
.login-inner { width: min(340px, 100%); }
.login-logo { display: block; width: 124px; height: 80px; margin: 0 auto; }
.login h1 { margin-top: 10px; font-size: 26px; font-weight: 650; letter-spacing: .14em; text-align: center; }
.login-lede { margin-top: 2px; color: var(--ink-3); font-size: 14px; text-align: center; }
.login-lede b { font-weight: 600; color: var(--ink-2); }
#loginForm { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.field input { height: 48px; padding: 0 14px; border: 0; border-radius: var(--r-field); background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); font-size: 16px; color: var(--ink); }
.field input:focus { outline: 2px solid var(--me-strong); outline-offset: 0; box-shadow: none; }
#loginForm .btn { margin-top: 6px; height: 48px; }
.fine { font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ───────── 提示 ───────── */

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 70;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: opacity .25s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action { padding-right: 7px; }
.toast.has-action.show { pointer-events: auto; }
.toast button { flex: none; height: 30px; padding: 0 13px; border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font-size: 13.5px; font-weight: 600; }
.toast button:hover { background: rgba(255, 255, 255, .26); }

/* 拖去取消的落点：拖起卡片时从下方浮上来，拖到上面变红；盖在拖着的卡片上面，字一直看得见 */
.drop {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 65;
  display: flex; align-items: center; gap: 9px; height: 54px; padding: 0 24px 0 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 16px 36px -14px rgba(46, 38, 39, .6);
  opacity: 0; transform: translate(-50%, 18px); pointer-events: none;
  transition: opacity .2s, transform .28s var(--ease), background-color .15s;
}
.drop .i { font-size: 21px; }
.drop.show { opacity: 1; transform: translate(-50%, 0); }
.drop.is-over { background: var(--danger); transform: translate(-50%, 0) scale(1.07); }

/* ───────── 尺寸适配 ───────── */

@media (max-width: 699px) {
  .add-btn { width: 36px; padding: 0; }
  .add-btn span { display: none; }
  .lb-long { display: none; }
  .lb-short { display: inline; }
  .week-nav { grid-template-columns: 34px minmax(0, 1fr) 34px; padding: 3px 4px 0; }
  .wn-arrow { width: 34px; height: 28px; }
  .wn-range { font-size: 12px; }
  .wn-today { height: 22px; padding: 0 8px; font-size: 11px; }
  .ev { border-radius: 5px; }
  .ev-title { font-size: 10.5px; line-height: 1.25; }
  .ev-meta { font-size: 9px; line-height: 11px; }
  dialog.sheet {
    width: 100%; max-height: 94dvh; margin: auto 0 0;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
}

@media (min-width: 700px) {
  :root { --ax: 52px; }
  dialog.sheet.sheet-sm { width: min(400px, calc(100vw - 32px)); }
  .app { padding: 0 20px 16px; }
  .top { gap: 8px 16px; padding: 10px 0 12px; }
  .brand { gap: 8px; font-size: 17px; }
  .logo { width: 56px; height: 36px; }

  .clock {
    grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "ava time meta" "ava time st";
    gap: 2px 12px; padding: 11px 22px 11px 14px;
  }
  .clock[data-zone="uk"] { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "meta time ava" "st time ava"; padding: 11px 14px 11px 22px; }
  .clock[aria-pressed="true"] { flex-grow: 1.15; }
  .clock-ava { width: 42px; height: 42px; }
  .clock-meta { flex-direction: row; align-items: baseline; gap: 8px; align-self: end; }
  .clock[data-zone="uk"] .clock-meta { justify-content: flex-end; }
  .cd-md { display: inline; }
  .clock-place { font-size: 13.5px; }
  .clock-date { font-size: 12.5px; }
  .clock-time { font-size: 30px; }
  .clock[aria-pressed="true"] .clock-time { font-size: 40px; font-weight: 300; }
  .clock-st { align-self: start; font-size: 13px; }
  .seam { flex-basis: 14px; }
  .swap { width: 40px; height: 40px; font-size: 19px; box-shadow: 0 0 0 5px var(--paper), inset 0 0 0 1px var(--hair); }

  .week-head { padding: 10px 0 8px; }
  .wh-ax { font-size: 12px; }
  .wh-zhou { display: inline; }
  .wh-w { font-size: 12px; }
  .wh-d { min-width: 28px; height: 28px; font-size: 16px; }
  .week-body { margin: 12px 0 14px; }
  .tk { font-size: 10.5px; }
  .ax-moon { font-size: 12px; }
  .now-pill { left: 5px; right: 5px; height: 20px; font-size: 11px; line-height: 20px; letter-spacing: 0; }
}

@media (min-width: 1180px) {
  .top { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand clocks actions"; gap: 0 28px; padding: 12px 0 14px; }
  .clocks { justify-self: center; width: 100%; max-width: 800px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
