/* ============================================
   Math Clock - 数学极客表盘 (v2)
   ============================================ */

/* ---------- CSS Variables / Themes ---------- */
:root {
  --clock-size: min(72vmin, 480px);
  --transition-speed: 0.3s;
}

/* 主题：学术黑板风（默认） */
[data-theme="chalkboard"] {
  --bg-primary: #2b4a3e;
  --bg-secondary: #1e3a2e;
  --bg-clock: #2d5a46;
  --border-clock: rgba(255, 255, 255, 0.12);
  --text-primary: #f0ece2;
  --text-secondary: #c8c2b4;
  --accent: #f7d794;
  --accent-glow: rgba(247, 215, 148, 0.4);
  --hand-hour: #f0ece2;
  --hand-minute: #d4cfc2;
  --hand-second: #e8a87c;
  --tooltip-bg: rgba(20, 50, 38, 0.92);
  --tooltip-border: rgba(255, 255, 255, 0.15);
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-hover: rgba(255, 255, 255, 0.15);
  --btn-active: rgba(255, 255, 255, 0.22);
  --panel-bg: rgba(0, 0, 0, 0.2);
  --modal-bg: rgba(20, 50, 38, 0.96);
  --shadow-color: rgba(0, 0, 0, 0.35);
  --font-family: 'Georgia', 'Noto Serif SC', serif;
  --formula-font-size: 0.82rem;
  --dot-color: #f0ece2;
  --tick-color: rgba(255, 255, 255, 0.15);
  --input-bg: rgba(255, 255, 255, 0.06);
}

/* 主题：极简现代风 */
[data-theme="minimal"] {
  --bg-primary: #fafafa;
  --bg-secondary: #f0f0f0;
  --bg-clock: #ffffff;
  --border-clock: #e0e0e0;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --accent: #2196f3;
  --accent-glow: rgba(33, 150, 243, 0.25);
  --hand-hour: #1a1a1a;
  --hand-minute: #444;
  --hand-second: #e53935;
  --tooltip-bg: rgba(255, 255, 255, 0.96);
  --tooltip-border: #e0e0e0;
  --btn-bg: rgba(0, 0, 0, 0.04);
  --btn-hover: rgba(0, 0, 0, 0.08);
  --btn-active: rgba(0, 0, 0, 0.14);
  --panel-bg: rgba(0, 0, 0, 0.03);
  --modal-bg: rgba(255, 255, 255, 0.97);
  --shadow-color: rgba(0, 0, 0, 0.08);
  --font-family: -apple-system, 'Helvetica Neue', 'PingFang SC', sans-serif;
  --formula-font-size: 0.78rem;
  --dot-color: #1a1a1a;
  --tick-color: rgba(0, 0, 0, 0.08);
  --input-bg: rgba(0, 0, 0, 0.03);
}

/* 主题：深邃午夜 */
[data-theme="midnight"] {
  --bg-primary: #0d1b2a;
  --bg-secondary: #1b2838;
  --bg-clock: #152238;
  --border-clock: rgba(160, 180, 220, 0.18);
  --text-primary: #d0dae8;
  --text-secondary: #8899b0;
  --accent: #5b9bd5;
  --accent-glow: rgba(91, 155, 213, 0.4);
  --hand-hour: #d0dae8;
  --hand-minute: #9aafc4;
  --hand-second: #6ec6e6;
  --tooltip-bg: rgba(13, 27, 42, 0.94);
  --tooltip-border: rgba(160, 180, 220, 0.15);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-hover: rgba(255, 255, 255, 0.12);
  --btn-active: rgba(255, 255, 255, 0.18);
  --panel-bg: rgba(0, 0, 0, 0.3);
  --modal-bg: rgba(13, 27, 42, 0.97);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --font-family: 'Segoe UI', 'Helvetica Neue', 'PingFang SC', sans-serif;
  --formula-font-size: 0.8rem;
  --dot-color: #d0dae8;
  --tick-color: rgba(160, 180, 220, 0.12);
  --input-bg: rgba(255, 255, 255, 0.05);
}

/* 主题：赛博朋克 */
[data-theme="cyberpunk"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-clock: #111118;
  --border-clock: rgba(0, 255, 255, 0.2);
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --accent: #00fff5;
  --accent-glow: rgba(0, 255, 245, 0.45);
  --hand-hour: #00fff5;
  --hand-minute: #cc44ff;
  --hand-second: #ff2d6b;
  --tooltip-bg: rgba(10, 10, 15, 0.95);
  --tooltip-border: rgba(0, 255, 255, 0.15);
  --btn-bg: rgba(0, 255, 245, 0.06);
  --btn-hover: rgba(0, 255, 245, 0.12);
  --btn-active: rgba(0, 255, 245, 0.2);
  --panel-bg: rgba(0, 0, 0, 0.4);
  --modal-bg: rgba(10, 10, 15, 0.97);
  --shadow-color: rgba(0, 0, 0, 0.6);
  --font-family: 'Courier New', 'Consolas', monospace;
  --formula-font-size: 0.8rem;
  --dot-color: #ff2d6b;
  --tick-color: rgba(0, 255, 255, 0.1);
  --input-bg: rgba(0, 255, 245, 0.04);
}

/* 赛博朋克专属发光效果 */
[data-theme="cyberpunk"] .clock-face {
  box-shadow:
    0 0 20px rgba(0, 255, 245, 0.15),
    0 8px 32px var(--shadow-color),
    inset 0 0 40px rgba(0, 255, 245, 0.03);
}

[data-theme="cyberpunk"] .formula-marker:hover,
[data-theme="cyberpunk"] .formula-marker.active {
  filter: drop-shadow(0 0 12px var(--accent-glow))
          drop-shadow(0 0 4px rgba(204, 68, 255, 0.4));
}

[data-theme="cyberpunk"] .center-dot {
  box-shadow: 0 0 10px var(--accent-glow), 0 0 20px rgba(255, 45, 107, 0.3);
}

[data-theme="cyberpunk"] .second-hand {
  box-shadow: 0 0 6px rgba(255, 45, 107, 0.5);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  transition: background var(--transition-speed), color var(--transition-speed);
}

/* ---------- Top Bar (theme + settings) ---------- */
.top-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  gap: 10px;
}

.top-bar button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-clock);
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: background var(--transition-speed), transform 0.2s;
  backdrop-filter: blur(8px);
}

.top-bar button:hover {
  background: var(--btn-hover);
  transform: rotate(30deg);
}

#settings-btn:hover {
  transform: rotate(60deg);
}

.theme-icon::before {
  content: '';
}

[data-theme="chalkboard"] .theme-icon::before {
  content: '☀';
}

[data-theme="minimal"] .theme-icon::before {
  content: '🌙';
}

[data-theme="midnight"] .theme-icon::before {
  content: '✦';
}

[data-theme="cyberpunk"] .theme-icon::before {
  content: '⚡';
}

/* ---------- Layout ---------- */
.container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  padding: 32px;
  width: 100%;
  max-width: 1000px;
  position: relative;
}

/* ---------- Clock Section ---------- */
.clock-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  overflow: visible;
}

.clock-wrapper {
  position: relative;
  width: var(--clock-size);
  height: var(--clock-size);
  aspect-ratio: 1 / 1;
  overflow: visible;
  flex-shrink: 0;
}

/* ---------- Clock Face ---------- */
.clock-face {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--bg-clock);
  border: 2px solid var(--border-clock);
  position: relative;
  overflow: visible;
  box-shadow:
    0 8px 32px var(--shadow-color),
    inset 0 0 60px rgba(0,0,0,0.05);
  transition: background var(--transition-speed), border var(--transition-speed), box-shadow var(--transition-speed);
}

/* 刻度线 */
.clock-face.show-ticks::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid var(--tick-color);
}

/* 60 个小刻度 */
.clock-face .tick-marks {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.tick-mark {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 8px;
  background: var(--tick-color);
  transform-origin: 0 calc(var(--clock-size) / 2);
}

.tick-mark.major {
  width: 2px;
  height: 12px;
  opacity: 0.6;
}

/* ---------- Formula Markers ---------- */
.formula-marker {
  position: absolute;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.25s ease, filter 0.25s ease;
  z-index: 20;
  font-size: var(--formula-font-size);
  color: var(--text-primary);
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  white-space: nowrap;
}

.formula-marker:hover,
.formula-marker.active {
  transform: translate(-50%, -50%) scale(1.2);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  z-index: 25;
}

.formula-marker .katex {
  font-size: inherit;
  visibility: visible;
  opacity: 1;
  display: inline-block;
}

/* ---------- Clock Hands ---------- */
.hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform-origin: bottom center;
  border-radius: 3px;
  z-index: 2;
  will-change: transform;
}

.hour-hand {
  width: 5px;
  height: calc(var(--clock-size) * 0.22);
  background: var(--hand-hour);
  margin-left: -2.5px;
  border-radius: 4px;
  box-shadow: 0 0 6px var(--shadow-color);
}

.minute-hand {
  width: 3px;
  height: calc(var(--clock-size) * 0.32);
  background: var(--hand-minute);
  margin-left: -1.5px;
  border-radius: 3px;
  box-shadow: 0 0 4px var(--shadow-color);
}

.second-hand {
  width: 1.5px;
  height: calc(var(--clock-size) * 0.38);
  background: var(--hand-second);
  margin-left: -0.75px;
  border-radius: 2px;
  z-index: 3;
}

/* 滴答模式：加 transition 产生跳动感 */
.second-hand.tick-mode {
  transition: transform 0.15s steps(1, end);
}

.center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--hand-second);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  box-shadow: 0 0 6px var(--shadow-color);
}

/* ---------- Info Panel (替代表盘内 Tooltip) ---------- */
.info-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-clock);
  border-radius: 12px;
  padding: 14px 20px;
  width: var(--clock-size);
  min-height: 70px;
  text-align: center;
  backdrop-filter: blur(8px);
  transition: background var(--transition-speed), border var(--transition-speed);
}

.info-result {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  min-height: 1.3em;
}

.info-branch {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
  min-height: 1em;
}

.info-trivia {
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: 0.8;
  min-height: 1em;
}

/* ---------- Digital Clock (mobile) ---------- */
.digital-clock {
  display: none;
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--text-primary);
  font-weight: 300;
}

/* body 上的类控制数字时钟显示 */
body.show-digital .digital-clock {
  display: block;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 220px;
  flex-shrink: 0;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-clock);
  border-radius: 14px;
  padding: 18px;
  backdrop-filter: blur(8px);
  transition: background var(--transition-speed), border var(--transition-speed);
}

.panel h2 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  opacity: 0.7;
  letter-spacing: 1px;
}

/* ---------- Pomodoro ---------- */
.pomodoro-settings {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.pomo-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pomo-field > span {
  font-size: 0.72rem;
  opacity: 0.6;
}

.pomo-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pomo-input-row input {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--border-clock);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  transition: border 0.2s;
}

.pomo-input-row input:focus {
  border-color: var(--accent);
}

.pomo-input-row .unit {
  font-size: 0.7rem;
  opacity: 0.5;
  white-space: nowrap;
}

.pomodoro-display {
  font-size: 2.2rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 10px;
  font-weight: 300;
  letter-spacing: 2px;
}

.pomodoro-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.pomodoro-controls button,
.alarm-setter button {
  flex: 1;
  padding: 7px;
  border: 1px solid var(--border-clock);
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font-family);
  transition: background var(--transition-speed);
}

.pomodoro-controls button:hover,
.alarm-setter button:hover {
  background: var(--btn-hover);
}

.pomodoro-status {
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ---------- Alarm ---------- */
.alarm-setter {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.alarm-setter input[type="time"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-clock);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.82rem;
}

.alarm-difficulty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.78rem;
}

.alarm-difficulty span {
  opacity: 0.6;
  white-space: nowrap;
}

.alarm-difficulty select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border-clock);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.78rem;
}

.alarm-status {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-bottom: 8px;
}

#alarm-cancel-btn {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--border-clock);
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-family);
  transition: background var(--transition-speed);
}

#alarm-cancel-btn:hover {
  background: var(--btn-hover);
}

/* ---------- Sidebar Toggle (mobile) ---------- */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-clock);
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: background var(--transition-speed);
}

.sidebar-toggle span::before {
  content: '⏱';
}

.sidebar-toggle:hover {
  background: var(--btn-hover);
}

/* ---------- Modal (通用) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--border-clock);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 48px var(--shadow-color);
  color: var(--text-primary);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 0.88rem;
  opacity: 0.8;
  margin-bottom: 14px;
}

.math-problem {
  font-size: 1.15rem;
  margin: 16px 0;
  padding: 14px;
  background: var(--btn-bg);
  border-radius: 10px;
}

.modal-input-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.modal-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-clock);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-family);
  outline: none;
  transition: border 0.2s;
}

.modal-input-row input:focus {
  border-color: var(--accent);
}

.modal-input-row button {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-family: var(--font-family);
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}

.modal-input-row button:hover {
  opacity: 0.85;
}

.modal-feedback {
  margin-top: 10px;
  font-size: 0.82rem;
  color: #e53935;
  font-weight: 500;
}

/* ---------- 闹钟多选项 (ODE 难度) ---------- */
.alarm-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.alarm-option-btn {
  padding: 10px 14px;
  border: 1px solid var(--border-clock);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.9rem;
  text-align: left;
  transition: background var(--transition-speed), border-color 0.2s;
}

.alarm-option-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
}

/* ---------- 设置模态框 ---------- */
.settings-card {
  text-align: left;
  max-width: 460px;
}

.settings-card h2 {
  text-align: center;
  margin-bottom: 18px;
}

.setting-group {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-clock);
}

.setting-group:last-of-type {
  border-bottom: none;
}

.setting-group h3 {
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0.65;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  cursor: default;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  font-size: 0.85rem;
}

/* 主题选择下拉 & 自定义颜色 */
.theme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.theme-row label {
  font-size: 0.85rem;
  white-space: nowrap;
}

.theme-row select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-clock);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

.theme-row select:focus {
  border-color: var(--accent);
}

.custom-bg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.custom-bg-row label {
  font-size: 0.85rem;
  white-space: nowrap;
}

.custom-bg-row input[type="color"] {
  width: 36px;
  height: 30px;
  border: 1px solid var(--border-clock);
  border-radius: 6px;
  padding: 2px;
  background: var(--input-bg);
  cursor: pointer;
}

.custom-bg-row .bg-hint {
  font-size: 0.72rem;
  opacity: 0.5;
}

.setting-toggle-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-clock);
  border-radius: 8px;
  overflow: hidden;
}

.setting-btn {
  padding: 6px 14px;
  border: none;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.78rem;
  transition: background var(--transition-speed);
  border-right: 1px solid var(--border-clock);
}

.setting-btn:last-child {
  border-right: none;
}

.setting-btn:hover {
  background: var(--btn-hover);
}

.setting-btn.active {
  background: var(--btn-active);
  font-weight: 600;
}

/* 自定义公式列表 */
.custom-formula-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.custom-formula-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-formula-row label {
  font-size: 0.78rem;
  white-space: nowrap;
  width: 28px;
  text-align: right;
  opacity: 0.7;
}

.custom-formula-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border-clock);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  outline: none;
}

.custom-formula-row input:focus {
  border-color: var(--accent);
}

.custom-formula-row input::placeholder {
  opacity: 0.35;
}

.modal-close-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  border: 1px solid var(--border-clock);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.88rem;
  transition: background var(--transition-speed);
}

.modal-close-btn:hover {
  background: var(--btn-hover);
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 800px) {
  .container {
    flex-direction: column;
    gap: 20px;
    padding: 20px 16px 80px;
  }

  .clock-wrapper {
    --clock-size: min(80vw, 400px);
  }

  .info-panel {
    width: var(--clock-size);
  }

  /* 移动端公式强制可见 + 缩放 */
  .formula-marker {
    width: 56px;
    height: 56px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 20;
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.85);
  }

  .formula-marker:hover,
  .formula-marker.active {
    transform: translate(-50%, -50%) scale(1.0);
  }

  .formula-marker .katex {
    font-size: inherit;
    visibility: visible;
  }

  body.show-digital .digital-clock {
    display: block;
  }

  .sidebar {
    width: 100%;
    max-width: 420px;
    flex-direction: column;
    display: none;
  }

  .sidebar .panel {
    width: 100%;
  }

  .sidebar.open {
    display: flex;
  }

  .sidebar-toggle {
    display: flex;
  }
}

@media (max-width: 420px) {
  .clock-wrapper {
    --clock-size: 88vw;
  }

  .info-panel {
    width: var(--clock-size);
  }

  .formula-marker {
    width: 44px;
    height: 44px;
    font-size: 0.55rem;
    white-space: nowrap;
    z-index: 20;
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.75);
  }

  .formula-marker:hover,
  .formula-marker.active {
    transform: translate(-50%, -50%) scale(0.9);
  }

  .formula-marker .katex {
    font-size: inherit;
    visibility: visible;
  }

  .digital-clock {
    font-size: 1.4rem;
  }

  .modal-card {
    padding: 22px 18px;
  }
}
