/* ==========================================================================
   Self-Hosted Local Fonts (Zero External Dependencies)
   ========================================================================== */
@font-face {
  font-family: 'Nova Round';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/NovaRound-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Outfit-Variable.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Inter-Variable.woff2') format('woff2');
}

/* ==========================================================================
   TileTimer Design System & Styling (Updated v6 - Rich Warm Theme & Dark Select Fix)
   ========================================================================== */

/* --- Root Color Tokens & Themes --- */
:root {
  /* Fonts */
  --font-heading: 'Outfit', 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  --font-body: 'Inter', 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Malgun Gothic', '맑은 고딕', sans-serif;

  /* Dimensions & Spacing */
  --header-height: 64px;
  --grid-gap: 24px;
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Theme Tokens --- */
html[data-theme="light"] {
  --bg-dashboard: #F8F9FA;
  --bg-header: rgba(255, 255, 255, 0.85);
  --bg-tile: #FFFFFF;
  --bg-tile-hover: #FAFAFA;
  --border-tile: #E5E7EB;
  --border-header: #E5E7EB;
  --shadow-tile: 0 10px 30px -5px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --shadow-tile-hover: 0 20px 40px -8px rgba(0, 0, 0, 0.10);
  --text-main: #111827;
  --text-sub: #6B7280;
  --text-muted: #9CA3AF;
  --accent-red: #EF4444;
  --accent-red-hover: #DC2626;
  --accent-blue: #3B82F6;
  --bg-input: #F3F4F6;
  --border-input: #D1D5DB;
  --badge-bg: #EEF2FF;
  --badge-text: #4F46E5;
}

html[data-theme="dark"] {
  --bg-dashboard: #0F172A;
  --bg-header: rgba(30, 41, 59, 0.85);
  --bg-tile: #1E293B;
  --bg-tile-hover: #243347;
  --border-tile: #334155;
  --border-header: #334155;
  --shadow-tile: 0 10px 30px -5px rgba(0, 0, 0, 0.35);
  --shadow-tile-hover: 0 20px 45px -4px rgba(0, 0, 0, 0.50);
  --text-main: #F8FAFC;
  --text-sub: #94A3B8;
  --text-muted: #64748B;
  --accent-red: #F87171;
  --accent-red-hover: #EF4444;
  --accent-blue: #60A5FA;
  --bg-input: #0F172A;
  --border-input: #475569;
  --badge-bg: #312E81;
  --badge-text: #818CF8;
}

/* Richer, Deeper Warm Sepia Paper Theme */
html[data-theme="warm"] {
  --bg-dashboard: #EFE6DC;
  --bg-header: rgba(245, 237, 227, 0.88);
  --bg-tile: #FDF8F0;
  --bg-tile-hover: #F7EFE3;
  --border-tile: #DBC8B5;
  --border-header: #DBC8B5;
  --shadow-tile: 0 10px 30px -5px rgba(80, 60, 40, 0.12);
  --shadow-tile-hover: 0 20px 40px -8px rgba(80, 60, 40, 0.18);
  --text-main: #2C1F14;
  --text-sub: #7A6250;
  --text-muted: #A38B78;
  --accent-red: #DC2626;
  --accent-red-hover: #B91C1C;
  --accent-blue: #D97706;
  --bg-input: #E5D6C5;
  --border-input: #CBB6A2;
  --badge-bg: #FEF3C7;
  --badge-text: #B45309;
}

/* --- Global Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dashboard);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

/* --- App Container --- */
.app-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.app-container.sidebar-right {
  flex-direction: row-reverse;
}

/* --- App Sidebar Navigation & Control Center --- */
.app-sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-header);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.03);
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.25s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.25s cubic-bezier(0.16, 1, 0.3, 1), margin 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.app-container.sidebar-right .app-sidebar {
  border-right: none;
  border-left: 1px solid var(--border-header);
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.03);
}

/* Collapsed Sidebar: 60px Minimal Floating Line Icon Dock */
.app-sidebar.collapsed {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  margin-left: 0;
  background-color: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  overflow-x: hidden;
  pointer-events: none;
}

.app-container.sidebar-right .app-sidebar.collapsed {
  margin-left: 0;
  margin-right: 0;
}

/* Collapsed Header Elements */
.app-sidebar.collapsed .sidebar-header {
  padding: 0;
  height: 64px;
  border-bottom: none !important;
  background: transparent !important;
  justify-content: center;
}

.app-sidebar.collapsed .sidebar-header-actions {
  width: 100%;
  display: flex;
  justify-content: center;
}

.app-sidebar.collapsed .sidebar-brand-group {
  display: none;
}

.app-sidebar.collapsed #btn-toggle-sidebar-pos {
  display: none;
}

/* Collapsed Sidebar Body */
.app-sidebar.collapsed .sidebar-body {
  padding: 8px 0;
  gap: 6px;
  align-items: center;
  background: transparent !important;
  overflow-x: hidden;
}

.app-sidebar.collapsed .sidebar-section {
  width: 100%;
  align-items: center;
}

.app-sidebar.collapsed .sidebar-section-title {
  display: none;
}

/* Collapsed Floating Line Icon Buttons */
.app-sidebar.collapsed .sidebar-tools-list {
  width: 100%;
  align-items: center;
  gap: 6px;
}

.app-sidebar.collapsed .sidebar-tools-list .tool-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  border-radius: 12px;
  background-color: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: var(--text-main);
  pointer-events: auto;
  transition: all var(--transition-fast);
}

.app-sidebar.collapsed .sidebar-tools-list .tool-btn:hover {
  background-color: var(--bg-tile-hover) !important;
  border-color: var(--border-tile) !important;
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08) !important;
}

.app-sidebar.collapsed .sidebar-tools-list .tool-btn:active {
  transform: scale(0.96);
}

.app-sidebar.collapsed .sidebar-tools-list .tool-label {
  display: none;
}

.app-sidebar.collapsed .tool-icon {
  margin: 0;
  width: 44px;
  height: 44px;
}

.app-sidebar.collapsed .tool-icon .lucide-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Collapsed Layout Mode Row */
.app-sidebar.collapsed .layout-mode-section {
  padding: 10px 0 0 0;
  border-top: none !important;
  background: transparent !important;
  width: 100%;
  display: flex;
  justify-content: center;
}

.app-sidebar.collapsed .layout-mode-row {
  justify-content: center;
  width: auto;
}

.app-sidebar.collapsed .layout-mode-info {
  display: none;
}

.app-sidebar.collapsed .vertical-switch-toggle {
  pointer-events: auto;
}

/* Collapsed Hidden Sections (Zoom, Alarm Duration, Footer) */
.app-sidebar.collapsed .zoom-section,
.app-sidebar.collapsed .alarm-duration-section,
.app-sidebar.collapsed .sidebar-footer {
  display: none;
}

/* Header-Integrated Collapse/Expand Button (#btn-sidebar-edge-tab) */
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.app-container.sidebar-right .sidebar-header-actions {
  flex-direction: row-reverse;
}

.sidebar-edge-tab {
  width: 44px;
  height: 50px;
  border-radius: 10px;
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  padding: 0;
  flex-shrink: 0;
  pointer-events: auto;
}

.sidebar-edge-tab:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--border-tile);
  color: var(--text-main);
}

.sidebar-edge-tab .tab-arrow-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Expanded state:
   Left sidebar: arrow points left
   Right sidebar: arrow points right
*/
.app-container.sidebar-right .sidebar-edge-tab .tab-arrow-icon {
  transform: rotate(180deg);
}

/* Collapsed state:
   Button centered in 60px rail with floating style
*/
.app-sidebar.collapsed .sidebar-edge-tab {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text-main);
}

.app-sidebar.collapsed .sidebar-edge-tab:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--border-tile);
  color: var(--accent-blue);
  transform: scale(1.1);
}

/* Collapsed arrow inversion:
   Left sidebar collapsed: arrow points right (rotate 180deg)
   Right sidebar collapsed: arrow points left (rotate 0deg)
*/
.app-sidebar.collapsed .sidebar-edge-tab .tab-arrow-icon {
  transform: rotate(180deg);
}

.app-container.sidebar-right .app-sidebar.collapsed .sidebar-edge-tab .tab-arrow-icon {
  transform: rotate(0deg);
}

/* Sidebar Backdrop for Mobile Touch Dismiss */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 95;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
}

.sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Mobile Responsive Drawer Engine (max-width: 768px) */
@media (max-width: 768px) {
  .app-sidebar {
    position: relative;
    height: 100vh;
    height: 100dvh;
    z-index: 90;
  }

  .app-sidebar:not(.collapsed) {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
    z-index: 100 !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25) !important;
    background-color: var(--bg-header) !important;
  }

  .app-container.sidebar-right .app-sidebar:not(.collapsed) {
    left: auto;
    right: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25) !important;
  }

  .app-sidebar.collapsed {
    transform: none !important;
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .app-container.sidebar-right .app-sidebar.collapsed {
    transform: none !important;
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 16px;
  border-bottom: 1px solid var(--border-header);
  flex-shrink: 0;
  position: relative;
}

.sidebar-brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Nova Round', sans-serif;
  font-weight: 400;
  font-size: 1.18rem;
  color: var(--text-main);
  letter-spacing: 0.2px;
  user-select: none;
  white-space: nowrap;
}

.app-container.sidebar-right .sidebar-header {
  flex-direction: row-reverse;
  padding: 0 16px 0 4px;
}

.app-container.sidebar-right .sidebar-brand-group {
  flex-direction: row-reverse;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-red);
}

.sidebar-action-btn {
  width: 42px;
  height: 50px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-action-btn .lucide-icon {
  width: 19px;
  height: 19px;
}

.sidebar-action-btn:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--border-tile);
  color: var(--text-main);
}

/* Lucide Icon Standard */
.lucide-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

.brand-icon .lucide-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-icon .lucide-icon {
  width: 1.05rem;
  height: 1.05rem;
}

/* Sidebar Body */
.sidebar-body {
  flex: 1;
  min-height: 0;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 6px;
}

.sidebar-section-title {
  font-size: 0.94rem; /* 15px */
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
  padding-left: 6px;
}

/* Tool Buttons in Sidebar */
.sidebar-tools-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-tools-list .tool-btn {
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 12px 0 0;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-tile);
  background-color: var(--bg-tile);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  text-align: left;
}

.sidebar-tools-list .tool-btn:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--accent-blue);
  transform: translateX(2px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.sidebar-tools-list .tool-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-tools-list .tool-icon .lucide-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.sidebar-tools-list .tool-label {
  flex: 1;
  margin-left: 6px;
}

/* Zoom Control Section */
.zoom-section {
  padding: 14px 0 0 0;
  border-top: 1px solid var(--border-header);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zoom-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.zoom-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-value-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-blue);
  min-width: 44px;
  text-align: right;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.zoom-value-badge:hover {
  background-color: var(--bg-tile-hover);
  text-decoration: underline;
}

.zoom-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-tile);
  background-color: var(--bg-input);
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.zoom-reset-btn .lucide-icon {
  width: 14px;
  height: 14px;
}

.zoom-reset-btn:hover {
  background-color: var(--bg-tile-hover);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  transform: scale(1.05);
}

.zoom-reset-btn:active {
  transform: scale(0.95);
}

.zoom-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.zoom-step-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-tile);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.zoom-step-btn:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.zoom-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border-tile);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent-blue);
}

/* Layout, Auto Focus & Automation Mode Sections */
.layout-mode-section,
.auto-focus-mode-section,
.automation-mode-section {
  padding: 14px 0 0 0;
  border-top: 1px solid var(--border-header);
}

.layout-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  transition: opacity var(--transition-fast);
}

.layout-mode-row.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.layout-mode-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.94rem; /* 15px */
  color: var(--text-main);
  user-select: none;
}

.layout-mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.layout-mode-icon .lucide-icon {
  width: 16px;
  height: 16px;
}

/* Switch Toggle (Standard Horizontal) */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-tile);
  transition: var(--transition-fast);
  border-radius: 22px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-fast);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch-toggle input:checked + .switch-slider {
  background-color: var(--accent-blue);
}

#toggle-layout-mode:checked + .switch-slider {
  background-color: #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

#toggle-automation-mode:checked + .switch-slider {
  background-color: #10b981 !important;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.switch-toggle input:checked + .switch-slider:before {
  transform: translateX(18px);
}

.switch-toggle input:disabled + .switch-slider {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Vertical Toggle Switch (Vintage Rocker Switch Style: UP = ON Red / DOWN = OFF Gray) */
.vertical-switch-toggle {
  position: relative;
  display: inline-flex;
  width: 24px;
  height: 44px;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.vertical-switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.vertical-switch-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-tile);
  border-radius: 22px;
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.vertical-switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 3px; /* Default OFF position: DOWN */
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28), 0 0 1px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s;
}

/* Checked state: UP = ON (Red) */
.vertical-switch-toggle input:checked + .vertical-switch-slider {
  background-color: #ef4444;
  border-color: #dc2626;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 10px rgba(239, 68, 68, 0.5);
}

.vertical-switch-toggle input:checked + .vertical-switch-slider:before {
  transform: translateY(-20px); /* 44px - 3px bottom - 18px knob = 23px. 23 - 20 = 3px top margin */
}

.vertical-switch-toggle input:disabled + .vertical-switch-slider {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Global Alarm Duration Section */
.alarm-duration-section {
  padding: 14px 0 0 0;
  border-top: 1px solid var(--border-header);
}

.alarm-duration-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.alarm-duration-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.alarm-duration-icon .lucide-icon {
  width: 18px;
  height: 18px;
}

.alarm-duration-select {
  flex: 1;
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.alarm-duration-select:hover,
.alarm-duration-select:focus {
  border-color: var(--accent-blue);
  background-color: var(--bg-tile-hover);
}

.alarm-duration-select:hover,
.alarm-duration-select:focus {
  border-color: var(--accent-blue);
  background-color: var(--bg-tile-hover);
}

/* Sidebar Footer (Themes, Language, Profile) */
/* Sidebar Footer (Compact Single Row: Language + Themes) */
.sidebar-footer {
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  border-top: 1px solid var(--border-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.015);
  flex-shrink: 0;
}

.lang-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: var(--bg-input);
  padding: 4px 8px;
  border-radius: var(--border-radius-md);
  flex: 1;
  min-width: 0;
  height: 34px;
}

.lang-globe-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lang-globe-icon .lucide-icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--text-sub);
}

.lang-select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  width: 100%;
  padding-right: 2px;
}

.lang-select option {
  background-color: var(--bg-tile);
  color: var(--text-main);
  padding: 8px;
}

.theme-selector-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  padding: 2px;
  border-radius: var(--border-radius-md);
  gap: 2px;
  flex-shrink: 0;
  height: 34px;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--border-radius-sm);
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-btn .lucide-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.theme-btn:hover {
  background-color: var(--bg-tile-hover);
  color: var(--text-main);
}

.theme-btn.active {
  background-color: var(--bg-tile);
  color: var(--accent-blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* --- Profile Widget & Popover Menu (Header Native) --- */
.profile-widget-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-widget {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.28);
  flex-shrink: 0;
  border: none;
  padding: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.profile-widget:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.45);
}

.profile-widget.active {
  box-shadow: 0 0 0 2px var(--bg-header), 0 0 0 4px #6366F1;
}

.profile-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 7px;
  height: 7px;
  background-color: #10B981;
  border: 1.5px solid var(--bg-header);
  border-radius: 50%;
}

.profile-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  bottom: auto;
  width: 300px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background-color: var(--bg-tile);
  border: 1px solid var(--border-header);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.25), 0 8px 16px -2px rgba(0, 0, 0, 0.12);
  padding: 8px 6px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeInFast 0.15s ease-out;
  user-select: none;
}

.app-container.sidebar-right .profile-popover {
  left: auto;
  right: 0;
}

.profile-popover.hidden {
  display: none !important;
}

.popover-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.popover-divider {
  height: 1px;
  background-color: var(--border-header);
  margin: 4px 2px;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.popover-item:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

.popover-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  flex-shrink: 0;
}

.popover-item:hover .popover-icon {
  color: var(--custom-text, var(--text-main));
}

.popover-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-header, #e2e8f0);
}

.popover-user-card.hidden {
  display: none !important;
}

.popover-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-blue, #2563eb);
}

.popover-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.popover-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-user-email {
  font-size: 0.75rem;
  color: var(--text-sub, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-cloud-status {
  font-size: 0.68rem;
  color: var(--accent-blue, #2563eb);
  margin-top: 2px;
  font-weight: 500;
}

.cloud-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body, sans-serif);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 500;
  transition: all var(--transition-fast, 0.2s ease);
  user-select: none;
  cursor: default;
}

.cloud-sync-badge.hidden {
  display: none !important;
}

.cloud-sync-badge.saving {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-blue, #2563eb);
}

.cloud-sync-badge.saved {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.cloud-sync-badge.error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.cloud-sync-badge .sync-spin {
  display: inline-block;
  animation: syncBadgeSpin 1s linear infinite;
}

@keyframes syncBadgeSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.profile-widget .avatar-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.popover-sub-header {
  padding: 6px 10px 3px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-sub-title {
  font-family: var(--font-body);
  font-size: 0.875rem; /* 14px */
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.2px;
}

.popover-reorder-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-tb-reorder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm, 4px);
  color: var(--text-sub);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

.btn-tb-reorder:hover:not(:disabled) {
  background-color: rgba(150, 150, 150, 0.15);
  color: var(--text-main);
}

.btn-tb-reorder:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.popover-preset-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#popover-user-presets,
#sidebar-user-presets {
  max-height: 145px; /* Exactly 4 items fit without scroll (139px); 5th item triggers scroll (174px) */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 150, 150, 0.3) transparent;
}

#popover-user-presets::-webkit-scrollbar,
#sidebar-user-presets::-webkit-scrollbar {
  width: 5px;
}

#popover-user-presets::-webkit-scrollbar-track,
#sidebar-user-presets::-webkit-scrollbar-track {
  background: transparent;
}

#popover-user-presets::-webkit-scrollbar-thumb,
#sidebar-user-presets::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.3);
  border-radius: 4px;
}

#popover-user-presets::-webkit-scrollbar-thumb:hover,
#sidebar-user-presets::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 150, 0.5);
}

.popover-preset-item {
  height: 34px;
  min-height: 34px;
  flex-shrink: 0;
  padding-left: 8px;
  padding-right: 6px;
  display: flex;
  align-items: center;
  position: relative;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}

.preset-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-sub);
  opacity: 0.4;
  flex-shrink: 0;
  margin-right: 0;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.popover-preset-item.active {
  background-color: rgba(16, 185, 129, 0.08);
  color: #10B981;
  font-weight: 700;
}

.popover-preset-item.active .preset-bullet {
  background-color: #10B981;
  opacity: 1;
  transform: scale(1.2);
}

.preset-name-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  flex: 1;
  margin-right: 0;
}

.preset-name-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem; /* 14px */
  letter-spacing: -0.3px;
}

.preset-action-btn {
  background: none;
  border: none;
  padding: 2px;
  border-radius: 4px;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
  opacity: 0;
}

.popover-preset-item:hover .preset-action-btn {
  opacity: 1;
}

.preset-action-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.btn-preset-delete {
  margin-left: 2px;
}

.btn-preset-delete:hover {
  color: #EF4444 !important;
}

.popover-preset-item.editing .preset-action-btn,
.popover-preset-item.editing .preset-name-wrap {
  display: none !important;
}

.preset-name-input {
  flex: 1;
  width: 100%;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 0.875rem; /* 14px */
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.popover-auth-item {
  color: #6366F1;
}

.popover-auth-item .popover-icon {
  color: #6366F1;
}

/* Toast Notification */
.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(17, 24, 39, 0.92);
  color: #FFFFFF;
  padding: 10px 22px;
  border-radius: 9999px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.app-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

/* Camera Flash Animation */
@keyframes cameraFlash {
  0% { opacity: 0; }
  35% { opacity: 0.28; }
  100% { opacity: 0; }
}

.camera-flash-overlay {
  position: fixed;
  inset: 0;
  background: #FFF;
  z-index: 9998;
  pointer-events: none;
  animation: cameraFlash 0.35s ease-out forwards;
}

/* --- Dashboard Viewport & Fixed 5-Column Grid Engine --- */
.dashboard-viewport {
  flex: 1;
  height: 100%;
  height: 100dvh;
  overflow: auto;
  padding: 20px 24px;
  touch-action: pan-x pan-y pinch-zoom;
}

/* --- Sidebar TimeBoard Workspace Selector Component --- */
.timeboard-selector-section {
  position: relative;
  margin-bottom: 4px;
}

.timeboard-picker-wrap {
  position: relative;
  width: 100%;
}

.timeboard-picker-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background-color: var(--bg-tile);
  border: 1px solid var(--border-header);
  border-radius: var(--border-radius-md, 10px);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.875rem; /* 14px */
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast, 0.15s ease);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  text-align: left;
}

.timeboard-picker-btn:hover {
  background-color: var(--bg-tile-hover);
  border-color: var(--accent-blue);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.tb-picker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.tb-picker-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-picker-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  opacity: 0.6;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.timeboard-picker-btn.open .tb-picker-chevron {
  transform: rotate(180deg);
}

.timeboard-picker-dropdown {
  position: fixed;
  width: 300px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background-color: var(--bg-tile);
  border: 1px solid var(--border-header);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.25), 0 8px 16px -2px rgba(0, 0, 0, 0.12);
  padding: 8px 6px;
  z-index: 1250;
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: none;
  pointer-events: auto;
  animation: fadeInFast 0.15s ease-out;
}

.timeboard-picker-dropdown.hidden {
  display: none !important;
}

/* Collapsed sidebar rail adaptation */
.app-sidebar.collapsed .timeboard-selector-section {
  width: 100%;
  align-items: center;
  justify-content: center;
}

.app-sidebar.collapsed .timeboard-picker-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar.collapsed .timeboard-picker-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 auto;
  justify-content: center;
  border-radius: 12px;
  background-color: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: var(--text-main);
  pointer-events: auto;
  transition: all var(--transition-fast);
}

.app-sidebar.collapsed .timeboard-picker-btn:hover {
  background-color: var(--bg-tile-hover) !important;
  border-color: var(--border-tile) !important;
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08) !important;
}

.app-sidebar.collapsed .timeboard-picker-btn:active {
  transform: scale(0.96);
}

.app-sidebar.collapsed .tb-picker-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar.collapsed .tb-picker-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.app-sidebar.collapsed .tb-picker-name,
.app-sidebar.collapsed .tb-picker-chevron {
  display: none;
}

.app-sidebar.collapsed .timeboard-picker-dropdown {
  position: fixed;
  left: 70px;
  top: 80px;
  width: 300px;
  pointer-events: auto;
}

.app-container.sidebar-right .app-sidebar.collapsed .timeboard-picker-dropdown {
  left: auto;
  right: 70px;
  top: 80px;
  pointer-events: auto;
}

.dashboard-grid-wrapper {
  display: table;
  margin: 0 auto;
  min-width: fit-content;
  transform-origin: top center;
  transition: transform 0.1s ease;
  position: relative;
  touch-action: pan-x pan-y pinch-zoom;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 125px);
  grid-auto-rows: 125px;
  gap: 10px;
  width: fit-content;
  transition: outline 0.2s ease;
}

/* Layout Edit Mode Grid Styling */
@keyframes layoutGridBorderPulse {
  0%, 100% {
    outline-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), 0 0 25px rgba(239, 68, 68, 0.15);
  }
  50% {
    outline-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.45), 0 0 35px rgba(249, 115, 22, 0.25);
  }
}

@keyframes marchingAntsOuterBorder {
  0% {
    background-position: 0 0, 100% 0, 100% 100%, 0 100%;
  }
  100% {
    background-position: 32px 0, 100% 32px, calc(100% - 32px) 100%, 0 calc(100% - 32px);
  }
}

.layout-edit-mode .dashboard-grid {
  position: relative;
  outline: 3px dashed #ef4444;
  outline-offset: 8px;
  border-radius: var(--border-radius-lg);
  background-image: radial-gradient(rgba(239, 68, 68, 0.22) 1.5px, transparent 1.5px);
  background-size: 20px 20px;
  animation: layoutGridBorderPulse 2.2s infinite ease-in-out;
  transition: outline 0.2s ease, box-shadow 0.2s ease;
}

/* When grabbing & moving an element in Layout Mode, outer border marches clockwise! */
.layout-edit-mode.layout-is-dragging .dashboard-grid {
  outline: none !important;
}

.layout-edit-mode.layout-is-dragging .dashboard-grid::after {
  content: "";
  position: absolute;
  top: -11px;
  left: -11px;
  right: -11px;
  bottom: -11px;
  border-radius: calc(var(--border-radius-lg) + 8px);
  pointer-events: none;
  z-index: 100;
  box-sizing: border-box;
  background-image: 
    linear-gradient(90deg, #ef4444 50%, transparent 50%),
    linear-gradient(180deg, #ef4444 50%, transparent 50%),
    linear-gradient(90deg, #ef4444 50%, transparent 50%),
    linear-gradient(180deg, #ef4444 50%, transparent 50%);
  background-repeat: repeat-x, repeat-y, repeat-x, repeat-y;
  background-size: 24px 3.5px, 3.5px 24px, 24px 3.5px, 3.5px 24px;
  background-position: 0 0, 100% 0, 100% 100%, 0 100%;
  animation: marchingAntsOuterBorder 0.6s linear infinite;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.45), inset 0 0 14px rgba(239, 68, 68, 0.12);
}

/* In Layout Edit Mode, lock tile contents & buttons to prevent accidental clicks while dragging */
.layout-edit-mode .tile-body {
  pointer-events: none !important;
  user-select: none !important;
}

.layout-edit-mode .tile-header button:not(.btn-close) {
  pointer-events: none !important;
  opacity: 0.3 !important;
  cursor: grab !important;
}

.layout-edit-mode .tile-header .btn-close {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* iOS-style Jiggle Animation in Layout Edit Mode */
.layout-edit-mode .tile-card {
  cursor: grab !important;
  animation: iosTileJiggle 0.26s ease-in-out infinite alternate;
  transform-origin: 50% 50%;
  transition: box-shadow 0.2s ease, filter 0.2s ease;
  touch-action: none;
}

/* Organic staggered timing so tiles don't shake identically */
.layout-edit-mode .tile-card:nth-child(2n) {
  animation-duration: 0.22s;
  animation-delay: -0.11s;
}

.layout-edit-mode .tile-card:nth-child(3n) {
  animation-duration: 0.28s;
  animation-delay: -0.05s;
}

.layout-edit-mode .tile-card:nth-child(5n) {
  animation-duration: 0.24s;
  animation-delay: -0.17s;
}

/* Spotlight Hover: pauses jiggle and springs up with red border glow */
.layout-edit-mode .tile-card:hover {
  animation-play-state: paused;
  box-shadow: 0 0 0 2.5px #ef4444, 0 14px 30px rgba(0, 0, 0, 0.22) !important;
  transform: translateY(-3px) scale(1.02) !important;
  z-index: 5;
}

.layout-edit-mode .tile-card:active {
  cursor: grabbing !important;
  animation: none !important;
}

/* While dragged, the placeholder in grid is extra dimmed and static */
.layout-edit-mode .tile-card.tile-is-dragged {
  opacity: 0.2 !important;
  animation: none !important;
  transform: none !important;
  box-shadow: none !important;
}

@keyframes iosTileJiggle {
  0% {
    transform: rotate(-0.75deg) translateY(-0.5px);
  }
  100% {
    transform: rotate(0.75deg) translateY(0.5px);
  }
}

/* Dynamic Snapping Ghost Slot - Marching Ants Animation */
@keyframes marchingAntsGhost {
  0% {
    background-position: 0 0, 100% 0, 100% 100%, 0 100%;
  }
  100% {
    background-position: 24px 0, 100% 24px, calc(100% - 24px) 100%, 0 calc(100% - 24px);
  }
}

@keyframes ghostPulseGlow {
  0%, 100% {
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.5), inset 0 0 14px rgba(239, 68, 68, 0.15);
    background-color: rgba(239, 68, 68, 0.1);
  }
  50% {
    box-shadow: 0 0 32px rgba(249, 115, 22, 0.8), inset 0 0 24px rgba(249, 115, 22, 0.25);
    background-color: rgba(249, 115, 22, 0.16);
  }
}

.grid-ghost-slot {
  position: absolute;
  border-radius: var(--border-radius-lg);
  pointer-events: none;
  z-index: 1000;
  box-sizing: border-box;
  background-image: 
    linear-gradient(90deg, #ef4444 50%, transparent 50%),
    linear-gradient(180deg, #ef4444 50%, transparent 50%),
    linear-gradient(90deg, #ef4444 50%, transparent 50%),
    linear-gradient(180deg, #ef4444 50%, transparent 50%);
  background-repeat: repeat-x, repeat-y, repeat-x, repeat-y;
  background-size: 16px 3.5px, 3.5px 16px, 16px 3.5px, 3.5px 16px;
  background-position: 0 0, 100% 0, 100% 100%, 0 100%;
  animation: marchingAntsGhost 0.5s linear infinite, ghostPulseGlow 1.8s infinite ease-in-out;
  transition: left 0.08s ease-out, top 0.08s ease-out, width 0.12s ease-out, height 0.12s ease-out;
}

.grid-ghost-slot.hidden {
  display: none !important;
}

/* --- Tile Card Grid Module Spans --- */
.tile-card {
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  grid-column: span 1;
  grid-row: span 1;
  height: 100%;
  width: 100%;
  border-radius: var(--border-radius-lg);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: pan-x pan-y pinch-zoom;
}

.tile-face {
  background-color: var(--custom-bg, var(--bg-tile));
  border: 3px solid var(--custom-border, var(--border-tile));
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-tile);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  container-type: inline-size;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow 0.2s ease;
}

.tile-card:hover .tile-face {
  box-shadow: var(--shadow-tile-hover);
}

.tile-card.span-2 {
  grid-column: span 2;
  grid-row: span 2;
}


.tile-card.span-3 {
  grid-column: span 3;
  grid-row: span 3;
}

.tile-card.span-4 {
  grid-column: span 4;
  grid-row: span 4;
}

/* --- Connection Starter (연동 스타터) Widget Styling --- */
.tile-card.tile-starter .tile-header-starter {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  padding: 6px 10px;
  border-bottom: none;
  background: transparent;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tile-card.tile-starter .tile-header-starter button {
  pointer-events: auto;
  opacity: 0.65;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tile-card.tile-starter .tile-header-starter button:hover {
  opacity: 1;
  transform: scale(1.12);
}

.tile-card.tile-starter .tile-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex: 1;
  padding: 0;
  overflow: hidden;
}

.tile-card.tile-starter .starter-canvas {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s ease, transform 0.15s ease;
  border-radius: var(--border-radius-lg);
}

.tile-card.tile-starter .starter-canvas:hover {
  filter: brightness(1.05);
}

.tile-card.tile-starter .starter-canvas:active {
  transform: scale(0.985);
}

.starter-content-layer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.starter-idle-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--custom-text, #ef4444);
}

.starter-play-icon svg {
  width: 78px;
  height: 78px;
  fill: currentColor;
  filter: drop-shadow(0 4px 14px rgba(239, 68, 68, 0.35));
  transition: transform 0.15s ease;
}

.starter-canvas:hover .starter-play-icon svg {
  transform: scale(1.06);
}

.starter-play-text {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.starter-counting-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--custom-text, #ef4444);
  animation: pulseCount 0.4s ease-out;
}

.starter-count-number {
  font-family: var(--font-heading);
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
}

.starter-cancel-hint {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.75;
  margin-top: 10px;
}

@keyframes pulseCount {
  0% { transform: scale(0.7); opacity: 0.3; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.starter-autofocus-toggle {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--custom-text, var(--text-main));
  cursor: pointer;
  opacity: 0.85;
  user-select: none;
  transition: all var(--transition-fast);
}

.starter-autofocus-toggle:hover {
  opacity: 1;
  background: var(--border-tile);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.starter-autofocus-toggle input[type="checkbox"] {
  cursor: pointer;
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent-red, #ef4444);
}

.btn-starter-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 10;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--custom-text, var(--text-main));
  cursor: pointer;
  opacity: 0.85;
  transition: all var(--transition-fast);
}

.btn-starter-duration:hover {
  opacity: 1;
  background: var(--border-tile);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.starter-picker-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  animation: fadeInFast 0.15s ease-out;
}

/* Resize Handle & Clone Button (Overlay on bottom-right corner in Layout Edit Mode) */
.tile-resize-handle {
  display: none;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  color: #ffffff;
  border: 2.5px solid #ffffff;
  border-radius: 7px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  z-index: 30;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease, box-shadow 0.15s ease;
}

.layout-edit-mode .tile-resize-handle {
  display: flex !important;
}

.tile-resize-handle:hover {
  transform: scale(1.18);
  background: #dc2626;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.6);
}

.tile-resize-handle:active {
  transform: scale(0.95);
  background: #b91c1c;
}

.tile-resize-handle .resize-handle-text {
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  pointer-events: none;
  user-select: none;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Clone Button (Overlay directly above resize handle in Layout Edit Mode) */
.tile-clone-btn {
  display: none;
  position: absolute;
  right: -5px;
  bottom: 25px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  color: #ffffff;
  border: 2.5px solid #ffffff;
  border-radius: 7px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  z-index: 30;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease, box-shadow 0.15s ease;
}

.layout-edit-mode .tile-clone-btn {
  display: flex !important;
}

.tile-clone-btn:hover {
  transform: scale(1.18);
  background: #dc2626;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.6);
}

.tile-clone-btn:active {
  transform: scale(0.95);
  background: #b91c1c;
}

.tile-clone-btn .lucide-icon {
  width: 13px;
  height: 13px;
  stroke-width: 3.2;
  pointer-events: none;
}

.btn-resize-toggle {
  display: none !important;
}

.tile-card:hover {
  box-shadow: var(--shadow-tile-hover);
}

.tile-card.custom-styled {
  background-color: var(--custom-bg) !important;
  border-color: var(--custom-border) !important;
  color: var(--custom-text) !important;
}

/* While dragging a tile */
.tile-card.tile-is-dragged {
  opacity: 0.3 !important;
  border: 2px dashed var(--accent-blue) !important;
  box-shadow: none !important;
}

.layout-edit-mode .tile-card.tile-is-dragged {
  opacity: 0.35 !important;
  border: 3px dashed #ef4444 !important;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5) !important;
}

/* 1:1 Swap Target Highlight */
.tile-card.tile-swap-target {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px var(--accent-blue), var(--shadow-tile-hover) !important;
  transform: scale(0.97);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#drag-preview-ghost,
#drag-preview-ghost * {
  pointer-events: none !important;
}

/* When any tile is in fullscreen, force wrapper zoom to 1 so viewport 100vw/100vh doesn't scale off-screen */
body.has-fullscreen-tile #dashboard-grid-wrapper {
  zoom: 1 !important;
  transform: none !important;
}

/* Fullscreen Focus View Mode ([🗖]) */
.tile-card.fullscreen-focus {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100% !important;
  max-height: 100dvh !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  grid-column: auto !important;
  grid-row: auto !important;
  zoom: 1 !important;
  transform: none !important;
}

.tile-card.fullscreen-focus .tile-body {
  height: calc(100% - 44px) !important;
  max-height: calc(100dvh - 44px) !important;
}

/* Unified Signage Watermark for Fullscreen Focus & Playback Splash Mode */
.tile-card.fullscreen-focus::after,
.memo-splash-overlay::after {
  content: "iTimeBoard.com";
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Nova Round', sans-serif;
  font-size: clamp(23px, 1.9vw, 27px);
  font-weight: 400;
  letter-spacing: 0.8px;
  color: var(--custom-text, #111111);
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
  z-index: 100005;
  white-space: nowrap;
  transition: opacity var(--transition-normal);
}

[data-theme="dark"] .tile-card.fullscreen-focus:not(.custom-styled)::after,
[data-theme="dark"] .memo-splash-overlay:not(.custom-styled)::after {
  color: #ffffff;
}

.tile-card.fullscreen-focus.custom-styled::after,
.memo-splash-overlay.custom-styled::after {
  color: var(--custom-text, #111111);
}

.tile-card.fullscreen-focus.no-watermark::after,
.memo-splash-overlay.no-watermark::after,
.no-watermark .tile-card.fullscreen-focus::after,
.no-watermark .memo-splash-overlay::after {
  display: none !important;
}



.tile-card.fullscreen-focus .tile-corner-btn,
.tile-card.fullscreen-focus .timetimer-corner-btn,
.tile-card.fullscreen-focus .memo-card-splash-bottom {
  bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
}

.tile-card.fullscreen-focus .tile-corner-btn.btn-left,
.tile-card.fullscreen-focus .timetimer-corner-btn.btn-left,
.tile-card.fullscreen-focus .memo-card-splash-bottom {
  left: max(12px, env(safe-area-inset-left, 12px)) !important;
}

.tile-card.fullscreen-focus .tile-corner-btn.btn-right,
.tile-card.fullscreen-focus .timetimer-corner-btn.btn-right {
  right: max(12px, env(safe-area-inset-right, 12px)) !important;
}

.tile-card.fullscreen-focus .tile-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--custom-bg, var(--bg-tile));
  border-bottom: 1px solid var(--custom-border, var(--border-tile));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tile-card.fullscreen-focus .tile-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.03);
  pointer-events: none;
  z-index: 0;
}

.tile-card.fullscreen-focus .tile-header > * {
  position: relative;
  z-index: 1;
}

.tile-card.fullscreen-focus .btn-exit-fullscreen {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.tile-card.fullscreen-focus .btn-exit-fullscreen:hover {
  background-color: var(--accent-red);
  color: #ffffff;
}

.tile-card.fullscreen-focus.custom-styled .btn-exit-fullscreen {
  background-color: rgba(0, 0, 0, 0.08);
  color: var(--custom-text);
  border: 1px solid var(--custom-border);
}

.tile-card.fullscreen-focus.custom-styled .btn-exit-fullscreen:hover {
  background-color: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.tile-card.fullscreen-focus .tile-face {
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

.tile-card.minimized .tile-body {
  display: none !important;
}

.tile-card.minimized {
  grid-row: span 1 !important;
  height: 44px !important;
}

.tile-card.minimized .tile-face {
  height: 44px !important;
}

/* Visual Flash Effect (Pure full-face invert on the card face only, sockets are outside and 100% untouched) */
@keyframes tileInvertFlash {
  0%, 100% {
    filter: invert(0);
  }
  50% {
    filter: invert(0.95);
  }
}

.tile-card.flashing .tile-face {
  animation: tileInvertFlash 0.5s ease-in-out infinite;
}

/* Tile Header */
.tile-header {
  min-height: 44px;
  height: auto;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-top-left-radius: calc(var(--border-radius-lg) - 3px);
  border-top-right-radius: calc(var(--border-radius-lg) - 3px);
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-sizing: border-box;
}

.tile-header:active {
  cursor: grabbing;
}

.tile-header-left, .tile-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tile-header-left {
  min-width: 0;
  flex: 1 1 auto;
}

.tile-header-right {
  flex-shrink: 0;
}

.tile-btn-icon {
  border: none;
  background: transparent;
  color: var(--custom-text, var(--text-sub));
  width: 26px;
  height: 26px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.tile-btn-icon:hover {
  background-color: rgba(0, 0, 0, 0.08);
  color: var(--custom-text, var(--text-main));
}

.tile-btn-icon .lucide-icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.tile-btn-icon.btn-settings {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.tile-btn-icon.btn-settings .lucide-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

.tile-btn-icon.btn-close:hover {
  background-color: #EF4444;
  color: #FFF;
}

.ctrl-btn-danger {
  background-color: var(--accent-red);
  color: #FFF;
}

.ctrl-btn-danger:hover {
  background-color: var(--accent-red-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.tile-title-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.2;
  color: var(--custom-text, var(--text-main));
  user-select: none;
  pointer-events: auto;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  padding: 2px 4px;
  margin-left: -2px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  word-break: keep-all;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tile-title-text:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .tile-title-text:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.tile-title-inline-input {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--custom-text, var(--text-main));
  background-color: var(--bg-input);
  border: 1.5px solid var(--accent-blue);
  border-radius: var(--border-radius-sm);
  padding: 2px 8px;
  outline: none;
  width: 140px;
  max-width: 180px;
  height: 28px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Tile Body General */
.tile-body {
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: calc(100% - 44px);
  overflow: hidden;
  border-bottom-left-radius: calc(var(--border-radius-lg) - 3px);
  border-bottom-right-radius: calc(var(--border-radius-lg) - 3px);
  container-type: inline-size;
}

/* Controls Bar inside Tile Body */
.tile-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  width: 100%;
}

.ctrl-btn {
  padding: clamp(6px, 2.5cqi, 14px) clamp(12px, 4cqi, 24px);
  border-radius: var(--border-radius-md);
  border: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(0.8rem, 4cqi, 1.3rem);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ctrl-btn-primary {
  background-color: var(--accent-red);
  color: #FFFFFF;
}

.ctrl-btn-primary:hover {
  background-color: var(--accent-red-hover);
  transform: translateY(-1px);
}

/* Action-specific Control Buttons */
.ctrl-btn-play {
  background-color: #2563EB;
  color: #FFFFFF;
}

.ctrl-btn-play:hover {
  background-color: #1D4ED8;
  transform: translateY(-1px);
}

html[data-theme="dark"] .ctrl-btn-play {
  background-color: #3B82F6;
  color: #FFFFFF;
}

html[data-theme="dark"] .ctrl-btn-play:hover {
  background-color: #2563EB;
}

.ctrl-btn-pause {
  background-color: var(--accent-red);
  color: #FFFFFF;
}

.ctrl-btn-pause:hover {
  background-color: var(--accent-red-hover);
  transform: translateY(-1px);
}

.ctrl-btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-tile);
}

.ctrl-btn-secondary:hover {
  background-color: var(--border-tile);
}

/* --- Tile 1: Clock --- */
.tile-card.tile-clock .tile-body {
  padding: 0 !important;
  overflow: hidden;
}

.tile-playback-playing .clock-alarm-top-group {
  display: none !important;
}

.clock-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  container-type: size;
}

.clock-display-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Hide clock elements cleanly during picker without touching inline styles */
.tile-playback-picker-active > *:not(.memo-picker-mount),
.clock-alarm-picker-active > *:not(.time-picker-wrapper) {
  display: none !important;
}

/* Clock Tile: 50% subtle countdown on board so it does not distract from main clock time */
.tile-card.tile-clock .memo-card-splash-countdown {
  font-size: 0.48rem !important;
  opacity: 0.75;
}
.tile-card.tile-clock.span-3 .memo-card-splash-countdown {
  font-size: 0.55rem !important;
}
.tile-card.tile-clock.span-4 .memo-card-splash-countdown {
  font-size: 0.62rem !important;
}

.analog-clock-svg {
  width: 95%;
  height: 95%;
  max-width: none;
  max-height: none;
}

.tile-card.span-2 .analog-clock-svg {
  width: 90%;
  height: 90%;
}

.digital-clock-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 17cqi, 9rem);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--custom-text, var(--text-main));
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.1;
  width: 100%;
}

/* Digital Clock Fullscreen (Maximized Tile Card & Universal Splash Overlay): 2x Massive Dynamic Scaling */
.tile-card.maximized .digital-clock-display,
.tile-card.fullscreen-focus .digital-clock-display,
.memo-splash-overlay .digital-clock-display {
  font-size: clamp(3rem, min(20vw, 36vh), 18rem);
}

.tile-card.maximized .digital-city-name,
.tile-card.fullscreen-focus .digital-city-name,
.memo-splash-overlay .digital-city-name {
  font-size: clamp(1.2rem, 2.5vw, 2.6rem);
  margin-top: clamp(12px, 2vh, 24px);
}

.digital-time-main {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  position: relative;
}

.digital-digits-hm {
  font-variant-numeric: tabular-nums;
}

.digital-seconds-wrap {
  position: relative;
  display: inline-flex;
  align-items: baseline;
}

.digital-colon {
  margin: 0 1px;
}

.digital-digits-ss {
  font-variant-numeric: tabular-nums;
}

/* AM/PM: 초(Seconds) 위쪽에 단정하게 얹혀 균형을 맞추고, 시간색상(커스텀색상)과 완벽 동기화 */
.digital-ampm-above {
  position: absolute;
  top: -0.28em;
  right: 0;
  font-size: 0.28em;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--custom-text, var(--text-main));
  letter-spacing: 0.5px;
  line-height: 1;
}

.digital-city-name {
  font-size: 0.25em;
  color: var(--custom-text, var(--text-sub));
  font-weight: 700;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.clock-ampm-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: var(--font-heading);
  font-size: clamp(0.72rem, 3.2cqi, 0.95rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-sub));
  background-color: rgba(0, 0, 0, 0.05);
  padding: 3px 6px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  user-select: none;
  z-index: 10;
  line-height: 1.2;
}

html[data-theme="dark"] .clock-ampm-badge {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Top-Right Alarm Controls Group (Time Chip + Bell Toggle Button) */
.clock-alarm-top-group {
  position: absolute;
  top: 4px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  z-index: 10;
}

/* Bottom-Right Remaining Countdown Badge (Shown only when alarm is active) */
.clock-remaining-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  color: var(--custom-text, var(--text-sub));
  font-family: var(--font-heading);
  font-size: clamp(0.72rem, 3.2cqi, 0.95rem);
  font-weight: 700;
  letter-spacing: -0.2px;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: 0.85;
  pointer-events: none;
}

.clock-remaining-badge .lucide-icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

.alarm-badge,
.clock-alarm-time-badge {
  position: relative;
  background-color: transparent;
  color: var(--custom-text, var(--text-main));
  padding: 2px 4px;
  border-radius: 6px;
  font-size: clamp(0.7rem, 3cqi, 0.92rem);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
  transition: transform var(--transition-fast), opacity var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.alarm-badge .lucide-icon,
.clock-alarm-time-badge .lucide-icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}

.alarm-time-main {
  font-weight: 700;
}

.alarm-badge:hover,
.clock-alarm-time-badge:hover {
  background-color: rgba(128, 128, 128, 0.08);
  transform: scale(1.04);
}

.alarm-badge.off,
.clock-alarm-time-badge.off {
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
  color: var(--custom-text, var(--text-main)) !important;
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

/* Independent Alarm Toggle Button */
.clock-alarm-toggle-btn {
  position: relative;
  background-color: transparent;
  color: var(--custom-text, var(--text-main));
  padding: 2px 4px;
  border-radius: 6px;
  font-size: clamp(0.7rem, 3cqi, 0.92rem);
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), opacity var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.clock-alarm-toggle-btn .lucide-icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}

.clock-alarm-toggle-btn:hover {
  background-color: rgba(128, 128, 128, 0.08);
  transform: scale(1.08);
}

.clock-alarm-toggle-btn.off {
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
  color: var(--custom-text, var(--text-main)) !important;
  opacity: 0.45;
  filter: grayscale(1);
}

.alarm-hand-group line,
.alarm-hand-group circle {
  transition: stroke 0.3s ease, opacity 0.3s ease;
}

/* --- Tile 2: Stopwatch --- */
.stopwatch-display {
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 18cqi, 9.5rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-main));
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  display: inline-block;
  text-align: center;
  white-space: nowrap;
  line-height: 1;
  transition: font-size var(--transition-fast);
}

.stopwatch-display.has-hours {
  font-size: clamp(1.65rem, 13.5cqi, 7.2rem);
}

.stopwatch-start-badge {
  font-family: var(--font-heading), var(--font-body);
  font-size: clamp(0.75rem, 5.4cqi, 2.85rem);
  font-weight: 700;
  color: var(--custom-text, var(--text-main));
  margin-top: clamp(4px, 1.2cqi, 14px);
  letter-spacing: -0.2px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.stopwatch-display.has-hours ~ .stopwatch-start-badge {
  font-size: clamp(0.7rem, 4.05cqi, 2.2rem);
}

.lap-list-container {
  width: 90%;
  max-height: 26%;
  overflow-y: auto;
  margin-top: 6px;
  margin-bottom: 32px;
  border-top: 1px solid var(--border-tile);
  padding-top: 4px;
}

.lap-item {
  display: flex;
  justify-content: space-between;
  font-size: clamp(0.75rem, 3.5cqi, 1.1rem);
  padding: 2px 4px;
  color: var(--text-sub);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Stopwatch Fullscreen (Maximized & Fullscreen Focus Mode): 2x Massive Dynamic Scaling */
.tile-card.maximized .stopwatch-display,
.tile-card.fullscreen-focus .stopwatch-display {
  font-size: clamp(4.4rem, min(20vw, 34vh), 19rem);
  line-height: 1;
}

.tile-card.maximized .stopwatch-display.has-hours,
.tile-card.fullscreen-focus .stopwatch-display.has-hours {
  font-size: clamp(3.2rem, min(15vw, 26vh), 14.5rem);
}

.tile-card.maximized .stopwatch-start-badge,
.tile-card.fullscreen-focus .stopwatch-start-badge {
  font-size: clamp(1.3rem, min(4vw, 5vh), 3.2rem);
  margin-top: clamp(12px, 2.5vh, 28px);
}

.tile-card.maximized .stopwatch-display.has-hours ~ .stopwatch-start-badge,
.tile-card.fullscreen-focus .stopwatch-display.has-hours ~ .stopwatch-start-badge {
  font-size: clamp(1.1rem, min(3.5vw, 4.2vh), 2.6rem);
}

.tile-card.maximized .lap-list-container,
.tile-card.fullscreen-focus .lap-list-container {
  max-height: 32%;
  margin-top: clamp(12px, 2vh, 24px);
}

.tile-card.maximized .lap-item,
.tile-card.fullscreen-focus .lap-item {
  font-size: clamp(1.1rem, 1.8vw, 1.6rem);
  padding: 8px 16px;
}

/* --- Tile 3: Time Timer --- */
.timetimer-container {
  position: relative;
  width: 100%;
  height: 100%;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timetimer-disc-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 95cqmin;
  height: 95cqmin;
  max-width: 95%;
  max-height: 95%;
  border-radius: 50%;
  overflow: hidden;
  cursor: default;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timetimer-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Center pivot knob trigger (~20% radius area) */
.timetimer-center-trigger {
  cursor: pointer;
}

.timetimer-center-trigger .center-knob-base {
  transition: stroke var(--transition-fast), stroke-width var(--transition-fast), filter var(--transition-fast);
}

.timetimer-container:not(.is-adjusting) .timetimer-center-trigger:hover .center-knob-base {
  stroke: var(--accent-blue);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px rgba(79, 142, 247, 0.45));
}

.timetimer-container:not(.is-adjusting) .timetimer-center-trigger:hover .center-knob-dot {
  fill: var(--accent-blue);
}

/* Lower Time Label trigger */
.timetimer-lower-trigger {
  cursor: pointer;
}

.timetimer-lower-label {
  font-family: var(--font-heading), var(--font-mono), monospace;
  font-weight: 800;
  fill: var(--custom-text, var(--text-main));
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  z-index: 4;
  transition: fill var(--transition-fast);
}

.timetimer-container:not(.is-adjusting) .timetimer-lower-trigger:hover .timetimer-lower-label {
  fill: var(--accent-blue);
}

/* Circle Timer Adjustment Mode Visuals */
.timetimer-container.is-adjusting .timetimer-disc-wrapper {
  cursor: grab;
}

.timetimer-container.is-adjusting.is-dragging .timetimer-disc-wrapper {
  cursor: grabbing;
}

.timetimer-focus-ring {
  animation: timerRingPulse 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes timerRingPulse {
  0%, 100% {
    stroke-opacity: 0.9;
    stroke-width: 2.2;
  }
  50% {
    stroke-opacity: 0.45;
    stroke-width: 1.6;
  }
}

.timetimer-knob-handle {
  pointer-events: none;
  transition: transform 0.04s ease-out;
}

.timetimer-label-pill {
  pointer-events: none;
  animation: fadeInFast 0.15s ease-out;
}

/* Unified Corner Control Buttons (Play, Start, Reset, Complete) */
.tile-corner-btn,
.timetimer-corner-btn,
.btn-splash-close-only,
.btn-card-splash-close {
  padding: 6px 14px;
  font-size: 0.88rem;
  border-radius: var(--border-radius-sm);
}

.tile-corner-btn,
.timetimer-corner-btn {
  position: absolute;
  bottom: 6px;
  z-index: 5;
}

.tile-playback-duration {
  padding: 4px 8px !important;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.tile-corner-btn.btn-left,
.timetimer-corner-btn.btn-left {
  left: 6px;
}

.tile-corner-btn.btn-right,
.timetimer-corner-btn.btn-right {
  right: 6px;
}

/* --- Tile 4: Digital Timer --- */
.digital-timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  width: 100%;
  position: relative;
  gap: clamp(2px, 1.2cqi, 10px);
  container-type: size;
}

.digital-timer-picker-mount {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.digital-timer-days-badge {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 16cqi, 8.5rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-main));
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.digital-timer-display {
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 18cqi, 9.5rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-main));
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.digital-timer-container.has-days .digital-timer-days-badge,
.digital-timer-container.has-days .digital-timer-display {
  font-size: clamp(1.6rem, 12.5cqi, 6.2rem);
  line-height: 1.05;
}

.digital-timer-target-time {
  font-family: var(--font-heading), var(--font-body);
  font-size: clamp(0.75rem, 5.4cqi, 2.85rem);
  font-weight: 700;
  color: var(--custom-text, var(--text-main));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2cqi, 12px);
  letter-spacing: -0.2px;
  line-height: 1.2;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  opacity: 0.35;
  transition: opacity var(--transition-fast);
}

.digital-timer-container.has-days .digital-timer-target-time {
  font-size: clamp(0.7rem, 3.75cqi, 1.9rem);
}

.digital-timer-target-time .target-time-text {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.digital-timer-target-time .target-bell-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex-shrink: 0;
}

.digital-timer-target-time .lucide-icon {
  width: 0.95em;
  height: 0.95em;
}

.digital-timer-container.is-running .digital-timer-target-time {
  opacity: 1;
}

/* Digital Timer Fullscreen (Maximized & Fullscreen Focus Mode): 2x Massive Dynamic Scaling */
.tile-card.maximized .digital-timer-container,
.tile-card.fullscreen-focus .digital-timer-container {
  gap: clamp(12px, 2.5vh, 28px);
}

.tile-card.maximized .digital-timer-display,
.tile-card.fullscreen-focus .digital-timer-display {
  font-size: clamp(4.4rem, min(20vw, 34vh), 19rem);
  line-height: 1;
}

.tile-card.maximized .digital-timer-days-badge,
.tile-card.fullscreen-focus .digital-timer-days-badge {
  font-size: clamp(4rem, min(18vw, 30vh), 17rem);
  line-height: 1;
}

.tile-card.maximized .digital-timer-container.has-days .digital-timer-days-badge,
.tile-card.maximized .digital-timer-container.has-days .digital-timer-display,
.tile-card.fullscreen-focus .digital-timer-container.has-days .digital-timer-days-badge,
.tile-card.fullscreen-focus .digital-timer-container.has-days .digital-timer-display {
  font-size: clamp(3rem, min(14vw, 24vh), 13rem);
  line-height: 1.05;
}

.tile-card.maximized .digital-timer-target-time,
.tile-card.fullscreen-focus .digital-timer-target-time {
  font-size: clamp(1.3rem, min(4vw, 5vh), 3.2rem);
  gap: clamp(8px, 1.2vw, 16px);
  margin-top: 4px;
}

.tile-card.maximized .digital-timer-target-time .lucide-icon,
.tile-card.fullscreen-focus .digital-timer-target-time .lucide-icon {
  width: 1.15em;
  height: 1.15em;
}

/* --- Tile 5: D-day --- */
.tile-card.tile-dday .tile-body {
  padding: 0 !important;
  overflow: hidden;
}

.dday-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  height: 100%;
  width: 100%;
  gap: clamp(3px, 1.2cqi, 10px);
  padding: 6px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.dday-main-badge {
  font-family: var(--font-heading);
  font-size: clamp(2.3rem, 20cqi, 9rem);
  font-weight: 800;
  color: var(--accent-red);
  letter-spacing: -1px;
  line-height: 1.05;
  white-space: nowrap;
}

.dday-sub-countdown {
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 7.5cqi, 3.4rem);
  font-weight: 700;
  color: var(--custom-text, var(--text-sub));
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}

.dday-target-date {
  font-size: clamp(0.72rem, 4.2cqi, 1.9rem);
  color: var(--custom-text, var(--text-muted));
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.15;
}

.dday-target-date .lucide-icon {
  width: 1.1em;
  height: 1.1em;
}

/* D-day Fullscreen Focus & Splash Scaling (2x sizing) */
.tile-card.fullscreen-focus .dday-container,
.memo-splash-center-wrap .dday-container {
  gap: clamp(14px, 3vh, 32px);
  padding: 24px;
}

.tile-card.fullscreen-focus .dday-main-badge,
.memo-splash-center-wrap .dday-main-badge {
  font-size: clamp(4.5rem, min(24vw, 32vh), 18rem);
  line-height: 1.0;
  letter-spacing: -2px;
}

.tile-card.fullscreen-focus .dday-sub-countdown,
.memo-splash-center-wrap .dday-sub-countdown {
  font-size: clamp(1.8rem, min(9vw, 11vh), 6.8rem);
  line-height: 1.1;
}

.tile-card.fullscreen-focus .dday-target-date,
.memo-splash-center-wrap .dday-target-date {
  font-size: clamp(1.3rem, min(5vw, 6vh), 3.6rem);
  gap: 12px;
  line-height: 1.15;
}

.tile-card.fullscreen-focus .dday-target-date .lucide-icon,
.memo-splash-center-wrap .dday-target-date .lucide-icon {
  width: 1.15em;
  height: 1.15em;
}

/* When tile alarm is ringing, hide bottom corner buttons to focus on ringing bell */
.tile-card.flashing .tile-corner-btn {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity var(--transition-fast);
}

/* --- Alarm Dismiss Overlay & Ringing Bell --- */
.alarm-dismiss-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 60;
  border-radius: inherit;
  cursor: pointer;
}

/* --- Settings Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  background-color: var(--bg-tile);
  border: 1px solid var(--border-tile);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: min(440px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-tile);
  padding-bottom: 12px;
  flex-shrink: 0;
}

#modal-settings-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

#modal-settings-form::-webkit-scrollbar {
  width: 5px;
}

#modal-settings-form::-webkit-scrollbar-track {
  background: transparent;
}

#modal-settings-form::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}

html[data-theme="dark"] #modal-settings-form::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
}

.form-control {
  padding: 9px 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-input);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-blue);
}

.form-control:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-control.input-invalid {
  border-color: var(--accent-red) !important;
  background-color: rgba(239, 68, 68, 0.05);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
  animation: shakeX 0.25s ease-in-out;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.field-error-msg {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-red);
  margin-top: 4px;
  animation: modalFadeIn 0.15s ease;
}

.btn-theme-reset-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-input);
  background-color: var(--bg-input);
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-theme-reset-pill:hover {
  background-color: var(--border-tile);
  color: var(--text-main);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

/* Circle Timer Range Selector (10m, 30m, 60m, 120m) */
.timer-range-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.range-pill-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-input);
  background-color: var(--bg-input);
  color: var(--text-sub);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.range-pill-label:hover {
  background-color: var(--border-tile);
  color: var(--text-main);
}

.range-pill-label.active {
  background-color: #2563EB;
  border-color: #2563EB;
  color: #FFFFFF;
}

html[data-theme="dark"] .range-pill-label.active {
  background-color: #3B82F6;
  border-color: #3B82F6;
  color: #FFFFFF;
}

/* Circle Timer Disc Color Selector (Yellow, Pink, Red, Green, Custom) */
.disc-color-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.disc-color-chip-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  min-height: 48px;
  border-radius: var(--border-radius-md);
  border: 1.5px solid var(--border-input);
  background-color: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.disc-color-chip-wrap:hover {
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.disc-color-chip-wrap.active {
  border-color: #2563EB;
  background-color: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 1px #2563EB;
}

html[data-theme="dark"] .disc-color-chip-wrap.active {
  border-color: #3B82F6;
  background-color: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 0 1px #3B82F6;
}

.disc-color-svg {
  width: 34px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

html[data-theme="dark"] .disc-color-svg circle:first-child {
  fill: rgba(255, 255, 255, 0.12);
}

.disc-color-chip-wrap:hover .disc-color-svg {
  transform: scale(1.08);
}

.disc-color-chip-wrap.active .disc-color-svg {
  transform: scale(1.12);
}

/* Custom chip: rainbow sector until selected, then the user's chosen color */
.disc-color-chip-wrap.active[data-color="custom"] .disc-sector {
  fill: var(--custom-disc);
}

/* Unified Custom Color Box (1 Box, 2 Rows) */
.custom-color-unified-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--border-radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* Row 1: 10 Preset Color Chips */
.preset-chip-list {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  width: 100%;
  align-items: center;
}

.preset-color-chip {
  width: 100%;
  max-width: 25px;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.preset-color-chip:hover {
  transform: scale(1.22);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.preset-color-chip.active {
  transform: scale(1.18);
  box-shadow: 0 0 0 2.5px var(--accent-blue);
  position: relative;
}

.chip-inner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
}

/* Row 2: Direct Custom Color Swatches */
.color-control-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--border-tile);
  padding-top: 10px;
  width: 100%;
}

.color-inline-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-input);
  min-width: 0;
  width: 100%;
}

.color-inline-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: var(--text-muted);
}

html[data-theme="dark"] .color-inline-item {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .color-inline-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.color-inline-item span {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  user-select: none;
  text-align: center;
}

.custom-color-swatch-btn {
  width: 100%;
  max-width: 44px;
  height: 20px;
  border-radius: 5px;
  border: 1.5px solid rgba(0, 0, 0, 0.16);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

html[data-theme="dark"] .custom-color-swatch-btn {
  border: 1.5px solid rgba(255, 255, 255, 0.28);
}

.color-inline-item:hover .custom-color-swatch-btn {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.18);
}

.inline-preview-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  user-select: none;
  flex-shrink: 0;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

/* --- In-App Standalone Color Picker Popover --- */
.color-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10005;
  animation: modalFadeIn 0.15s ease-out;
}

.color-picker-card {
  background-color: var(--bg-tile);
  border: 1px solid var(--border-tile);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
  width: 90%;
  max-width: 300px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: modalFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.color-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-tile);
  padding-bottom: 8px;
}

.color-picker-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.color-picker-current-preview {
  width: 48px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border-tile);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

html[data-theme="dark"] .color-picker-current-preview {
  border-color: rgba(255, 255, 255, 0.28);
}

.color-picker-close-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.color-picker-close-btn:hover {
  background-color: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

.color-picker-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.color-picker-palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.color-picker-chip {
  width: 100%;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  display: block;
}

html[data-theme="dark"] .color-picker-chip {
  border-color: rgba(255, 255, 255, 0.18);
}

.color-picker-chip:hover {
  transform: scale(1.15);
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.color-picker-chip.active {
  transform: scale(1.10);
  box-shadow: 0 0 0 2px var(--accent-blue);
  position: relative;
  z-index: 1;
}

.color-picker-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-slider {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  border-radius: 7px;
  outline: none;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .color-slider {
  border-color: rgba(255, 255, 255, 0.25);
}

.color-slider-hue {
  background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
}

.color-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.color-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.color-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.color-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-tile);
}

.color-picker-hex-wrap {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--border-radius-sm);
  padding: 3px 6px;
  width: 86px;
}

.color-picker-hex-hash {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
  margin-right: 2px;
}

.color-picker-hex-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
}

.color-picker-action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-picker-cancel-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.color-picker-confirm-btn {
  padding: 4px 12px;
  font-size: 0.78rem;
}

/* Compact D-day Date Picker */
.dday-date-picker-wrap {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: 240px;
}

.custom-date-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 190px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--border-radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-date-box:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.custom-date-box .weekday-pill {
  color: var(--accent-blue);
  font-weight: 700;
  pointer-events: none;
}

.custom-date-box .cal-icon {
  margin-left: auto;
  font-size: 1rem;
  opacity: 0.75;
  pointer-events: none;
}

.hidden-date-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  background-color: var(--bg-tile);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  padding-bottom: 2px;
  border-top: 1px solid var(--border-tile);
  flex-shrink: 0;
  z-index: 5;
}




/* --- Responsive Viewport Padding (< 768px) --- */
@media (max-width: 768px) {
  .dashboard-viewport {
    padding: 12px 10px;
    padding-bottom: max(80px, calc(env(safe-area-inset-bottom, 0px) + 60px));
  }
}

/* --- Node Ports (Automation Chaining) --- */
/* --- Node Ports (Automation Chaining) --- */
.node-port {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
  touch-action: none;
}

.port-icon-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.port-icon-inner .lucide-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.2px;
}

/* Hit area pseudo-element for easy clicking/dragging */
.node-port::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
}

.node-port:active {
  cursor: grabbing !important;
}

/* Input Port: Socket (Left border next to Start Button) */
.node-port-input {
  left: -10px;
  bottom: 18px;
  border: 2px solid #10b981;
  background-color: #ffffff;
  color: #10b981;
  cursor: default; /* Empty socket: cannot be dragged */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Pointer points straight towards the Start Button (East / inward) */
.node-port-input .port-icon-inner {
  transform: none;
}

/* When a cable is plugged into the input socket, it becomes filled and can be unplugged! */
.node-port-input.is-connected {
  background-color: #10b981;
  color: #ffffff;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.45);
}

.node-port-input.port-hover-snap {
  transform: scale(1.35);
  border-color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.7);
}

.node-port-input:hover.is-connected {
  transform: scale(1.25);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

/* Output Port: Plug (Center of bottom border) */
.node-port-output {
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  border: 2px solid #10b981;
  background-color: #ffffff; /* Empty socket before connection */
  color: #10b981;
  cursor: grab; /* Grab to connect */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Pointer points straight downward (South / exiting) */
.node-port-output .port-icon-inner {
  transform: none;
}

/* When output has a connected wire, it becomes filled! */
.node-port-output.is-connected {
  background-color: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.45);
}

.node-port-output:hover {
  transform: translateX(-50%) scale(1.25);
  border-color: #059669;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.7);
}

/* Hide node ports in Fullscreen Focus Mode */
.tile-card.fullscreen-focus .node-port {
  display: none !important;
}

/* Dim ports during layout edit mode */
.layout-edit-mode .node-port {
  opacity: 0.25;
  pointer-events: none;
}

/* --- While Dragging a Wire: suppress all non-target ports & maintain grabbing cursor --- */
body.is-wire-dragging,
body.is-wire-dragging * {
  cursor: grabbing !important;
}

/* While dragging, ALL output ports are completely non-interactive */
body.is-wire-dragging .node-port-output {
  pointer-events: none !important;
  transform: translateX(-50%) !important;
  box-shadow: none !important;
}

/* While dragging, the source tile's own input port is disabled (cannot connect to self) */
body.is-wire-dragging .node-port-input.is-source-self {
  pointer-events: none !important;
  opacity: 0.25 !important;
  transform: none !important;
  box-shadow: none !important;
}

body.is-wire-dragging .node-port-input.port-hover-snap {
  transform: scale(1.4) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.85) !important;
}

/* --- SVG Wires Layer --- */
.node-wires-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

/* Individual wire path: Unified signature emerald green (halved stroke width) */
.node-wire-path {
  fill: none;
  stroke: #10b981;
  stroke-width: 1.4px;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
  transition: opacity 0.18s ease, stroke 0.18s ease, stroke-width 0.18s ease, filter 0.18s ease;
}

/* Invisible hitbox path on top of wire for effortless hover */
.node-wire-hitbox {
  fill: none;
  stroke: transparent;
  stroke-width: 14px;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  pointer-events: stroke;
}

/* Multi-wire Focus and Dimming */
body.has-wire-focus .node-wire-path:not(.is-focused) {
  opacity: 0.18 !important;
  filter: none !important;
}

body.has-wire-focus .node-wire-path.is-focused {
  opacity: 1 !important;
  stroke: #10b981 !important;
  stroke-width: 2.2px !important;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.85)) !important;
}

/* Connected ports pulse/scale during wire focus */
.node-port.is-port-focused {
  transform: scale(1.22) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.5), 0 0 10px rgba(16, 185, 129, 0.9) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
  z-index: 25 !important;
}

/* Temporary dragging wire */
.node-wire-path.is-dragging {
  stroke: #10b981;
  stroke-width: 3px;
  stroke-dasharray: 8 6;
  animation: wireMarchingAnts 0.6s linear infinite;
}

@keyframes wireMarchingAnts {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -14; }
}

/* When signal triggers (Step 3 Automation Chaining) */
.node-wire-path.is-active {
  stroke: #059669 !important;
  stroke-width: 2.2px !important;
  stroke-dasharray: 6 4;
  animation: wireSignalPulse 0.4s linear infinite;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.9)) !important;
}

@keyframes wireSignalPulse {
  from { stroke-dashoffset: 28; }
  to { stroke-dashoffset: 0; }
}

/* Target port pulse when signal arrives (Doubled duration to 3.0s with rhythmic breathing heartbeat & expanding glow rings) */
.node-port-input.port-signal-received {
  animation: portSignalPing 0.75s cubic-bezier(0.25, 1, 0.5, 1) 4 !important;
  z-index: 30 !important;
}

@keyframes portSignalPing {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.9);
  }
  35% {
    transform: scale(1.65);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.6), 0 0 20px 4px rgba(16, 185, 129, 0.95);
  }
  70% {
    transform: scale(0.92);
    box-shadow: 0 0 0 16px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* In Fullscreen focus mode, hide wires */
body.has-fullscreen-tile .node-wires-layer {
  display: none !important;
}

/* When Automation Mode is Disabled (OFF) */
body.automation-disabled .node-port {
  display: none !important;
}

body.automation-disabled #node-wires-layer,
body.automation-disabled .node-wires-layer {
  display: none !important;
}

/* Universal Playback Controls: Hide when automation is OFF */
body.automation-disabled .tile-playback-start,
body.automation-disabled .tile-playback-duration,
body.automation-disabled .tile-memo .btn-memo-start,
body.automation-disabled .tile-memo .btn-memo-duration,
body.automation-disabled .tile-calendar .btn-cal-start,
body.automation-disabled .tile-calendar .btn-cal-duration {
  display: none !important;
}

body.automation-disabled .tile-memo .memo-container.has-corner-btn {
  padding-bottom: 8px !important;
}

/* Automation Mode: Hide initial Start / Play button on tiles with an incoming wire */
body:not(.automation-disabled) .tile-card.has-input-wire .ctrl-btn-start,
body:not(.automation-disabled) .tile-card.has-input-wire .tile-playback-start {
  display: none !important;
}

/* ==========================================================================
   iTimeBoard Mini Memo (Sticky Note) & Center Splash Overlay
   ========================================================================== */

/* Tile Card: Memo Custom Styling */
.tile-card.tile-memo .tile-body {
  padding: 0 !important;
  overflow: hidden;
}

.memo-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Plain Text Mode */
.memo-text-container {
  padding: 8px 12px;
}

.memo-container.has-corner-btn {
  padding-bottom: 46px;
}

.memo-picker-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.btn-memo-duration {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
  color: var(--custom-text, var(--text-main));
}

.btn-memo-duration.is-infinite {
  font-family: var(--font-body);
  letter-spacing: normal;
}

.memo-textarea {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--custom-text, var(--text-main));
  padding: 0;
  box-sizing: border-box;
}

.memo-textarea::placeholder {
  color: var(--custom-text, var(--text-sub));
  opacity: 0.65;
}

/* Checklist Mode */
.memo-checklist-container {
  padding: 6px 8px;
  overflow-x: hidden;
}

.memo-checklist-items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
  cursor: text;
}

.memo-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.85rem;
  color: var(--custom-text, var(--text-sub));
  opacity: 0.7;
  cursor: pointer;
  user-select: none;
}

.memo-chk-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 4px;
  border-radius: var(--border-radius-sm);
  transition: background var(--transition-fast);
  width: 100%;
  box-sizing: border-box;
}

.memo-chk-row:hover {
  background: rgba(128, 128, 128, 0.08);
}

[data-theme="dark"] .memo-chk-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.memo-chk-label {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.memo-chk-box {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.memo-chk-text {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--custom-text, var(--text-main));
  padding: 1px 0;
  resize: none;
  overflow: hidden;
  word-break: break-all;
  overflow-wrap: break-word;
  box-sizing: border-box;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

.memo-chk-row.is-completed .memo-chk-text {
  text-decoration: line-through;
  opacity: 0.5;
  color: var(--custom-text, var(--text-sub));
}

.memo-item-del-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--custom-text, var(--text-sub));
  opacity: 0;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 1px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.memo-chk-row:hover .memo-item-del-btn {
  opacity: 0.6;
}

.memo-item-del-btn:hover {
  opacity: 1 !important;
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   Center Splash Popup Overlay (Box-less Cinematic Screen Display)
   ========================================================================== */
.memo-splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  background: var(--splash-bg, var(--bg-tile));
  color: var(--splash-text, var(--text-main));
  transition: opacity 0.2s ease;
}

.memo-splash-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.memo-splash-backdrop {
  position: absolute;
  inset: 0;
}

/* Top Progress Track (Substantial 18px line for effortless visibility) */
.memo-splash-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: rgba(128, 128, 128, 0.25);
  z-index: 100001;
  overflow: hidden;
}

.memo-splash-progress-bar {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #6366f1);
  transform-origin: left center;
  transform: scaleX(1);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.9), inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

.memo-splash-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 16px #ffffff, 0 0 32px #38bdf8;
  border-radius: 999px;
}

/* Top Right Minimize (Return to Board) Icon Button */
.memo-splash-btn-minimize {
  position: fixed;
  top: 6px;
  right: 10px;
  z-index: 100003;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-sm);
  color: currentColor;
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition-fast), background-color var(--transition-fast), opacity var(--transition-fast);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
  opacity: 0.9;
}

.memo-splash-btn-minimize:hover {
  background-color: rgba(128, 128, 128, 0.18);
  transform: scale(1.08);
  opacity: 1;
}

.memo-splash-btn-minimize:active {
  transform: scale(0.95);
}

.memo-splash-btn-minimize svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

/* Top Right Time (Box-less HUD text inheriting theme color) */
.memo-splash-top-info,
.memo-splash-top-bar {
  position: fixed;
  top: 36px;
  right: 48px;
  z-index: 100001;
  pointer-events: none;
}

.memo-splash-countdown-text {
  font-family: var(--font-mono);
  font-size: clamp(1.2rem, 2.2vw, 2.2rem);
  font-weight: 800;
  color: inherit;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  user-select: none;
  line-height: 1;
}

/* Clock Fullscreen Splash AM/PM badge (Symmetric with countdown text on top right) */
.clock-splash-ampm-badge {
  position: absolute;
  top: 36px;
  left: 48px;
  font-size: clamp(1.1rem, 2vw, 1.8rem);
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--custom-text, var(--text-muted));
  letter-spacing: 0.5px;
  user-select: none;
  z-index: 100001;
  opacity: 0.85;
}

/* Center Box-less Content (Widened area fitting comfortably) */
.memo-splash-center-wrap {
  position: relative;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 95%;
  max-width: min(1760px, 95vw);
  height: 100%;
  max-height: 88vh;
  padding: 50px 36px 80px;
  box-sizing: border-box;
  overflow-y: auto;
  text-align: center;
  transform: scale(0.97) translateZ(0);
  transition: transform 0.2s ease;
}

.memo-splash-center-wrap .memo-splash-text,
.memo-splash-center-wrap .memo-splash-checklist {
  margin-block: auto;
}

/* ==========================================================================
   Full-Screen Splash View for Clock Tile inside commonPlayback
   ========================================================================== */
.memo-splash-overlay:has(.clock-splash-container) .memo-splash-center-wrap {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100vh;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memo-splash-overlay:has(.clock-splash-container) .clock-splash-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  container-type: size;
}

.memo-splash-overlay:has(.clock-splash-container) .clock-splash-container .analog-clock-svg {
  width: 95%;
  height: 95%;
  max-width: min(92vh, 95vw);
  max-height: min(92vh, 95vw);
}

.memo-splash-overlay:has(.clock-splash-container) .clock-splash-container .digital-clock-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 30% subtle countdown on fullscreen splash for clock */
.memo-splash-overlay:has(.clock-splash-container) .memo-splash-countdown-text {
  font-size: clamp(0.72rem, 1.35vw, 1.05rem) !important;
  opacity: 0.8;
}

/* ==========================================================================
   Full-Screen Splash View for Mini Calendar inside commonPlayback
   ========================================================================== */
.memo-splash-overlay:has(.calendar-tile-container) .memo-splash-center-wrap {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100vh;
  padding: clamp(14px, 2.5vw, 36px) clamp(20px, 4vw, 60px) 72px;
  box-sizing: border-box;
  overflow: hidden;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view {
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .calendar-nav-header {
  padding: 0 clamp(8px, 1.5vw, 24px) clamp(10px, 2vw, 24px);
  gap: clamp(20px, 3vw, 44px);
  flex-shrink: 0;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .cal-display-year {
  font-size: clamp(1.8rem, 2.5vw, 3rem);
  font-weight: 800;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .cal-display-month {
  font-size: clamp(2.4rem, 3.8vw, 4.4rem);
  font-weight: 800;
  color: var(--primary, #3b82f6);
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .btn-cal-nav {
  width: clamp(48px, 5vw, 68px);
  height: clamp(48px, 5vw, 68px);
  pointer-events: none;
  opacity: 0.6;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .btn-cal-nav svg {
  width: clamp(28px, 3.2vw, 40px);
  height: clamp(28px, 3.2vw, 40px);
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .calendar-weekdays-row {
  font-size: clamp(1.3rem, 2vw, 2.2rem);
  font-weight: 800;
  padding-bottom: clamp(10px, 1.5vw, 18px);
  margin-bottom: clamp(6px, 1vw, 12px);
  flex-shrink: 0;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .calendar-days-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: clamp(2px, 0.5vw, 8px);
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .cal-day-num {
  font-size: clamp(1.4rem, 2vw, 2.5rem);
  font-weight: 800;
  width: clamp(34px, 4vw, 56px);
  height: clamp(34px, 4vw, 56px);
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .cal-dday-list {
  margin-top: -4px;
}

.memo-splash-center-wrap .calendar-tile-container.is-splash-view .cal-dday-name {
  font-size: clamp(0.95rem, 1.3vw, 1.6rem);
  line-height: 1.25;
  gap: 4px;
}

.memo-splash-overlay.is-visible .memo-splash-center-wrap {
  transform: scale(1) translateZ(0);
}

/* Massive, Balanced Typography with smooth cinematic floating shadow */
.memo-splash-text {
  font-size: clamp(3.4rem, 6.8vw, 6.2rem);
  font-weight: 800;
  color: inherit;
  line-height: 1.32;
  letter-spacing: -1.5px;
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  text-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.35),
    0 18px 40px rgba(0, 0, 0, 0.28),
    0 28px 60px rgba(0, 0, 0, 0.20);
  user-select: text;
}

.memo-splash-checklist {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1050px;
  width: 100%;
  text-align: left;
}

.memo-splash-chk-item {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: clamp(2.6rem, 5.5vw, 4.6rem);
  font-weight: 700;
  color: inherit;
  text-shadow: 
    0 6px 14px rgba(0, 0, 0, 0.32),
    0 14px 30px rgba(0, 0, 0, 0.25),
    0 22px 48px rgba(0, 0, 0, 0.18);
}

.memo-splash-chk-item.is-completed {
  text-decoration: line-through;
  opacity: 0.4;
}

.memo-splash-chk-icon {
  font-size: clamp(2.8rem, 6vw, 5rem);
  color: #38bdf8;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3)) drop-shadow(0 14px 28px rgba(0, 0, 0, 0.2));
}

/* Bottom Left Complete Button in Fullscreen Splash */
.memo-splash-bottom-bar {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  left: max(12px, env(safe-area-inset-left, 12px));
  z-index: 100001;
}

.btn-splash-close-only {
  border: none;
  background: var(--accent-red);
  color: #FFFFFF !important;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: -0.2px;
  cursor: pointer;
  opacity: 1;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-splash-close-only:hover {
  background: var(--accent-red-hover);
  color: #FFFFFF !important;
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.45);
}

.btn-splash-close-only:active {
  transform: translateY(0);
}

/* ==========================================================================
   In-Card Splash View for Mini Memo (Normal Dashboard Mode)
   ========================================================================== */

.memo-card-splash {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  background-color: var(--custom-bg, var(--bg-tile));
  color: var(--custom-text, var(--text-main));
  animation: memoCardSplashFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes memoCardSplashFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.memo-card-splash-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(128, 128, 128, 0.16);
  z-index: 10;
  overflow: hidden;
}

.memo-card-splash-bar {
  height: 100%;
  width: 100%;
  background: #38bdf8;
  transform-origin: left center;
  transition: transform 0.08s linear;
}

.memo-card-splash-top-info {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 10;
}

.memo-card-splash-countdown {
  font-size: 0.76rem;
  font-weight: 800;
  color: inherit;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.memo-card-splash-content {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 20px 12px 28px;
  box-sizing: border-box;
  text-align: center;
}

.memo-card-splash-content .memo-splash-text,
.memo-card-splash-content .memo-splash-checklist {
  margin-block: auto;
}

.memo-card-splash .memo-splash-text {
  font-size: clamp(1.05rem, 3.8vw, 1.35rem);
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.3px;
  color: inherit;
  word-break: break-word;
  white-space: pre-wrap;
  text-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.25),
    0 6px 14px rgba(0, 0, 0, 0.18),
    0 12px 22px rgba(0, 0, 0, 0.12);
}

.memo-card-splash .memo-splash-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  text-align: left;
}

.memo-card-splash .memo-splash-chk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: inherit;
  text-shadow: 
    0 2px 5px rgba(0, 0, 0, 0.22),
    0 5px 12px rgba(0, 0, 0, 0.15);
}

.memo-card-splash .memo-splash-chk-icon {
  font-size: 1.1rem;
  color: #38bdf8;
  flex-shrink: 0;
}

.memo-card-splash-bottom {
  position: absolute;
  bottom: 6px;
  left: 6px;
  z-index: 10;
}

.tile-playback-picker-active {
  padding: 8px 12px 46px 12px !important;
  box-sizing: border-box !important;
}

.tile-playback-running-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.tile-playback-running-layer .btn-card-splash-close {
  pointer-events: auto;
}

/* Fullscreen scaling for overlay playback (Calendar, Clock, etc.) */
.tile-card.fullscreen-focus .tile-playback-running-layer .memo-card-splash-track {
  height: 5px;
}

.tile-card.fullscreen-focus .tile-playback-running-layer .memo-card-splash-top-info {
  top: 10px;
  right: 64px;
}

.tile-card.fullscreen-focus .tile-playback-running-layer .memo-card-splash-countdown {
  font-size: clamp(1.2rem, 2.2vw, 2.2rem) !important;
  opacity: 0.9;
}



.btn-card-splash-close {
  border: none;
  background: var(--accent-red);
  color: #FFFFFF !important;
  font-weight: 800;
  letter-spacing: -0.2px;
  cursor: pointer;
  opacity: 1;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-card-splash-close:hover {
  background: var(--accent-red-hover);
  color: #FFFFFF !important;
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.45);
}

.btn-card-splash-close:active {
  transform: translateY(0);
}

/* Scaling for M and L size */
.tile-card.span-3 .memo-card-splash-bottom {
  bottom: 8px;
  left: 8px;
}
.tile-card.span-3 .memo-card-splash-countdown {
  font-size: 0.88rem;
}
.tile-card.span-3 .tile-corner-btn {
  bottom: 8px;
}
.tile-card.span-3 .tile-corner-btn.btn-left { left: 8px; }
.tile-card.span-3 .tile-corner-btn.btn-right { right: 8px; }

.tile-card.span-4 .memo-card-splash-bottom {
  bottom: 10px;
  left: 10px;
}
.tile-card.span-4 .memo-card-splash-countdown {
  font-size: 1rem;
}
.tile-card.span-4 .tile-corner-btn {
  bottom: 10px;
}
.tile-card.span-4 .tile-corner-btn.btn-left { left: 10px; }
.tile-card.span-4 .tile-corner-btn.btn-right { right: 10px; }

.tile-card.tile-memo.span-3 .memo-card-splash .memo-splash-text {
  font-size: clamp(1.45rem, 4.2vw, 1.85rem);
}
.tile-card.tile-memo.span-3 .memo-card-splash .memo-splash-chk-item {
  font-size: 1.25rem;
  gap: 12px;
}
.tile-card.tile-memo.span-3 .memo-card-splash .memo-splash-chk-icon {
  font-size: 1.45rem;
}

.tile-card.tile-memo.span-4 .memo-card-splash .memo-splash-text {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
}
.tile-card.tile-memo.span-4 .memo-card-splash .memo-splash-chk-item {
  font-size: 1.6rem;
  gap: 16px;
}
.tile-card.tile-memo.span-4 .memo-card-splash .memo-splash-chk-icon {
  font-size: 1.85rem;
}

/* ==========================================================================
   iTimeBoard Mini Calendar Tile Component
   ========================================================================== */

.tile-card.tile-calendar .tile-body {
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.calendar-tile-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  position: relative;
  padding: 6px 8px 8px;
  box-sizing: border-box;
}

.btn-cal-duration {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
  color: var(--custom-text, var(--text-main));
}

.btn-cal-duration.is-infinite {
  font-family: var(--font-body);
  letter-spacing: normal;
}

/* Calendar Header Navigation */
.calendar-nav-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 4px 4px;
  flex-shrink: 0;
}

.calendar-title-display {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--font-heading, inherit);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.3px;
  color: var(--custom-text, var(--text-main));
}

.cal-display-year {
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0.75;
}

.cal-display-sep {
  opacity: 0.4;
  font-weight: 700;
}

.cal-display-month {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--primary, #3b82f6);
}

.btn-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--custom-text, var(--text-sub));
  border-radius: var(--border-radius-sm, 6px);
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
}

.btn-cal-nav:hover {
  background: rgba(128, 128, 128, 0.15);
  color: var(--custom-text, var(--text-main));
}

.btn-cal-nav:active {
  transform: scale(0.92);
}

.btn-cal-nav svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Weekdays Header */
.calendar-weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--custom-text, var(--text-sub));
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.12);
  flex-shrink: 0;
}

.cal-weekday.is-sun {
  color: #ef4444;
}

.cal-weekday.is-sat {
  color: #3b82f6;
}

/* Days Grid */
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  flex: 1;
  min-height: 0;
  gap: 1px;
}

.calendar-day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1px 1px 0;
  border-radius: var(--border-radius-sm, 6px);
  min-width: 0;
  overflow: hidden;
  position: relative;
  transition: background var(--transition-fast, 0.15s ease);
}

.calendar-day-cell:hover {
  background: rgba(128, 128, 128, 0.08);
}

.calendar-day-cell.is-other-month {
  opacity: 0.25;
}

.cal-day-num {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  color: var(--custom-text, var(--text-main));
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0;
}

.calendar-day-cell.is-sun .cal-day-num {
  color: #ef4444;
}

.calendar-day-cell.is-sat .cal-day-num {
  color: #3b82f6;
}

.calendar-day-cell.is-today .cal-day-num {
  background: var(--primary, #3b82f6);
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

/* D-day Text on Dates: Pure Name, No Box, No Dot */
.calendar-day-cell.has-dday {
  cursor: pointer;
}

.cal-dday-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  margin-top: -2px;
  min-width: 0;
  overflow: hidden;
  text-align: center;
}

.cal-dday-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 1px;
  color: var(--primary, #3b82f6);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.2px;
  overflow: hidden;
  cursor: pointer;
}

.cal-dday-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
}

.cal-dday-count {
  flex-shrink: 0;
  font-size: 0.88em;
  font-weight: 800;
  opacity: 0.92;
  margin-left: 1px;
  color: inherit;
}

.calendar-day-cell.is-today .cal-dday-name {
  color: var(--primary, #3b82f6);
  filter: brightness(1.1);
}

/* ==========================================================================
   Proportional Scaling for Size M (span-3)
   ========================================================================== */
.tile-card.tile-calendar.span-3 .tile-body {
  padding: 0 !important;
}
.tile-card.tile-calendar.span-3 .calendar-tile-container {
  padding: 8px 12px 46px;
}

.tile-card.tile-calendar.span-3 .calendar-nav-header {
  padding: 0 6px 6px;
  gap: 16px;
}

.tile-card.tile-calendar.span-3 .cal-display-year {
  font-size: 1.15rem;
}

.tile-card.tile-calendar.span-3 .cal-display-month {
  font-size: 1.6rem;
}

.tile-card.tile-calendar.span-3 .btn-cal-nav {
  width: 36px;
  height: 36px;
}

.tile-card.tile-calendar.span-3 .btn-cal-nav svg {
  width: 22px;
  height: 22px;
}

.tile-card.tile-calendar.span-3 .calendar-weekdays-row {
  font-size: 1.05rem;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.tile-card.tile-calendar.span-3 .cal-day-num {
  font-size: 1.05rem;
  width: 26px;
  height: 26px;
}

.tile-card.tile-calendar.span-3 .cal-dday-list {
  margin-top: -3px;
}

.tile-card.tile-calendar.span-3 .cal-dday-name {
  font-size: 0.82rem;
  line-height: 1.15;
  gap: 2px;
}

/* ==========================================================================
   Proportional Scaling for Size L (span-4)
   ========================================================================== */
.tile-card.tile-calendar.span-4 .tile-body {
  padding: 0 !important;
}
.tile-card.tile-calendar.span-4 .calendar-tile-container {
  padding: 12px 18px 56px;
}

.tile-card.tile-calendar.span-4 .calendar-nav-header {
  padding: 0 8px 10px;
  gap: 22px;
}

.tile-card.tile-calendar.span-4 .cal-display-year {
  font-size: 1.45rem;
}

.tile-card.tile-calendar.span-4 .cal-display-month {
  font-size: 2.1rem;
}

.tile-card.tile-calendar.span-4 .btn-cal-nav {
  width: 44px;
  height: 44px;
}

.tile-card.tile-calendar.span-4 .btn-cal-nav svg {
  width: 28px;
  height: 28px;
}

.tile-card.tile-calendar.span-4 .calendar-weekdays-row {
  font-size: 1.35rem;
  padding-bottom: 10px;
  margin-bottom: 6px;
}

.tile-card.tile-calendar.span-4 .cal-day-num {
  font-size: 1.35rem;
  width: 34px;
  height: 34px;
}

.tile-card.tile-calendar.span-4 .cal-dday-list {
  margin-top: -4px;
}

.tile-card.tile-calendar.span-4 .cal-dday-name {
  font-size: 1.05rem;
  line-height: 1.2;
  gap: 2px;
}

/* ==========================================================================
   Fullscreen Focus View for Mini Calendar
   ========================================================================== */
.tile-card.tile-calendar.fullscreen-focus .tile-body {
  padding: 0 !important;
}

.tile-card.tile-calendar.fullscreen-focus .calendar-tile-container {
  padding: clamp(14px, 2.5vw, 36px) clamp(20px, 4vw, 60px) clamp(50px, 6vw, 76px) !important;
}

.tile-card.tile-calendar.fullscreen-focus .calendar-nav-header {
  padding: 0 clamp(8px, 1.5vw, 24px) clamp(10px, 2vw, 24px);
  gap: clamp(20px, 3vw, 44px);
}

.tile-card.tile-calendar.fullscreen-focus .cal-display-year {
  font-size: clamp(1.8rem, 2.5vw, 3rem);
}

.tile-card.tile-calendar.fullscreen-focus .cal-display-month {
  font-size: clamp(2.4rem, 3.8vw, 4.4rem);
}

.tile-card.tile-calendar.fullscreen-focus .btn-cal-nav {
  width: clamp(48px, 5vw, 68px);
  height: clamp(48px, 5vw, 68px);
}

.tile-card.tile-calendar.fullscreen-focus .btn-cal-nav svg {
  width: clamp(28px, 3.2vw, 40px);
  height: clamp(28px, 3.2vw, 40px);
}

.tile-card.tile-calendar.fullscreen-focus .calendar-weekdays-row {
  font-size: clamp(1.3rem, 2vw, 2.2rem);
  padding-bottom: clamp(10px, 1.5vw, 18px);
  margin-bottom: clamp(6px, 1vw, 12px);
}

.tile-card.tile-calendar.fullscreen-focus .cal-day-num {
  font-size: clamp(1.4rem, 2vw, 2.5rem);
  width: clamp(34px, 4vw, 56px);
  height: clamp(34px, 4vw, 56px);
}

.tile-card.tile-calendar.fullscreen-focus .cal-dday-list {
  margin-top: -4px;
}

.tile-card.tile-calendar.fullscreen-focus .cal-dday-name {
  font-size: clamp(0.95rem, 1.3vw, 1.6rem);
  line-height: 1.25;
  gap: 4px;
}

/* ==========================================================================
   Universal Wheel / Roller Time Picker Component
   ========================================================================== */
.time-picker-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  width: 100%;
  max-height: 90%;
  animation: fadeInFast 0.15s ease-out;
}

.time-picker-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.5cqmin, 16px);
  margin-bottom: clamp(6px, 2cqmin, 22px);
  padding: 0;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 5.5cqmin, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.time-picker-header-icon {
  width: clamp(14px, 5.5cqmin, 34px);
  height: clamp(14px, 5.5cqmin, 34px);
  color: #10B981;
  flex-shrink: 0;
}

.time-picker-header-icon.play-icon {
  color: #2563EB;
}

html[data-theme="dark"] .time-picker-header-icon.play-icon {
  color: #3B82F6;
}

.time-picker-roller-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.4cqmin, 18px);
  width: 100%;
}

.time-picker-columns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 1.2cqmin, 22px);
  max-width: 100%;
}

.time-picker-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: clamp(50px, 19cqmin, 160px);
}

.time-picker-sep {
  font-family: var(--font-mono);
  font-size: clamp(1.44rem, 9cqmin, 5rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-main));
  opacity: 0.5;
  margin-top: calc(-1 * clamp(16px, 5.2cqmin, 46px));
  padding: 0 1px;
  line-height: 1;
}

.time-picker-sep-space {
  width: clamp(3px, 1.4cqmin, 18px);
}

.time-picker-arrow {
  background: transparent;
  border: none;
  padding: clamp(1px, 0.4cqmin, 4px) clamp(4px, 1.2cqmin, 16px);
  color: var(--custom-text, var(--text-sub));
  cursor: pointer;
  opacity: 0.45;
  border-radius: 4px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: clamp(20px, 4.8cqmin, 44px);
}

.time-picker-arrow svg {
  width: clamp(14px, 3.8cqmin, 28px);
  height: clamp(14px, 3.8cqmin, 28px);
}

.time-picker-arrow:hover {
  opacity: 1;
  background: rgba(128, 128, 128, 0.15);
  color: var(--custom-text, var(--text-main));
}

.time-picker-arrow:active {
  transform: scale(0.85);
}

.time-picker-wheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: ns-resize;
  padding: 1px 2px;
  border-radius: var(--border-radius-md);
  position: relative;
  width: 100%;
}

.time-picker-wheel:hover {
  background: rgba(128, 128, 128, 0.05);
}

.wheel-slot {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.wheel-slot-prev,
.wheel-slot-next {
  font-size: clamp(0.92rem, 6.2cqmin, 3rem);
  font-weight: 600;
  opacity: 0.25;
  color: var(--custom-text, var(--text-sub));
  height: clamp(19px, 5.8cqmin, 48px);
  filter: blur(0.2px);
  pointer-events: none;
}

.wheel-slot-active {
  font-size: clamp(1.68rem, 11.4cqmin, 6.5rem);
  font-weight: 800;
  color: var(--custom-text, var(--text-main));
  background: rgba(128, 128, 128, 0.12);
  border: 1px solid rgba(128, 128, 128, 0.22);
  border-radius: var(--border-radius-sm);
  padding: clamp(2px, 0.7cqmin, 9px) clamp(5px, 1.2cqmin, 18px);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.wheel-num-text {
  pointer-events: none;
}

.time-picker-unit-label {
  font-family: var(--font-body);
  font-size: clamp(0.75rem, 3.1cqmin, 1.55rem);
  font-weight: 700;
  color: var(--custom-text, var(--text-sub));
  opacity: 0.7;
  margin-top: clamp(2px, 0.8cqmin, 10px);
}

.time-picker-col.col-ampm {
  min-width: clamp(52px, 21cqmin, 180px);
}

.time-picker-col.col-ampm .wheel-slot {
  font-family: var(--font-heading);
  letter-spacing: -0.3px;
}

.time-picker-col.col-ampm .wheel-slot-active {
  font-size: clamp(1.2rem, 7.8cqmin, 4.2rem);
  padding: clamp(2px, 0.7cqmin, 9px) clamp(7px, 1.6cqmin, 20px);
}

/* Hover prompt on idle digital timer display */
.digital-timer-container:not(.is-running) .digital-timer-display {
  cursor: pointer;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  border-radius: var(--border-radius-sm);
  padding: 0 4px;
}

.digital-timer-container:not(.is-running) .digital-timer-display:hover {
  background: rgba(128, 128, 128, 0.08);
  transform: scale(1.02);
}





