/* ==========================================================================
   tool-pomodoro.css — 番茄时钟专属样式
   位置: assets/css/tool-pomodoro.css (仅 pages/tool-pomodoro.html 引入)

   依据: _private/番茄时钟.md + 四张原型图 (默认态/工作态/休息态/弹窗)

   ★ 版式 (照原型):
       .pm
         ├─ .pm-top    上: 三栏
         │    ├─ .pm-config  左「番茄钟类型」白卡片 (贴着内容, 不撑满整列)
         │    ├─ .pm-center  中「当前模式：60min-10min」(橙) + 淡环 + 红方块数字
         │    └─ .pm-ops     右 默认态=一颗红「开始计时」 / 工作休息态=操作小按钮
         └─ .pm-bottom 下「历史统计」「历史记录」两张白卡片, 各占整行

   ★ 三个状态的按钮:
       默认态 -> 右栏只有「开始计时」; 没有自动循环/最后一次; 环内不显示图标
       工作态 -> 暂停计时 · 提前结束本轮 · +5min · -5min (橙)
       休息态 -> 暂停计时 · 提前开始下一轮 · +5min · -5min (灰)

   ★ 只写"番茄时钟独有的"。框架 .tool-panel 自带 padding: 20px 24px,
     这里的留白是在它之内再加的。颜色用 :root 的设计变量 (见 common.css):
       --brand #F97C12 橙 / --brand-soft / --brand-dark
       --red #F0554B 红 / --green 绿
       --text --text-sub --text-muted --border --border-strong --surface --bg
       --radius --radius-sm --radius-lg --shadow-card
   ========================================================================== */

/* ★ 关键: 框架 .tool-panel 自带的内边距只有 20px 24px, 太贴边。
   这里在它**之内**再加一圈, 让内容离面板边框拉开距离 (总留白约 36px / 42px)。 */
.pm {
  padding: 16px 18px;

  /* 番茄钟类型的专属色 (原型: 标准番茄橙 / 半小时蓝 / 一节课绿) */
  --pm-blue:  #2E6BE6;
  --pm-green: #2F9E44;
}

/* ==========================================================================
   一、上下两个模块
   ========================================================================== */
.pm-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 28px;
  align-items: start;
}

/* 下: 数据区。原型里就是两张白卡片并排拉开, 没有分隔线 */
.pm-bottom {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 24px;
}

/* 白卡片 (配置 / 统计 / 记录 通用) */
.pm-block {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pm-block-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pm-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.pm-block-head .pm-block-title { margin: 0; }

/* ==========================================================================
   二、左: 番茄钟类型 (白卡片, 宽度贴着内容)
   ========================================================================== */
.pm-config {
  justify-self: start;              /* ★ 卡片跟着内容走, 不撑满整列 */
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pm-types {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.pm-type {
  display: inline-flex;
  align-items: center;
  gap: 10px;                        /* 说明紧贴按钮 */
  padding: 0;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* 按钮本体: 小圆角矩形, 白字; 颜色按 data-type 区分 */
.pm-type-name {
  min-width: 76px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: var(--brand);
  border: 1px solid transparent;
  border-radius: 6px;
  transition: box-shadow .15s, filter .15s;
}
.pm-type:hover .pm-type-name { filter: brightness(1.07); }

.pm-type[data-type="half"]  .pm-type-name { background: var(--pm-blue); }
.pm-type[data-type="class"] .pm-type-name { background: var(--pm-green); }
.pm-type[data-type="custom"] .pm-type-name {
  color: var(--text-sub);
  background: var(--surface);
  border-color: var(--border-strong);
}

/* 选中: 同色光晕 */
.pm-type.is-on .pm-type-name { box-shadow: 0 0 0 3px rgba(249, 124, 18, .28); }
.pm-type[data-type="half"].is-on  .pm-type-name { box-shadow: 0 0 0 3px rgba(46, 107, 230, .28); }
.pm-type[data-type="class"].is-on .pm-type-name { box-shadow: 0 0 0 3px rgba(47, 158, 68, .28); }
.pm-type[data-type="custom"].is-on .pm-type-name {
  color: var(--brand-dark);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(249, 124, 18, .20);
}

.pm-type-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* 自定义时长 (选中"自定义"时出现) */
.pm-custom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.pm-custom[hidden] { display: none; }
.pm-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pm-custom-label {
  flex: none;
  width: 56px;
  font-size: 12px;
  color: var(--text-sub);
}

/* ---------- 通用输入 ---------- */
.pm-input {
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s;
}
.pm-input:focus { border-color: var(--brand); }
.pm-input::placeholder { color: var(--text-muted); }
.pm-input-num { width: 104px; }
.pm-unit {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   三、中: 当前模式 + 圆环
   ========================================================================== */
.pm-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
/* 原型里"当前模式"是橙色 */
.pm-mode {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.pm-ring-wrap {
  position: relative;
  /* ★ 核心视觉: 计时圆环尽量做大, 但别超出一屏高度 */
  width: min(340px, 56vh);
  height: min(340px, 56vh);
}
.pm-ring {
  display: block;
  width: 100%;
  height: 100%;
}
.pm-ring circle {
  fill: none;
  stroke-width: 9;
}
/* 轨道 = 阶段色的淡色 (原型: 未开始是一圈淡红, 没有进度弧) */
.pm-ring-bg { stroke: rgba(240, 85, 75, .18); }
.pm[data-phase="work"]  .pm-ring-bg { stroke: rgba(249, 124, 18, .16); }
.pm[data-phase="break"] .pm-ring-bg { stroke: rgba(100, 116, 139, .16); }
/* 进度弧 = 从 0 逐渐填满 */
.pm-ring-fg {
  stroke: var(--red);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset .35s linear, stroke .25s;
}
.pm[data-phase="work"]  .pm-ring-fg { stroke: var(--brand); }
.pm[data-phase="break"] .pm-ring-fg { stroke: var(--text-muted); }

.pm-ring-inner {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ---------- 时间: 两个方块 + 冒号 (原型「60 : 60」) ---------- */
.pm-time {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pm-digit {
  min-width: 84px;
  padding: 14px 16px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  color: #fff;
  background: var(--red);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;   /* 等宽, 倒计时不抖 */
  transition: background .25s;
}
.pm-colon {
  font-size: 34px;
  font-weight: 700;
  color: var(--red);
  transition: color .25s;
}
.pm[data-phase="work"]  .pm-digit { background: var(--brand); }
.pm[data-phase="work"]  .pm-colon { color: var(--brand); }
.pm[data-phase="break"] .pm-digit { background: var(--text-sub); }
.pm[data-phase="break"] .pm-colon { color: var(--text-sub); }

.pm-icon {
  width: 30px;
  height: 30px;
  color: var(--text-muted);
  transition: color .25s;
}
.pm-icon svg { display: block; width: 100%; height: 100%; }

/* 自动循环 / 最后一次: 原型里默认态没有, 只在工作/休息态出现 */
/* 自动循环 / 最后一次: 原型 = 方角矩形 + 橙描边; 选中项橙实心 */
.pm-loop {
  display: flex;
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pm[data-phase="idle"] .pm-loop { display: none; }
.pm-loop-btn {
  flex: 1;
  padding: 9px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--brand);
  background: var(--surface);
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.pm-loop-btn:hover { background: var(--brand-soft); }
.pm-loop-btn.is-on {
  color: #fff;
  background: var(--brand);
  font-weight: 600;
}

/* ==========================================================================
   四、右: 默认态「开始计时」 / 工作休息态 操作小按钮
   ========================================================================== */
/* 右栏: 给一个固定宽, 按钮在里面才谈得上"左右居中" */
.pm-ops {
  display: flex;
  flex-direction: column;
  align-items: center;              /* ★ 按钮在本栏内左右居中 */
  justify-content: center;          /* ★ 上下居中 (跟圆环同一水平线) */
  align-self: center;
  width: 210px;
  gap: 10px;
}

/* 开始计时: 做大做宽, 在栏内上下左右居中 */
.pm-start-btn {
  width: 100%;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(240, 85, 75, .28);
  transition: background .25s, box-shadow .25s, opacity .15s;
}
.pm-start-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.pm-op {
  width: 100%;
  min-width: 116px;
  padding: 11px 16px;
  font-size: 13px;
  font-family: inherit;
  text-align: center;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.pm-op:hover { border-color: var(--brand); color: var(--brand); }

/* ★ 默认态: 右栏只有「开始计时」 */
.pm[data-phase="idle"] .pm-op { display: none; }
/* ★ 工作/休息态: 换成操作小按钮 */
.pm[data-phase="work"]  .pm-start-btn,
.pm[data-phase="break"] .pm-start-btn { display: none; }

/* 「提前结束本轮」只有工作态; 「提前开始下一轮」只有休息态 */
.pm-op-work,
.pm-op-break { display: none; }
.pm[data-phase="work"]  .pm-op-work  { display: block; }
.pm[data-phase="break"] .pm-op-break { display: block; }

/* 工作态: 操作按钮 = 橙色实心白字 (原型) */
.pm[data-phase="work"] .pm-op {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}
.pm[data-phase="work"] .pm-op:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

/* 休息态: 操作按钮 = 灰色实心白字 (原型) */
.pm[data-phase="break"] .pm-op {
  color: #fff;
  background: var(--text-muted);
  border-color: var(--text-muted);
}
.pm[data-phase="break"] .pm-op:hover {
  background: var(--text-sub);
  border-color: var(--text-sub);
  color: #fff;
}

/* ==========================================================================
   五、下: 数据区
   ========================================================================== */
.pm-select {
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}
.pm-select:focus { border-color: var(--brand); }

/* ---------- 统计: 三项横排 = 大图标 + 大数字 (原型: 数值染橙/绿/红) ---------- */
.pm-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 44px;
}
.pm-stat {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pm-stat-icon {
  flex: none;
  width: 38px;
  height: 38px;
  color: var(--text);          /* 已专注的时钟图标是深色 */
}
.pm-stat-icon svg { display: block; width: 100%; height: 100%; }
.pm-stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pm-stat-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pm-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* 已专注 = 橙 */
.pm-stat-focus .pm-stat-value { color: var(--brand); }
/* 完成次数 = 绿 (图标同色) */
.pm-stat-done .pm-stat-icon,
.pm-stat-done .pm-stat-value { color: var(--green); }
/* 中断次数 = 红 (图标同色) */
.pm-stat-stop .pm-stat-icon,
.pm-stat-stop .pm-stat-value { color: var(--red); }

/* 记录表 */
.pm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
.pm-table th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pm-table td {
  padding: 11px 16px;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
}
.pm-table tr:last-child td { border-bottom: none; }
.pm-empty {
  padding: 30px 16px !important;
  text-align: center;
  color: var(--text-muted);
}
.pm-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pm-more:hover { border-color: var(--brand); color: var(--brand); }

/* 小按钮 (隐藏内容) */
.pm-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pm-mini:hover { border-color: var(--brand); color: var(--brand); }
.pm-mini svg { width: 13px; height: 13px; }

/* ==========================================================================
   六、默认态: 环里只有数字, 不显示图标
   ========================================================================== */
.pm[data-phase="idle"] .pm-icon { display: none; }
/* 工作态图标 = 绿书本 */
.pm[data-phase="work"] .pm-icon { color: var(--green); }

/* ==========================================================================
   七、底部备注
   ========================================================================== */
.pm-note {
  margin: 20px 0 0;
  font-size: 12px;
  text-align: center;
  color: var(--text-muted);
}

/* ==========================================================================
   八、窄屏
   ========================================================================== */
@media (max-width: 1100px) {
  .pm-top { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .pm-config { justify-self: start; }
  .pm-center { order: -1; }          /* 窄屏把计时区放最前 */
  .pm-ops {
    width: auto;                 /* 窄屏右栏不再固定宽 */
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    align-self: stretch;
  }
  .pm-ops .pm-op,
  .pm-ops .pm-start-btn { width: auto; }
}
@media (max-width: 720px) {
  .pm-ring-wrap { width: min(250px, 50vh); height: min(250px, 50vh); }
  .pm-digit { min-width: 62px; padding: 10px 12px; font-size: 28px; }
  .pm-colon { font-size: 24px; }
  .pm-stats { flex-direction: column; align-items: flex-start; gap: 18px; }
}

/* ==========================================================================
   九、确认弹窗 (原型: ⚠ 图标 + 文案 + 取消 / 红色确定)
   ========================================================================== */
.pm-modal {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pm-modal[hidden] { display: none; }
.pm-modal-mask {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(15, 23, 42, .45);
}
.pm-dialog {
  position: relative;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
}
.pm-dialog-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 22px 6px;
}
.pm-dialog-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: 50%;
}
.pm-dialog-text {
  margin: 0;
  padding-top: 1px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.pm-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px 20px;
}
.pm-btn {
  padding: 9px 24px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.pm-btn-plain {
  color: var(--text-sub);
  background: var(--surface);
  border-color: var(--border-strong);
}
.pm-btn-plain:hover { border-color: var(--brand); color: var(--brand); }
.pm-btn-danger { color: #fff; background: var(--red); }
.pm-btn-danger:hover { background: #D8453C; }

/* ==========================================================================
   十、页面内提示 (通知权限未授予时的降级)
   ========================================================================== */
.pm-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  z-index: 90;
  padding: 12px 20px;
  font-size: 13px;
  color: #fff;
  background: rgba(15, 23, 42, .9);
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.pm-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   十一、计时中: 类型按钮 / 输入框 呈禁用态
   ========================================================================== */
.pm-type:disabled { cursor: not-allowed; opacity: .7; }
.pm-type:disabled::after { display: none; }
.pm-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }

/* ==========================================================================
   十二、编辑工作内容弹窗 (原型: 灰色标题条 + ✕ + 输入区 + 取消/橙色保存)
   ========================================================================== */
.pm-edit {
  position: relative;
  width: 520px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .22);
  overflow: hidden;
}
.pm-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pm-edit-title { font-size: 14px; font-weight: 600; color: var(--text); }
.pm-edit-x {
  width: 26px;
  height: 26px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pm-edit-x:hover { color: var(--text); background: var(--border); }
.pm-edit-body { padding: 18px 16px 4px; }
.pm-edit-text {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  resize: vertical;
}
.pm-edit-text:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.pm-edit-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px 18px;
}
.pm-btn-brand { color: #fff; background: var(--brand); }
.pm-btn-brand:hover { filter: brightness(.95); }

/* ==========================================================================
   十三、历史记录表: 内容列 / 操作列链接
   ========================================================================== */
/* 列宽策略: 除"工作内容"外的列都收窄到刚好显示全 (width:1% + nowrap),
   省下的宽度全部让给内容列 -> 内容列尽量宽, 超长才截断 */
.pm-table th:not(.pm-cell-content),
.pm-table td:not(.pm-cell-content) {
  width: 1%;
  white-space: nowrap;
}
.pm-table td:not(.pm-cell-content) { vertical-align: middle; }

/* 数据区顶部的小字说明 (登录后才会保存记录) */
.pm-tip {
  grid-column: 1 / -1;      /* .pm-bottom 是网格时, 这行独占整行, 不挤占卡片格 */
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-sub);
}

.pm-cell-content {
  width: auto;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-sub);
}
.pm-cell-act { white-space: nowrap; }
.pm-link {
  padding: 0;
  margin-right: 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--brand);
  background: none;
  border: 0;
  cursor: pointer;
}
.pm-link:hover { text-decoration: underline; }
.pm-link.is-danger { color: var(--red); margin-right: 0; }
