* {
    margin: 0;
    font-style: normal;
    outline: none;
}

/* 画布底色：预览时的纯色垫底（默认纯白，菜单里可改）。
   导入带透明通道的背景图时，透明区域显示的就是这个颜色，不会再发黑。
   导出透明 PNG / SVG 时会临时置为 transparent，成品始终透明。 */
:root {
    --canvas-color: #ffffff;
}

html,
body {
    background-color: var(--canvas-color);
}

@font-face {
    font-family: 'DIN 1451 LT W06 Mittelschrift';
    font-style: normal;
    font-weight: 100;
    src: url(../font/Mittelschrift.otf)
}

@font-face {
    font-family: '字魂59号-创粗黑';
    font-style: normal;
    font-weight: 100;
    src: url(../font/字魂59号-创粗黑.ttf)
}

div#app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.app-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 画布底色铺在这一层：背景图的透明区漏出的就是它 */
    background-color: var(--canvas-color);
}

/* ===== 背景图层 ===== */
.app-stage-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center;
    /* 舞台盒子的宽高比 = 原图宽高比，故 100% 100% 不会拉伸变形 */
    background-size: 100% 100%;
    display: none;
}

/* 导出瞬间剥离画布底色与外圈投影：透明 PNG / SVG 都不能带上底色 */
body.exporting .app-stage {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* 有背景图时：舞台按原图比例铺满视口，文字区域可整体拖动 */
.app-stage.has-bg {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    /* 底色与页面同色时，用一圈中性灰 ring + 外阴影标出成片边界 */
    box-shadow: 0 0 0 1px rgba(128, 128, 128, 0.58), 0 24px 64px rgba(0, 0, 0, 0.3);
}

.app-stage.has-bg .app-stage-bg {
    display: block;
}

/* 铺满：舞台框 = 视口，图片等比放大到覆盖整个框，居中裁掉溢出部分（不变形）。
   完整显示时舞台框本身就等于图片比例，故 100% 100% 也不会变形。 */
.app-stage.fit-cover .app-stage-bg {
    background-size: cover;
}

.app-stage.has-bg .app-stage-role {
    cursor: move;
    touch-action: none;
}

.app-stage.has-bg .app-stage-role.dragging {
    cursor: grabbing;
}

.app-stage-role {
    position: relative;
    display: flex;
    flex-direction: column;
    font-size: 200%;
    user-select: none;
}

/* 天/时/分 格式内容更宽，整体略缩一档，保证单屏不溢出（各锚点由 JS 按实测重算） */
.app-stage-role.fmt-long {
    font-size: 140%;
}

/* 一根贯通的红竖条：左缘对齐「耗时」(160px)，自「耗时」顶边一路连到英文块底边(bottom:0) */
.app-stage-bar {
    position: absolute;
    left: 160px;
    top: 38px;
    bottom: 0;
    width: 5px;
    background: #e91c00;
}

.app-stage-role-top {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
}

/* 左列宽度 = 标题自然宽度（JS 实测写入）。标题与「耗时」各自以右缘锚定在列右沿，
   文字变长时向左生长(往前跑)，绝不反向压到时间数字上。
   宽度只在载入时定一次，之后编辑标题不会推动右侧时间，避免「改标题导致数字错位」。 */
.app-stage-role-top-left {
    position: relative;
    width: 224px;
}

.app-stage-role-top-left-left {
    position: relative;
    height: 1.2em;
}

/* 「耗时」：右缘钉在列右沿，超出则向左生长 */
.app-stage-role-top-left-left .t2 {
    position: absolute;
    top: 0;
    right: 0;
    white-space: nowrap;
    padding-left: 10px;
    font-family: '字魂59号-创粗黑';
}

/* 标题：外层仅占位(预留一行高度)，内层 .t 绝对定位、右缘钉在列右沿，
   文字变长时向左生长(往前跑)，不挤压也不重叠时间数字 */
.app-stage-role-top-left-top {
    position: relative;
    height: 1.2em;
}

.app-stage-role-top-left-top .t {
    position: absolute;
    top: 0;
    right: 0;
    white-space: nowrap;
    font-family: '字魂59号-创粗黑';
}

/* ===== 时间区（两种格式共用一套数字 / 单位样式） ===== */
.app-stage-role-top-time {
    display: flex;
    align-items: flex-end;
}

.time-group {
    display: flex;
    align-items: flex-end;
    white-space: nowrap;
}

/* 数字：沿用原「35」的样式（DIN / 200% / 信号红） */
.time-group .num {
    font-family: "DIN 1451 LT W06 Mittelschrift";
    font-size: 200%;
    line-height: 100%;
    margin: 0 8px;
    color: #e91c00;
}

/* 单位（分钟 / 天时秒）：中文字体，与数字底部对齐 */
.time-group .unit {
    font-family: '字魂59号-创粗黑';
    white-space: nowrap;
}

/* 天时分钟格式：数字紧贴自己的单位，组与组之间留出呼吸，
   读起来是「1天 2时 30分」而不是散开的「1 天 2 时 30 分」 */
.app-stage-role.fmt-long .time-group .num {
    margin: 0 1px;
}

.app-stage-role.fmt-long .time-group .num:first-child {
    margin-left: 4px;
}

.app-stage-role.fmt-long .time-group .unit+.num {
    margin-left: 7px;
}

/* 英文块：左缩进 = 红竖条左缘 + 竖条宽 + 8（JS 按实测写入）。
   字体族带上中文兜底，天/时/分 格式里的中文单位才不会掉回系统字体。 */
.app-stage-role-bottom {
    margin-left: 173px;
    padding-left: 0;
    font-family: "DIN 1451 LT W06 Mittelschrift", '字魂59号-创粗黑';
    font-size: 50%;
    text-transform: uppercase;
}

/* 英文标题不做任何长度限制与自动换行：一行到底，换行位置完全由手动回车决定。
   pre 保留 <br> / \n 的换行，同时禁止按宽度折行（超长时就往右延伸，不再拆行）。 */
.app-stage-role-bottom-top {
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    line-height: 1.25;
}

/* 英文块在两种格式下大小一致（50%）；切格式只改时间写法，不缩放整块 */

/* 第二行：SPENT + 时间 */
.app-stage-role-bottom-bottom {
    margin-top: 0.35em;
    display: flex;
    align-items: baseline;
    gap: 0.5em;
}

.app-stage-role-bottom-bottom .lead-label {
    flex: 0 0 auto;
}

/* 英文块里的时间组：**只沿用上面的字体**（DIN，不带中文字体兜底），
   字号与颜色跟这一行的英文完全一致 —— 不放大、不染红 */
.app-stage-role .app-stage-role-bottom .time-group {
    display: flex;
    align-items: baseline;
}

.app-stage-role .app-stage-role-bottom .time-group .num {
    font-family: "DIN 1451 LT W06 Mittelschrift";
    font-size: 100%;
    line-height: 100%;
    color: inherit;
    margin: 0 1px;
}

.app-stage-role .app-stage-role-bottom .time-group .num:first-child {
    margin-left: 0;
}

.app-stage-role .app-stage-role-bottom .time-group .unit+.num {
    margin-left: 0.55em;      /* 组与组之间明显拉开，和「数字+单位」的内部间距形成层级 */
}

.app-stage-role .app-stage-role-bottom .time-group .unit {
    font-family: "DIN 1451 LT W06 Mittelschrift";
    line-height: 100%;
    margin-left: 0.2em;       /* 与自己的数字留一点缝，读作「1D」而不是「1 D」 */
}

/* ===== 格式切换：非当前格式整块隐藏 ===== */
.fmt-off {
    display: none !important;
}

/* ===== 文案可编辑 ===== */
.editable {
    cursor: text;
}

.editable:hover {
    outline: 1px dashed rgba(233, 28, 0, 0.6);
    outline-offset: 2px;
}

/* 导出瞬间隐藏编辑态轮廓，保证导出图干净 */
body.exporting .editable {
    outline: none !important;
}

/* ===== 操作提示 ===== */
.export-hint {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 998;
}

.export-hint.show {
    opacity: 1;
}

/* ===== 右键 / 长按菜单 ===== */
.ctx-menu {
    position: fixed;
    z-index: 1000;
    /* 固定宽度：定位时才能准确夹取到视口内，避免窄屏溢出被截断 */
    width: 244px;
    max-width: calc(100vw - 16px);
    /* 菜单项变多后，矮屏也不至于顶出视口 */
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ctx-menu[hidden] {
    display: none !important;
}

.ctx-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #18191c;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s ease;
}

.ctx-item:hover {
    background: #f4f4f5;
}

.ctx-item.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.ctx-sub {
    font-size: 11px;
    color: #9a9aa0;
    white-space: nowrap;
}

.ctx-sep {
    height: 1px;
    margin: 5px 8px;
    background: #eee;
}

.ctx-check {
    justify-content: flex-start;
    gap: 9px;
}

.ctx-check input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #e91c00;
    cursor: pointer;
}

.ctx-check input:disabled {
    cursor: not-allowed;
}

/* 文字大小步进器 */
.ctx-zoom {
    justify-content: space-between;
    cursor: default;
}

.ctx-zoom:hover {
    background: transparent;
}

.zoom-ctl {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.zoom-ctl b {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: #f2f2f3;
    color: #18191c;
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease;
}

.zoom-ctl b:hover {
    background: #e4e4e6;
}

.zoom-ctl i {
    min-width: 40px;
    text-align: center;
    font-style: normal;
    font-size: 11px;
    color: #6b6b70;
    font-variant-numeric: tabular-nums;
}

/* 画布底色 */
.ctx-color {
    justify-content: space-between;
    cursor: pointer;
}

.color-ctl {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.color-hex {
    min-width: 56px;
    text-align: right;
    font-size: 11px;
    color: #9a9aa0;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

/* 原生取色器：保持可渲染（display:none 时部分浏览器不弹窗），但不可见、不可点 */
.color-input-native {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* 常用底色快捷块 */
.ctx-swatches {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 10px 7px;
}

.ctx-swatches b {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ctx-swatches b:hover {
    transform: translateY(-1px);
}

.ctx-swatches b.on {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 0 0 2px #e91c00;
}

.ctx-note {
    padding: 2px 10px 5px;
    font-size: 11px;
    line-height: 1.5;
    color: #9a9aa0;
    white-space: normal;
    word-break: break-word;
}

/* ===== 预览遮罩 ===== */
.preview-mask {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.82);
}

.preview-mask[hidden] {
    display: none !important;
}

.preview-mask img {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 12px 44px rgba(0, 0, 0, 0.55);
    background-color: #fff;
    /* 透明区用棋盘格衬底，方便看清哪里是透明的 */
    background-image:
        linear-gradient(45deg, #dcdcdc 25%, transparent 25%),
        linear-gradient(-45deg, #dcdcdc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dcdcdc 75%),
        linear-gradient(-45deg, transparent 75%, #dcdcdc 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.preview-tip {
    position: absolute;
    left: 0;
    right: 0;
    top: 16px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
