/**
 * 番茄钟组件样式
 *   - 桌面卡片（2×2 / 4×2 共用）：暖杏番茄色系固定铺底 + 四角呼吸光晕；
 *     模式色 --pm-color 由 JS 注入（专注红 / 短休绿 / 长休蓝），只着色进度环与按钮，
 *     整卡底色不随模式变化，保持稳定的视觉基调。
 *   - 1×1 mini：48×48 实时计时环 + 同色暖底，由 mountIcon 驱动刷新；
 *   - 2×2：纵向紧凑布局；4×2：横向布局（进度环在左，信息 / 操作在右）。
 *   - 详情面板（appBox）：左侧计时主区 + 右侧统计 / 设置 / 记录，宽屏两栏、窄屏堆叠。
 * ============================================================ */
/* SPA 主容器类名：halotab-widget halotab-widget-pomodoro（无需额外样式） */

/* ============================================================
 * 桌面卡片
 * ============================================================ */
.halotab-widget-pomo {
  --pm-color: #ef4444;
  --pm-bg-base: linear-gradient(135deg, #fff7f0 0%, #ffede0 55%, #ffe4d6 100%);
  --pm-glow-1: radial-gradient(110% 75% at 0% 0%,   rgba(239, 68, 68, .14) 0%, transparent 58%);
  --pm-glow-2: radial-gradient(95% 75% at 100% 100%, rgba(249, 115, 22, .11) 0%, transparent 60%);
  --pm-deco: rgba(180, 105, 85, .40);
  --pm-track: rgba(180, 105, 85, .14);
  --pm-text: #3b231d;
  --pm-text-soft: #8b6b60;

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  padding: 10px 12px;
  box-sizing: border-box;
  background: var(--pm-glow-1), var(--pm-glow-2), var(--pm-bg-base);
  color: var(--pm-text);
  border-radius: inherit;
  cursor: pointer;
  overflow: hidden;
}

.halotab-widget-pomo-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--pm-deco);
  z-index: 0;
}
.halotab-widget-pomo-bg svg { width: 100%; height: 100%; display: block; }
.halotab-widget-pomo-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: transparent;
  z-index: 1;
}

.halotab-widget-pomo-badge,
.halotab-widget-pomo-ring,
.halotab-widget-pomo-info,
.halotab-widget-pomo-mode,
.halotab-widget-pomo-task,
.halotab-widget-pomo-controls { position: relative; z-index: 2; }

.halotab-widget-pomo-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
}

.halotab-widget-pomo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  font-size: clamp(9px, 2.6cqi, 11px);
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.4;
  color: #b45309;
  background: rgba(239, 68, 68, .10);
  border: 1px solid rgba(239, 68, 68, .22);
  border-radius: 999px;
}

.halotab-widget-pomo-ring {
  position: relative;
  width: clamp(76px, 26cqi, 112px);
  height: clamp(76px, 26cqi, 112px);
  flex: 0 0 auto;
}
.halotab-widget-pomo-ring svg { width: 100%; height: 100%; display: block; }
.halotab-widget-pomo-track { stroke: var(--pm-track); }
.halotab-widget-pomo-bar {
  stroke: var(--pm-color);
  transition: stroke-dashoffset .45s linear, stroke .25s;
}
.halotab-widget-pomo-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(17px, 7cqi, 28px);
  font-weight: 800;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  color: var(--pm-text);
}
.halotab-widget-pomo[data-running="true"] .halotab-widget-pomo-time { color: var(--pm-color); }

.halotab-widget-pomo-mode {
  font-size: clamp(11px, 3.3cqi, 14px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--pm-color);
}
.halotab-widget-pomo-task {
  display: block;
  max-width: 100%;
  font-size: clamp(10px, 2.8cqi, 12px);
  color: var(--pm-text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.halotab-widget-pomo-cycle {
  display: none;
  font-size: 11px;
  color: var(--pm-text-soft);
  opacity: .85;
}

.halotab-widget-pomo-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.halotab-widget-pomo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(180, 105, 85, .22);
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  color: var(--pm-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: filter .15s, background .15s, transform .1s;
}
.halotab-widget-pomo-btn:hover { background: #fff; filter: brightness(1.02); }
.halotab-widget-pomo-btn:active { transform: scale(.94); }
.halotab-widget-pomo-toggle {
  min-width: 34px;
  border-color: transparent;
  background: var(--pm-color);
  color: #fff;
}
.halotab-widget-pomo-toggle:hover { background: var(--pm-color); filter: brightness(1.08); }

/* ------------------------------------------------------------
 * 2×2（164×201）：纵向紧凑布局，隐藏徽章，给进度环留足空间
 * ------------------------------------------------------------ */
.halotab-card[data-size="2x2"] .halotab-widget-pomo { gap: 4px; padding: 8px 10px; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-badge { display: none; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-ring { width: 84px; height: 84px; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-time { font-size: 19px; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-info { gap: 2px; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-task {
  max-width: 92%;
  font-size: 10px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
.halotab-card[data-size="2x2"] .halotab-widget-pomo-btn { min-width: 26px; height: 23px; font-size: 11px; }
.halotab-card[data-size="2x2"] .halotab-widget-pomo-toggle { min-width: 30px; }

/* ------------------------------------------------------------
 * 4×2（358×201）：横向布局 —— 进度环在左，信息 / 轮次 / 操作在右
 * ------------------------------------------------------------ */
.halotab-card[data-size="4x2"] .halotab-widget-pomo {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 22px;
  padding: 10px 20px;
  text-align: left;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-badge {
  position: absolute;
  top: 10px;
  left: 18px;
  z-index: 3;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-ring {
  width: 118px;
  height: 118px;
  margin-top: 8px;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-time { font-size: 27px; }
.halotab-card[data-size="4x2"] .halotab-widget-pomo-info {
  flex: 1 1 auto;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-mode { font-size: 16px; }
.halotab-card[data-size="4x2"] .halotab-widget-pomo-task {
  display: block;
  max-width: 100%;
  font-size: 12px;
  white-space: nowrap;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-cycle { display: block; }
.halotab-card[data-size="4x2"] .halotab-widget-pomo-controls {
  flex: 0 0 auto;
  margin: 8px 0 0;
}
.halotab-card[data-size="4x2"] .halotab-widget-pomo-btn { min-width: 34px; height: 28px; font-size: 12px; }

/* ------------------------------------------------------------
 * 1×1（67×80，图标槽 48×48）：实时倒计时环 + 同色暖底
 * ------------------------------------------------------------ */
.halotab-widget-pomodoro.halotab-widget-mini {
  background: linear-gradient(135deg, #fff7f0 0%, #ffede0 55%, #ffe4d6 100%) !important;
  color: #3b231d;
}
.ht-pomo-mini {
  --pm-color: #ef4444;
  --pm-track: rgba(180, 105, 85, .16);
  --pm-text: #3b231d;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}
.ht-pomo-mini-ring { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ht-pomo-mini-track { stroke: var(--pm-track); }
.ht-pomo-mini-bar {
  stroke: var(--pm-color);
  transition: stroke-dashoffset .45s linear, stroke .25s;
}
.ht-pomo-mini-time {
  position: relative;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--pm-text);
}
.ht-pomo-mini[data-running="true"] .ht-pomo-mini-time { color: var(--pm-color); }

/* 暗色卡片 */
html[data-theme="dark"] .halotab-widget-pomo,
html[data-theme="auto"] .halotab-widget-pomo {
  --pm-bg-base: linear-gradient(135deg, #1c1310 0%, #150e0c 55%, #100b09 100%);
  --pm-glow-1: radial-gradient(110% 75% at 0% 0%,   rgba(239, 68, 68, .12) 0%, transparent 58%);
  --pm-glow-2: radial-gradient(95% 75% at 100% 100%, rgba(249, 115, 22, .09) 0%, transparent 60%);
  --pm-deco: rgba(239, 68, 68, .26);
  --pm-track: rgba(255, 255, 255, .10);
  --pm-text: #f5eee9;
  --pm-text-soft: #a8887c;
  color: var(--pm-text);
}
html[data-theme="dark"] .halotab-widget-pomo-badge,
html[data-theme="auto"] .halotab-widget-pomo-badge {
  color: #fca5a5;
  background: rgba(239, 68, 68, .14);
  border-color: rgba(239, 68, 68, .30);
}
html[data-theme="dark"] .halotab-widget-pomo-btn,
html[data-theme="auto"] .halotab-widget-pomo-btn {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .14);
  color: #f5eee9;
}
html[data-theme="dark"] .halotab-widget-pomo-toggle,
html[data-theme="auto"] .halotab-widget-pomo-toggle {
  background: var(--pm-color);
  border-color: transparent;
  color: #fff;
}
/* 1×1 mini 暗色 */
html[data-theme="dark"] .halotab-widget-pomodoro.halotab-widget-mini,
html[data-theme="auto"] .halotab-widget-pomodoro.halotab-widget-mini {
  background: linear-gradient(135deg, #1c1310 0%, #150e0c 55%, #100b09 100%) !important;
  color: #f5eee9;
}
html[data-theme="dark"] .ht-pomo-mini,
html[data-theme="auto"] .ht-pomo-mini {
  --pm-track: rgba(255, 255, 255, .12);
  --pm-text: #f5eee9;
}

/* ============================================================
 * 详情面板
 * ============================================================ */
.ht-appbox-body[data-key="pomodoro"] { padding: 0; height: 100%; }

.ht-pomo-app {
  --pm-color: #ef4444;
  --pm-text: #3b231d;
  --pm-text-soft: #8b6b60;
  --pm-card-bg: rgba(255, 250, 246, .84);
  --pm-border: rgba(180, 105, 85, .16);
  --pm-track: rgba(180, 105, 85, .13);
  --pm-bg-base: linear-gradient(135deg, #fff7f0 0%, #ffede0 55%, #ffe4d6 100%);
  --pm-glow-1: radial-gradient(110% 75% at 0% 0%,   rgba(239, 68, 68, .13) 0%, transparent 58%);
  --pm-glow-2: radial-gradient(95% 75% at 100% 100%, rgba(249, 115, 22, .10) 0%, transparent 60%);
  --pm-deco: rgba(180, 105, 85, .38);

  position: relative;
  display: grid;
  grid-template-columns: 1fr 320px;
  width: 100%;
  height: 100%;
  background: var(--pm-glow-1), var(--pm-glow-2), var(--pm-bg-base);
  color: var(--pm-text);
  font-size: 14px;
  overflow: hidden;
}
.ht-pomo-app-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--pm-deco);
  z-index: 0;
}
.ht-pomo-app-bg svg { width: 100%; height: 100%; display: block; }
.ht-pomo-app > .ht-pomo-main,
.ht-pomo-app > .ht-pomo-side { position: relative; z-index: 1; }

/* ---------- 左侧计时主区 ---------- */
.ht-pomo-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 20px 24px 16px;
}
.ht-pomo-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--pm-card-bg);
  border: 1px solid var(--pm-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex: 0 0 auto;
}
.ht-pomo-mode-tab {
  min-width: 76px;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pm-text-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.ht-pomo-mode-tab:hover { color: var(--pm-text); }
.ht-pomo-mode-tab.is-active {
  color: #fff;
  background: var(--pm-color);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--pm-color) 32%, transparent);
}

.ht-pomo-stage {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.ht-pomo-ring {
  position: relative;
  width: clamp(210px, 40vh, 300px);
  height: clamp(210px, 40vh, 300px);
  flex: 0 0 auto;
}
.ht-pomo-ring svg { width: 100%; height: 100%; display: block; }
.ht-pomo-ring-track { stroke: var(--pm-track); }
.ht-pomo-ring-bar {
  stroke: var(--pm-color);
  transition: stroke-dashoffset .45s linear, stroke .25s;
}
.ht-pomo-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.ht-pomo-time {
  font-size: clamp(44px, 9vh, 68px);
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--pm-text);
}
.ht-pomo-app[data-running="true"] .ht-pomo-time { color: var(--pm-color); }
.ht-pomo-mode-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--pm-color);
  letter-spacing: 1px;
}
.ht-pomo-cycle {
  font-size: 11px;
  color: var(--pm-text-soft);
}

.ht-pomo-task-row { width: min(420px, 100%); }
.ht-pomo-task-input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  box-sizing: border-box;
  border: 1px solid var(--pm-border);
  border-radius: 10px;
  background: var(--pm-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--pm-text);
  font-size: 13px;
  font-family: inherit;
  text-align: center;
}
.ht-pomo-task-input::placeholder { color: var(--pm-text-soft); }
.ht-pomo-task-input:focus {
  outline: none;
  border-color: var(--pm-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pm-color) 18%, transparent);
}

.ht-pomo-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ht-pomo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  height: 38px;
  padding: 0 18px;
  border: 1px solid var(--pm-border);
  border-radius: 9px;
  background: var(--pm-card-bg);
  color: var(--pm-text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter .15s, background .15s, transform .1s;
}
.ht-pomo-btn:hover { filter: brightness(1.02); }
.ht-pomo-btn:active { transform: scale(.97); }
.ht-pomo-btn-ghost:hover { background: color-mix(in srgb, var(--pm-color) 9%, var(--pm-card-bg)); }
.ht-pomo-btn-primary {
  min-width: 116px;
  border-color: transparent;
  background: var(--pm-color);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--pm-color) 28%, transparent);
}
.ht-pomo-btn-primary:hover { filter: brightness(1.08); }
.ht-pomo-btn-sm { min-width: 0; height: 32px; padding: 0 14px; font-size: 12px; }
.ht-pomo-tip {
  font-size: 11px;
  color: var(--pm-text-soft);
  opacity: .85;
}

/* ---------- 右侧栏 ---------- */
.ht-pomo-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--pm-border);
  background: var(--pm-card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: auto;
}
.ht-pomo-side-block {
  padding: 16px 18px;
  border-bottom: 1px solid var(--pm-border);
  flex: 0 0 auto;
}
.ht-pomo-side-block-grow { flex: 1 1 auto; border-bottom: 0; min-height: 0; }
.ht-pomo-side-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--pm-text);
  letter-spacing: .3px;
}

.ht-pomo-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ht-pomo-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--pm-color) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--pm-color) 16%, transparent);
}
.ht-pomo-stat-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--pm-color);
  font-variant-numeric: tabular-nums;
}
.ht-pomo-stat-label { font-size: 11px; color: var(--pm-text-soft); }

/* 设置 */
.ht-pomo-settings { display: flex; flex-direction: column; gap: 8px; }
.ht-pomo-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--pm-text-soft);
}
.ht-pomo-setting-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--pm-text);
  white-space: nowrap;
}
.ht-pomo-setting-field input {
  width: 52px;
  height: 28px;
  padding: 0 6px;
  box-sizing: border-box;
  border: 1px solid var(--pm-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, .6);
  color: var(--pm-text);
  font-size: 12px;
  font-family: inherit;
  text-align: center;
}
.ht-pomo-setting-field input:focus {
  outline: none;
  border-color: var(--pm-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--pm-color) 16%, transparent);
}
.ht-pomo-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--pm-text);
  cursor: pointer;
  user-select: none;
}
.ht-pomo-check input { margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--pm-color); }
.ht-pomo-settings-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
.ht-pomo-settings-tip { font-size: 11px; color: #16a34a; font-weight: 600; }

/* 今日记录 */
.ht-pomo-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ht-pomo-history-empty {
  padding: 18px 8px;
  font-size: 12px;
  color: var(--pm-text-soft);
  text-align: center;
}
.ht-pomo-history-item {
  --pm-item-color: #ef4444;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--pm-item-color) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--pm-item-color) 14%, transparent);
}
.ht-pomo-history-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pm-item-color);
  flex: 0 0 auto;
}
.ht-pomo-history-name {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--pm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ht-pomo-history-meta {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--pm-text-soft);
}

/* ---------- 暗色详情面板 ---------- */
html[data-theme="dark"] .ht-pomo-app,
html[data-theme="auto"] .ht-pomo-app {
  --pm-text: #f5eee9;
  --pm-text-soft: #a8887c;
  --pm-card-bg: rgba(30, 22, 19, .76);
  --pm-border: rgba(255, 255, 255, .12);
  --pm-track: rgba(255, 255, 255, .10);
  --pm-bg-base: linear-gradient(135deg, #1c1310 0%, #150e0c 55%, #100b09 100%);
  --pm-glow-1: radial-gradient(110% 75% at 0% 0%,   rgba(239, 68, 68, .11) 0%, transparent 58%);
  --pm-glow-2: radial-gradient(95% 75% at 100% 100%, rgba(249, 115, 22, .08) 0%, transparent 60%);
  --pm-deco: rgba(239, 68, 68, .24);
}
html[data-theme="dark"] .ht-pomo-task-input,
html[data-theme="dark"] .ht-pomo-setting-field input,
html[data-theme="auto"] .ht-pomo-task-input,
html[data-theme="auto"] .ht-pomo-setting-field input {
  background: rgba(255, 255, 255, .06);
  color: #f5eee9;
}
html[data-theme="dark"] .ht-pomo-btn-ghost:hover,
html[data-theme="auto"] .ht-pomo-btn-ghost:hover { background: rgba(255, 255, 255, .08); }

/* ---------- 窄屏：右侧栏移到下方 ---------- */
@media (max-width: 720px) {
  .ht-pomo-app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .ht-pomo-side {
    border-left: 0;
    border-top: 1px solid var(--pm-border);
    max-height: 42%;
  }
  .ht-pomo-main { padding: 14px 16px 10px; }
  .ht-pomo-ring { width: clamp(180px, 32vh, 240px); height: clamp(180px, 32vh, 240px); }
  .ht-pomo-time { font-size: clamp(38px, 7vh, 56px); }
  .ht-pomo-stage { gap: 10px; }
}
