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

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

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --background: #f2f2f7;
  --foreground: #1c1c1e;
  --card: #ffffff;
  --primary: #007aff;
  --primary-foreground: #ffffff;
  --muted: #e9e9ee;
  --muted-foreground: #6e6e73;
  --border: #d1d1d6;
  --ring: #007aff;
  --radius: 14px;
  --radius-control: 10px;
  --radius-pill: 980px;
  --shadow-color: 16, 17, 20;
  color-scheme: light;
}

html.dark {
  --background: #000000;
  --foreground: #f5f5f7;
  --card: #1c1c1e;
  --primary: #0a84ff;
  --primary-foreground: #ffffff;
  --muted: #2c2c2e;
  --muted-foreground: #98989d;
  --border: #38383a;
  --ring: #0a84ff;
  --shadow-color: 0, 0, 0;
  color-scheme: dark;
}

html.amoled {
  --background: #000000;
  --foreground: #f5f5f7;
  --card: #111113;
  --primary: #0a84ff;
  --primary-foreground: #ffffff;
  --muted: #1c1c1e;
  --muted-foreground: #98989d;
  --border: #2c2c2e;
  --ring: #0a84ff;
  --shadow-color: 0, 0, 0;
  color-scheme: dark;
}

/* Accent color: user-chosen theme color, picked in Settings. Blue matches the
   defaults above and needs no override. .productivity-ios redeclares --primary
   and --f7-theme-color (ios-app.css), so those selectors are repeated here
   with !important to win regardless of load order. */
html[data-accent="pink"], html[data-accent="pink"] .productivity-ios {
  --primary: #ec6a9c !important; --ring: #ec6a9c !important; --f7-theme-color: #ec6a9c !important;
}
html[data-accent="red"], html[data-accent="red"] .productivity-ios {
  --primary: #ff3b30 !important; --ring: #ff3b30 !important; --f7-theme-color: #ff3b30 !important;
}
html[data-accent="green"], html[data-accent="green"] .productivity-ios {
  --primary: #34c759 !important; --ring: #34c759 !important; --f7-theme-color: #34c759 !important;
}
html[data-accent="purple"], html[data-accent="purple"] .productivity-ios {
  --primary: #5856d6 !important; --ring: #5856d6 !important; --f7-theme-color: #5856d6 !important;
}
html.dark[data-accent="pink"], html.amoled[data-accent="pink"], html.dark[data-accent="pink"] .productivity-ios, html.amoled[data-accent="pink"] .productivity-ios {
  --primary: #ff8ab8 !important; --ring: #ff8ab8 !important; --f7-theme-color: #ff8ab8 !important;
}
html.dark[data-accent="red"], html.amoled[data-accent="red"], html.dark[data-accent="red"] .productivity-ios, html.amoled[data-accent="red"] .productivity-ios {
  --primary: #ff453a !important; --ring: #ff453a !important; --f7-theme-color: #ff453a !important;
}
html.dark[data-accent="green"], html.amoled[data-accent="green"], html.dark[data-accent="green"] .productivity-ios, html.amoled[data-accent="green"] .productivity-ios {
  --primary: #30d158 !important; --ring: #30d158 !important; --f7-theme-color: #30d158 !important;
}
html.dark[data-accent="purple"], html.amoled[data-accent="purple"], html.dark[data-accent="purple"] .productivity-ios, html.amoled[data-accent="purple"] .productivity-ios {
  --primary: #5e5ce6 !important; --ring: #5e5ce6 !important; --f7-theme-color: #5e5ce6 !important;
}

html.dark .btn-danger,
html.dark .form-error,
html.dark .item-delete,
html.amoled .btn-danger,
html.amoled .form-error,
html.amoled .item-delete {
  color: #f87171;
}

* {
  box-sizing: border-box;
  border-color: var(--border);
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Vazirmatn", "Roboto", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  letter-spacing: -0.01em;
}

::selection {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
}

a {
  color: inherit;
  text-decoration: none;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-shell {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  overflow-x: hidden;
}

.bg-fx {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg-fx::before,
.bg-fx::after {
  content: "";
  position: absolute;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  filter: blur(56px);
  opacity: 0.65;
}

.bg-fx::before {
  inset-inline-start: -6rem;
  top: -8rem;
}

.bg-fx::after {
  inset-inline-end: -7rem;
  bottom: -8rem;
}

html.amoled .bg-fx::before,
html.amoled .bg-fx::after {
  display: none;
}

.site-header {
  width: 100%;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--card) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.nav-inner,
.footer-inner {
  width: min(100%, 80rem);
  margin-inline: auto;
  padding-inline: 1rem;
}

.nav-inner {
  display: flex;
  height: 3.5rem;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  flex: 1;
  font-family: "JetBrains Mono", monospace;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  max-width: 14rem;
  position: relative;
}

.brand-ticker {
  display: block;
  overflow: hidden;
  line-height: 1.25;
}

/* ── Glitch / Electric brand name ── */
.brand-name {
  display: inline-block;
  position: relative;
  animation: brand-glitch 5s step-end infinite;
}

.brand-name::before,
.brand-name::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.brand-name::before {
  color: #ff003c;
  mix-blend-mode: screen;
  animation: brand-split-a 5s step-end infinite;
}

.brand-name::after {
  color: #00f7ff;
  mix-blend-mode: screen;
  animation: brand-split-b 5s step-end infinite;
}

@keyframes brand-glitch {
  0%,100% { transform: none; opacity: 1; filter: none; }

  /* hit 1 */
  3%    { transform: translateX(-12px) skewX(-8deg); opacity: .9; filter: brightness(1.6); text-shadow: 0 0 8px #f0f, 0 0 2px #0ff; }
  3.15% { transform: translateX( 14px) skewX( 5deg); opacity: 1;  filter: none;            text-shadow: 0 0 6px currentColor; }
  3.3%  { transform: translateX( -6px);              opacity: .3;                           text-shadow: none; }
  3.5%  { transform: translateX(  8px) skewX(-3deg); opacity: 1;  filter: brightness(1.8); text-shadow: 0 0 10px #0ff, 0 0 3px #fff; }
  3.7%  { transform: none;                           opacity: .1; filter: none;             text-shadow: none; }
  4%    { transform: none;                           opacity: 1;                            text-shadow: none; }

  /* hit 2 */
  18%   { transform: translateX( 10px) skewX(-5deg); opacity: .7; filter: brightness(1.4) hue-rotate(45deg); text-shadow: 0 0 8px #f0f; }
  18.2% { transform: translateX(-14px);              opacity: 1;  filter: none;                               text-shadow: 0 0 5px currentColor; }
  18.4% { transform: none;                           opacity: .2;                                             text-shadow: none; }
  18.6% { transform: none;                           opacity: 1;                                              text-shadow: none; }

  /* hit 3 */
  33%   { transform: translateX(-16px) skewX( 6deg); opacity: .8; filter: brightness(1.5);   text-shadow: 0 0 9px #0ff, 0 0 2px #fff; }
  33.2% { transform: translateX( 10px) skewX(-4deg); opacity: 1;  filter: none;               text-shadow: 0 0 6px currentColor; }
  33.4% { transform: translateX( -4px);              opacity: .4;                              text-shadow: none; }
  33.6% { transform: none;                           opacity: .1; filter: brightness(2);      text-shadow: 0 0 12px #fff; }
  33.9% { transform: none;                           opacity: 1;  filter: none;               text-shadow: none; }

  /* hit 4 */
  52%   { transform: translateX( 16px) skewX(-6deg); opacity: .8; filter: brightness(1.5) hue-rotate(90deg); text-shadow: 0 0 8px #f0f, 0 0 3px #0ff; }
  52.2% { transform: translateX(-10px) skewX( 4deg); opacity: 1;  filter: none;                               text-shadow: 0 0 5px currentColor; }
  52.4% { transform: translateX(  6px);              opacity: .3;                                             text-shadow: none; }
  52.6% { transform: none;                           opacity: 1;  filter: brightness(1.4);                   text-shadow: 0 0 7px currentColor; }
  52.8% { transform: none;                           opacity: .5; filter: none;                               text-shadow: none; }
  53%   { transform: none;                           opacity: 1;                                              text-shadow: none; }

  /* hit 5 */
  70%   { transform: translateX(-8px)  skewX( 3deg); opacity: .6; filter: brightness(1.3); text-shadow: 0 0 7px #0ff; }
  70.2% { transform: translateX(12px);               opacity: 1;  filter: none;             text-shadow: 0 0 5px currentColor; }
  70.3% { transform: none;                           opacity: .2;                            text-shadow: none; }
  70.5% { transform: none;                           opacity: 1;                             text-shadow: none; }

  /* hit 6 */
  87%   { transform: translateX( 14px) skewX(-7deg); opacity: .85; filter: brightness(1.6) hue-rotate(60deg); text-shadow: 0 0 10px #f0f, 0 0 4px #fff; }
  87.2% { transform: translateX(-10px) skewX( 3deg); opacity: 1;   filter: none;                               text-shadow: 0 0 6px currentColor; }
  87.4% { transform: translateX(  5px);              opacity: .25;                                             text-shadow: none; }
  87.6% { transform: none;                           opacity: 1;   filter: brightness(1.5);                   text-shadow: 0 0 8px #0ff; }
  87.8% { transform: none;                           opacity: .4;  filter: none;                               text-shadow: none; }
  88%   { transform: none;                           opacity: 1;                                               text-shadow: none; }
}

/* red ghost */
@keyframes brand-split-a {
  0%,100% { opacity:0; transform:none; clip-path:none; }

  3%    { opacity:1; transform:translateX(-14px); clip-path:polygon(0 0,  100% 0,  100% 40%,0 40%); }
  3.15% { opacity:0; }
  3.3%  { opacity:1; transform:translateX( 10px); clip-path:polygon(0 55%,100% 55%,100% 100%,0 100%); }
  3.5%  { opacity:0; }
  3.7%  { opacity:1; transform:translateX( -8px); clip-path:polygon(0 20%,100% 20%,100% 70%,0 70%); }
  4%    { opacity:0; }

  18%   { opacity:1; transform:translateX( 12px); clip-path:polygon(0 0,  100% 0,  100% 45%,0 45%); }
  18.3% { opacity:0; }
  18.5% { opacity:1; transform:translateX( -8px); clip-path:polygon(0 50%,100% 50%,100% 100%,0 100%); }
  18.6% { opacity:0; }

  33%   { opacity:1; transform:translateX(-18px); clip-path:polygon(0 0,  100% 0,  100% 35%,0 35%); }
  33.3% { opacity:0; }
  33.6% { opacity:1; transform:translateX( 10px); clip-path:polygon(0 60%,100% 60%,100% 100%,0 100%); }
  33.9% { opacity:0; }

  52%   { opacity:1; transform:translateX( 18px); clip-path:polygon(0 0,  100% 0,  100% 50%,0 50%); }
  52.2% { opacity:0; }
  52.4% { opacity:1; transform:translateX(-12px); clip-path:polygon(0 45%,100% 45%,100% 100%,0 100%); }
  52.6% { opacity:1; transform:translateX(  6px); clip-path:polygon(0 10%,100% 10%,100% 60%,0 60%); }
  52.8% { opacity:0; }

  70%   { opacity:1; transform:translateX(-10px); clip-path:polygon(0 0,  100% 0,  100% 55%,0 55%); }
  70.2% { opacity:0; }
  70.4% { opacity:1; transform:translateX(  8px); clip-path:polygon(0 40%,100% 40%,100% 100%,0 100%); }
  70.5% { opacity:0; }

  87%   { opacity:1; transform:translateX( 16px); clip-path:polygon(0 0,  100% 0,  100% 45%,0 45%); }
  87.3% { opacity:0; }
  87.5% { opacity:1; transform:translateX(-10px); clip-path:polygon(0 55%,100% 55%,100% 100%,0 100%); }
  87.8% { opacity:0; }
}

/* cyan ghost */
@keyframes brand-split-b {
  0%,100% { opacity:0; transform:none; clip-path:none; }

  3%    { opacity:1; transform:translateX( 14px); clip-path:polygon(0 60%,100% 60%,100% 100%,0 100%); }
  3.15% { opacity:0; }
  3.3%  { opacity:1; transform:translateX(-10px); clip-path:polygon(0 0,  100% 0,  100% 45%,0 45%); }
  3.5%  { opacity:0; }
  3.7%  { opacity:1; transform:translateX(  8px); clip-path:polygon(0 30%,100% 30%,100% 80%,0 80%); }
  4%    { opacity:0; }

  18%   { opacity:1; transform:translateX(-14px); clip-path:polygon(0 55%,100% 55%,100% 100%,0 100%); }
  18.3% { opacity:0; }
  18.5% { opacity:1; transform:translateX( 10px); clip-path:polygon(0 0,  100% 0,  100% 50%,0 50%); }
  18.6% { opacity:0; }

  33%   { opacity:1; transform:translateX( 16px); clip-path:polygon(0 65%,100% 65%,100% 100%,0 100%); }
  33.3% { opacity:0; }
  33.6% { opacity:1; transform:translateX(-12px); clip-path:polygon(0 0,  100% 0,  100% 40%,0 40%); }
  33.9% { opacity:0; }

  52%   { opacity:1; transform:translateX(-16px); clip-path:polygon(0 50%,100% 50%,100% 100%,0 100%); }
  52.2% { opacity:0; }
  52.4% { opacity:1; transform:translateX( 12px); clip-path:polygon(0 0,  100% 0,  100% 55%,0 55%); }
  52.6% { opacity:1; transform:translateX( -6px); clip-path:polygon(0 40%,100% 40%,100% 90%,0 90%); }
  52.8% { opacity:0; }

  70%   { opacity:1; transform:translateX( 12px); clip-path:polygon(0 45%,100% 45%,100% 100%,0 100%); }
  70.2% { opacity:0; }
  70.4% { opacity:1; transform:translateX( -8px); clip-path:polygon(0 0,  100% 0,  100% 50%,0 50%); }
  70.5% { opacity:0; }

  87%   { opacity:1; transform:translateX(-14px); clip-path:polygon(0 50%,100% 50%,100% 100%,0 100%); }
  87.3% { opacity:0; }
  87.5% { opacity:1; transform:translateX( 10px); clip-path:polygon(0 0,  100% 0,  100% 45%,0 45%); }
  87.8% { opacity:0; }
}

.brand-block-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.55;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 0.1em;
}

.brand-block-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.brand-block-detail {
  display: block;
  font-size: 0.62rem;
  font-weight: 400;
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--radius-pill);
  padding-inline: 1rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.nav-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.nav-link:active {
  transform: scale(0.96);
}

.nav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  box-shadow: none;
}

.nav-link.active::after {
  content: none;
}

.nav-actions {
  display: flex;
  flex: 1;
  min-width: max-content;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (min-width: 721px) and (max-width: 1100px) {
  .nav-inner {
    gap: 0.35rem;
  }

  .brand {
    flex: 0 1 9rem;
  }

  .nav-links {
    gap: 0.15rem;
  }

  .nav-link {
    padding-inline: 0.65rem;
  }

  .nav-link .ui-icon {
    display: none;
  }

  .nav-actions {
    flex: 0 0 auto;
    gap: 0.35rem;
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: var(--muted);
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.theme-toggle:hover {
  background: color-mix(in srgb, var(--primary) 14%, var(--muted));
  color: var(--primary);
}

.theme-toggle:active {
  transform: scale(0.92);
}

.header-timer {
  position: relative;
}

.header-timer-button.is-active {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
}

.header-timer-button.is-ringing {
  color: #dc2626;
  border-color: color-mix(in srgb, #dc2626 50%, var(--border));
  background: color-mix(in srgb, #dc2626 12%, var(--card));
  animation: timer-pulse 0.85s ease-in-out infinite;
}

.header-timer-popover {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  z-index: 45;
  display: flex;
  width: 14rem;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.75rem;
  color: var(--foreground);
  box-shadow: 0 18px 45px rgba(var(--shadow-color), 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-0.25rem);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.header-timer:hover .header-timer-popover,
.header-timer:focus-within .header-timer-popover {
  opacity: 1;
  transform: translateY(0);
}

.header-timer-popover strong {
  font-size: 0.9rem;
}

.header-timer-popover span {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  line-height: 1.4;
}

.timer-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-color), 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.timer-alarm-backdrop {
  z-index: 110;
  background: rgba(var(--shadow-color), 0.44);
}

.timer-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.timer-modal {
  display: flex;
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100vh - 2rem));
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.24);
  transform: translateY(0.5rem) scale(0.98);
  transition: transform 0.18s ease;
}

.timer-modal-backdrop.is-open .timer-modal {
  transform: translateY(0) scale(1);
}

.timer-alarm-modal {
  width: min(26rem, calc(100vw - 2rem));
  align-items: center;
  text-align: center;
}

.timer-alarm-icon {
  display: inline-flex;
  width: 3.25rem;
  height: 3.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, #dc2626 12%, var(--card));
  color: #dc2626;
  animation: timer-pulse 0.85s ease-in-out infinite;
}

.timer-alarm-icon .ui-icon {
  width: 1.6rem;
  height: 1.6rem;
}

.timer-alarm-copy h2 {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
}

.timer-alarm-copy p:last-child {
  margin: 0.45rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.5;
}

.timer-alarm-list {
  display: grid;
  width: 100%;
  gap: 0.4rem;
}

.timer-alarm-item {
  border: 1px solid color-mix(in srgb, #dc2626 34%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, #dc2626 8%, var(--card));
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.timer-alarm-modal .btn {
  width: 100%;
}

.timer-modal-head,
.timer-section-head,
.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.timer-modal-head {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 34%, transparent);
}

.timer-modal-head > div {
  min-width: 0;
}

.timer-modal-head h2 {
  margin: 0.25rem 0 0;
  font-size: 1.2rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.timer-modal-head .calendar-eyebrow {
  margin: 0;
}

.timer-form {
  display: grid;
  gap: 0.85rem;
}

.timer-mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem;
  border-radius: var(--radius-control);
  background: var(--muted);
  padding: 0.15rem;
}

.timer-mode-option {
  position: relative;
}

.timer-mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.timer-mode-option span {
  display: flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: calc(var(--radius-control) - 2px);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.timer-mode-option input:checked + span {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 4px rgba(var(--shadow-color), 0.12);
}

.timer-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.timer-fields .form-field {
  display: grid;
  gap: 0.35rem;
}

.timer-fields .form-field span {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 700;
}

.timer-fields input {
  width: 100%;
  min-height: 2.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--muted);
  color: var(--foreground);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.timer-fields input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 26%, transparent);
  outline: none;
}

.timer-fields .form-field:last-child {
  grid-column: 1 / -1;
}

.timer-active-section {
  display: grid;
  min-height: 0;
  gap: 0.65rem;
}

.timer-section-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.timer-section-head span {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.timer-list {
  display: grid;
  max-height: 16rem;
  gap: 0.5rem;
  overflow: auto;
}

.timer-row {
  min-height: 3.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 42%, var(--card));
  padding: 0.7rem;
}

.timer-row.is-ringing {
  border-color: color-mix(in srgb, #dc2626 52%, var(--border));
  background: color-mix(in srgb, #dc2626 10%, var(--card));
}

.timer-row-main {
  display: grid;
  min-width: 0;
  gap: 0.2rem;
}

.timer-row-title {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-row-meta {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.timer-row-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
}

.timer-empty {
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  text-align: center;
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.theme-icon-moon,
.theme-icon-amoled {
  display: none;
}

html.dark .theme-icon-sun,
html.amoled .theme-icon-sun {
  display: none;
}

html.dark .theme-icon-moon {
  display: inline;
}

html.amoled .theme-icon-amoled {
  display: inline;
}

.main {
  display: flex;
  flex: 1;
  justify-content: center;
  width: 100%;
}

.container {
  width: min(100%, 56rem);
  padding: 2rem 1rem 3rem;
}

.container.container-wide {
  width: min(100%, 96rem);
  padding-inline: 1.5rem;
}

.container.container-full {
  width: 100%;
  max-width: none;
  padding: 0;
}

.page-stack {
  display: flex;
  flex-direction: column;
  padding-bottom: 3rem;
}

.section {
  margin-top: 4rem;
}

.section:first-child {
  margin-top: 1.5rem;
}

.section-heading {
  margin-bottom: 2rem;
  text-align: center;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 650;
}

.section-accent {
  width: 3rem;
  height: 0.25rem;
  margin: 0.5rem auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 40%, transparent), var(--primary), color-mix(in srgb, var(--primary) 40%, transparent));
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.card,
.post,
.github-card,
.login-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.card {
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(var(--shadow-color), 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: 0 8px 24px rgba(var(--shadow-color), 0.08);
}

.card h3,
.post h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  transition: color 0.2s ease;
}

.card:hover h3,
.post:hover h3 {
  color: var(--primary);
}

.card p,
.post p {
  margin: 0.5rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.6;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.posts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.post:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 12px 28px rgba(var(--shadow-color), 0.06);
}

.post time {
  flex-shrink: 0;
  color: var(--muted-foreground);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
}

.github-card {
  width: 100%;
  padding: 1rem;
}

.github-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}

.github-grid-wrap {
  width: 750px;
  margin-inline: auto;
}

.github-months {
  display: flex;
  gap: 3px;
  margin-bottom: 4px;
  color: var(--muted-foreground);
  font-size: 10px;
}

.github-months span {
  width: 60px;
}

.github-grid {
  display: flex;
  gap: 3px;
}

.github-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.github-cell {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--muted);
}

.github-cell.level-1 {
  background: color-mix(in srgb, var(--primary) 20%, var(--muted));
}

.github-cell.level-2 {
  background: color-mix(in srgb, var(--primary) 40%, var(--muted));
}

.github-cell.level-3 {
  background: color-mix(in srgb, var(--primary) 70%, var(--muted));
}

.github-cell.level-4 {
  background: var(--primary);
}

.github-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  margin-top: 0.5rem;
  color: var(--muted-foreground);
  font-size: 10px;
}

.github-legend .github-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.github-total {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  color: var(--muted-foreground);
  text-align: center;
  font-size: 0.875rem;
}

.footer {
  width: 100%;
  border-top: 1px solid var(--border);
}

.footer-inner {
  padding-block: 1.5rem;
  text-align: center;
}

.footer-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-row > * {
  flex: 1;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.footer-link,
.footer-copy {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--foreground);
}

.footer-copy {
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-pill);
  padding-inline: 1.25rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-soft {
  background: var(--muted);
  color: var(--foreground);
}

.btn-soft:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--muted));
}

.btn-danger {
  background: color-mix(in srgb, #ff3b30 14%, var(--muted));
  color: #ff3b30;
}

.btn-danger:hover {
  background: color-mix(in srgb, #ff3b30 22%, var(--muted));
}

.btn-block {
  width: 100%;
}

.auth-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: calc(100vh - 7rem);
  align-items: center;
  justify-content: center;
}

.auth-loader {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.auth-loader.is-done {
  opacity: 0;
  visibility: hidden;
}

.auth-loader-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid color-mix(in srgb, var(--muted-foreground) 24%, transparent);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: login-spin 0.75s linear infinite;
}

.auth-page[data-auth-page] {
  opacity: 0;
  visibility: hidden;
}

.auth-page[data-auth-page].is-ready {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.32s ease;
}

.login-hero {
  text-align: center;
  line-height: 1;
  will-change: transform;
}

/* intro state: only the hero is shown, vertically centered. The login card is
   pulled out of the flow (display:none) so the global reveal-observer cannot
   light it up — JS removes .intro after the first glitch to reveal the form. */
.auth-page.intro .login-card {
  display: none;
}

.auth-page:not(.intro) .login-card {
  display: block;
  animation: login-card-open 0.56s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-hero-text {
  display: inline-block;
  position: relative;
  font-family: "JetBrains Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  /* idle electric flicker while the text sits still between glitches.
     JS adds .is-glitching during the burst, which pauses this. */
  /* smooth grow / shrink; transform & opacity stay instant for the glitch */
  transition: font-size 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform, font-size, opacity;
}

.auth-page.is-ready .login-hero-text {
  animation: hero-idle-pulse 2.6s ease-in-out infinite;
}

/* during the glitch burst, let JS's inline text-shadow take over */
.login-hero-text.is-glitching {
  animation: none;
}

@keyframes hero-idle-pulse {
  0%, 100% { text-shadow: 0 0 6px rgba(0, 247, 255, 0.35), 0 0 12px rgba(255, 0, 60, 0.15); }
  50%      { text-shadow: 0 0 11px rgba(0, 247, 255, 0.55), 0 0 22px rgba(255, 0, 60, 0.30); }
  /* quick neon-sign flicker hits */
  7%       { text-shadow: 0 0 3px rgba(0, 247, 255, 0.20); }
  8%       { text-shadow: 0 0 13px rgba(0, 247, 255, 0.65), 0 0 24px rgba(255, 0, 60, 0.35); }
  68%      { text-shadow: 0 0 4px rgba(0, 247, 255, 0.25); }
  69%      { text-shadow: 0 0 15px rgba(0, 247, 255, 0.70), 0 0 26px rgba(255, 0, 60, 0.40); }
}

/* reuse brand-name pseudo setup, but kill its loop animation and hide the
   RGB-split layers until JS adds .is-glitching */
.login-hero-text::before,
.login-hero-text::after {
  font-size: inherit;
  animation: none;
  opacity: 0;
  transition: none;
}

.login-hero-text.is-glitching::before {
  opacity: 0.85;
  transform: translateX(-3px);
  color: #ff003c;
}

.login-hero-text.is-glitching::after {
  opacity: 0.85;
  transform: translateX(3px);
  color: #00f7ff;
}

.login-card {
  width: min(100%, 25rem);
  padding: 1.5rem;
}

@keyframes login-card-open {
  from {
    opacity: 0;
    transform: translateY(0.7rem) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.login-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

.login-subtitle,
.form-error {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.6;
}

.form-error {
  border: 1px solid color-mix(in srgb, #dc2626 30%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, #dc2626 8%, transparent);
  color: #b91c1c;
  padding: 0.75rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label,
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--muted);
  color: var(--foreground);
  padding-inline: 0.85rem;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input,
.field select {
  height: 2.75rem;
}

.field textarea {
  min-height: 9rem;
  padding-block: 0.75rem;
  line-height: 1.65;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  background: var(--card);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 22%, transparent);
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  transition-delay: var(--delay, 0ms);
}

.reveal.visible {
  opacity: 1;
  /* Resolve to `none` (not translateY(0)) so a settled .reveal does not create a
     containing block that would re-anchor position: fixed drawers/modals. */
  transform: none;
}

.calendar-page {
  direction: ltr;
}

.calendar-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.calendar-eyebrow,
.calendar-today,
.calendar-drawer-head p,
.form-hint,
.empty-day-text {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.calendar-eyebrow {
  color: var(--primary);
  font-weight: 650;
}

.calendar-toolbar h1 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.75rem;
  line-height: 1.25;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.calendar-card,
.calendar-drawer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.calendar-card {
  padding: 1rem;
}

.app-calendar-weekdays,
.app-calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.app-calendar-weekdays {
  margin-bottom: 0.55rem;
}

.app-calendar-weekdays div {
  color: var(--muted-foreground);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 650;
}

.app-calendar-month {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.app-calendar-day {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 5.4rem;
  flex-direction: column;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 92%, var(--muted));
  color: var(--foreground);
  padding: 0.65rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.app-calendar-day:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
  box-shadow: 0 12px 24px rgba(var(--shadow-color), 0.06);
}

.app-calendar-day.is-empty {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.app-calendar-day.is-past {
  border-color: color-mix(in srgb, var(--border) 70%, var(--muted-foreground));
  background: color-mix(in srgb, var(--muted) 82%, var(--card));
  color: color-mix(in srgb, var(--muted-foreground) 86%, var(--foreground));
}

.app-calendar-day.is-past .calendar-day-preview,
.app-calendar-day.is-past .calendar-day-number {
  opacity: 0.72;
}

.app-calendar-day.is-past .calendar-day-marker {
  background: color-mix(in srgb, var(--muted-foreground) 72%, var(--card));
}

.calendar-day-number {
  display: inline-flex;
  width: 1.7rem;
  height: 1.7rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.95rem;
  font-weight: 700;
}

.app-calendar-day.is-today {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.app-calendar-day.is-today .calendar-day-number {
  background: var(--primary);
  color: var(--primary-foreground);
}

.app-calendar-day.has-data {
  border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
}

.app-calendar-day.has-data::after {
  content: "";
  position: absolute;
  inset: 0.35rem;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
}

.app-calendar-day.is-past.has-data {
  border-color: color-mix(in srgb, var(--border) 72%, var(--muted-foreground));
}

.app-calendar-day.is-past.has-data::after {
  border-color: color-mix(in srgb, var(--muted-foreground) 24%, transparent);
}

.app-calendar-day.is-selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 38%, transparent);
}

.calendar-day-marker {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--primary);
}

.calendar-day-preview {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.74rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(var(--shadow-color), 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.calendar-drawer {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 50;
  width: min(26rem, calc(100vw - 1.5rem));
  padding: 1rem;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.18);
  transform: translateX(calc(100% + 1.5rem));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.22s ease;
}

.calendar-drawer.is-left {
  right: auto;
  left: 0.75rem;
  transform: translateX(calc(-100% - 1.5rem));
}

.calendar-drawer.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.calendar-drawer.is-left.is-open {
  transform: translateX(0);
}

.calendar-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
}

.calendar-drawer-head h2 {
  margin: 0.25rem 0 0;
  font-size: 1.25rem;
}

.drawer-close {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--foreground);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.drawer-close:hover {
  background: color-mix(in srgb, var(--muted) 70%, var(--border));
}

.day-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.day-summary .day-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  padding: 0.75rem;
}

.day-summary .day-item > div {
  flex: 1;
  min-width: 0;
}

[data-calendar-drawer] .drawer-close {
  width: auto;
  min-width: 44px;
  flex-shrink: 0;
  padding-inline: 0.65rem;
}

.day-summary span {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.day-summary p {
  margin: 0.35rem 0 0;
  color: var(--foreground);
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  text-align: start;
}

.item-delete {
  width: auto;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, #dc2626 30%, var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, #dc2626 8%, transparent);
  color: #b91c1c;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  padding: 0.35rem 0.55rem;
  transition: background 0.15s ease;
}

.item-delete:hover {
  background: color-mix(in srgb, #dc2626 14%, transparent);
}

.empty-day-text {
  margin-top: 1rem;
}

.drawer-add {
  margin-top: 1rem;
  width: 100%;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.drawer-actions .drawer-add {
  margin-top: 0;
}

.day-form {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.day-form.is-collapsed {
  display: none;
}

.time-calendar {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.time-header,
.time-body {
  min-width: 100%;
}

.time-header {
  display: grid;
  grid-template-columns: 4.5rem repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 62%, var(--card));
}

.time-corner,
.time-day-head {
  min-height: 4rem;
}

.time-day-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  border-left: 1px solid var(--border);
  padding: 0.75rem;
}

.time-day-head span {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 650;
}

.time-day-head strong {
  font-size: 0.95rem;
}

.time-day-head.is-today {
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
  color: var(--primary);
}

.time-body {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
}

.time-axis {
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 32%, var(--card));
}

.time-axis-hour {
  display: flex;
  height: 3.6rem;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.45rem;
  color: var(--muted-foreground);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}

.time-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.time-day-column {
  position: relative;
  min-height: calc(18 * 3.6rem);
  border-left: 1px solid var(--border);
}

.time-day-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(36, 1.8rem);
}

.time-hour-slot {
  position: relative;
  width: 100%;
  border: 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 45%, transparent);
  background: transparent;
  cursor: pointer;
  appearance: none;
  touch-action: none;
}

.time-hour-slot.is-hour {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.time-hour-slot::after {
  content: attr(data-slot-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.time-hour-slot:hover::after {
  opacity: 0.55;
}

.time-hour-slot.is-selection-range-start::after,
.time-hour-slot.is-selection-range-end::after {
  content: attr(data-selection-label);
  z-index: 2;
  border-radius: 4px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--foreground);
  font-weight: 700;
  opacity: 1;
}

.time-hour-slot:hover,
.time-hour-slot.is-selected {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.time-hour-slot.is-current-row {
  background: color-mix(in srgb, var(--muted-foreground) 10%, transparent);
}

.time-hour-slot.is-current-day-row {
  background: color-mix(in srgb, var(--muted-foreground) 17%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--muted-foreground) 24%, transparent);
}

.time-hour-slot.is-current-day-row::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.45rem;
  left: 0.45rem;
  height: 1px;
  background: color-mix(in srgb, var(--muted-foreground) 46%, transparent);
  pointer-events: none;
}

.time-hour-slot.is-selected {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 42%, transparent);
}

.time-mobile-selection {
  position: absolute;
  right: 0.42rem;
  left: 0.42rem;
  z-index: 6;
  display: none;
  min-height: 2.2rem;
  border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 15%, var(--card));
  color: var(--foreground);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font: inherit;
  text-align: center;
  box-shadow: 0 10px 24px rgba(var(--shadow-color), 0.14);
  touch-action: none;
}

.time-mobile-selection-label,
.time-mobile-selection-hint {
  display: block;
  pointer-events: none;
}

.time-mobile-selection-label {
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.time-mobile-selection-hint {
  margin-top: 0.12rem;
  color: color-mix(in srgb, var(--primary) 72%, var(--muted-foreground));
  font-size: 0.66rem;
  font-weight: 750;
}

.time-mobile-selection-handle {
  position: absolute;
  left: 50%;
  z-index: 2;
  display: inline-flex;
  width: 2.5rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--primary) 55%, var(--border));
  border-radius: 999px;
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(var(--shadow-color), 0.16);
  transform: translateX(-50%);
  pointer-events: auto;
}

.time-mobile-selection-handle::before {
  width: 0;
  height: 0;
  border-right: 0.32rem solid transparent;
  border-left: 0.32rem solid transparent;
  content: "";
}

.time-mobile-selection-handle.is-top {
  top: -0.78rem;
}

.time-mobile-selection-handle.is-top::before {
  border-bottom: 0.42rem solid currentColor;
}

.time-mobile-selection-handle.is-bottom {
  bottom: -0.78rem;
}

.time-mobile-selection-handle.is-bottom::before {
  border-top: 0.42rem solid currentColor;
}

.time-block-layer {
  position: absolute;
  inset: 0.25rem 0.35rem;
  pointer-events: none;
}

.time-block {
  position: absolute;
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  min-height: 2rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--block-color) 48%, var(--border));
  border-radius: 10px;
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--block-color) 20%, var(--card)),
    color-mix(in srgb, var(--block-color) 9%, var(--card))
  );
  color: var(--foreground);
  padding: 0.4rem 0.55rem 0.4rem 0.7rem;
  box-shadow: 0 1px 2px rgba(var(--shadow-color), 0.05), 0 6px 16px rgba(var(--shadow-color), 0.07);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.time-block::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--block-color);
}

.time-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--block-color) 28%, transparent), 0 12px 24px rgba(var(--shadow-color), 0.12);
}

.time-block.is-dragging {
  cursor: grabbing;
  user-select: none;
  opacity: 0.92;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--block-color) 45%, transparent), 0 16px 30px rgba(var(--shadow-color), 0.2);
}

/* Only while an actual move is in progress: let elementFromPoint see the day
   column beneath the block. A plain click never gets this class, so the click
   still reaches the block and opens the editor. */
.time-block.is-moving {
  pointer-events: none;
}

.time-day-column.is-drop-target {
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent);
}

.time-block-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  z-index: 2;
  cursor: ns-resize;
}

.time-block-move-grip { display: none; }

.time-block-handle-top {
  top: 0;
}

.time-block-handle-bottom {
  bottom: 0;
}

.time-block-body {
  min-width: 0;
  width: 100%;
}

.time-block strong,
.time-block span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.time-block strong {
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.3;
}

.time-block span {
  margin-top: 0.15rem;
  color: color-mix(in srgb, var(--block-color) 70%, var(--muted-foreground));
  font-family: "JetBrains Mono", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.01em;
}

.time-block.color-blue {
  --block-color: #2563eb;
}

.time-block.color-green {
  --block-color: #16a34a;
}

.time-block.color-amber {
  --block-color: #d97706;
}

.time-block.color-rose {
  --block-color: #e11d48;
}

.time-block.color-violet {
  --block-color: #7c3aed;
}

.time-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.time-kind-panel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.time-kind-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
  border: 0;
  padding: 0;
}

.time-kind-switch-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.time-kind-switch legend {
  grid-column: 1 / -1;
  margin-bottom: 0.15rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 700;
}

.time-kind-option {
  display: flex;
  min-height: 2.55rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.time-kind-option.is-active {
  border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
  background: color-mix(in srgb, var(--primary) 11%, var(--card));
  color: var(--foreground);
}

.time-kind-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.time-kind-switch.is-locked .time-kind-option {
  cursor: default;
  opacity: 0.72;
}

.time-repeat-field {
  position: relative;
}

.time-repeat-field[hidden] {
  display: none;
}

.time-recur-options {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.25rem 0 0.5rem;
}

.time-recur-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.4rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.88rem;
  cursor: pointer;
}

.time-recur-option:hover {
  background: var(--muted);
}

.time-recur-option input {
  accent-color: var(--primary);
  cursor: pointer;
}

.time-recur-option[hidden] {
  display: none;
}

.time-recur-option-inline input[type="date"],
.time-recur-option-inline input[type="number"] {
  width: 6.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
}

.time-recur-option-inline input:disabled {
  opacity: 0.5;
}

.time-custom-recur-modal {
  width: min(24rem, calc(100vw - 2rem));
}

.time-custom-recur-row {
  margin: 0.9rem 0;
}

.time-custom-recur-row[hidden] {
  display: none;
}

.time-custom-recur-row .field-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 700;
}

.time-custom-recur-interval {
  display: flex;
  gap: 0.5rem;
}

.time-custom-recur-interval input[type="number"] {
  width: 4.5rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.time-custom-recur-interval select {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.time-weekday-pills {
  display: flex;
  gap: 0.4rem;
}

.time-weekday-pill {
  display: flex;
  width: 2.2rem;
  height: 2.2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background);
  color: var(--foreground);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.time-weekday-pill.is-active {
  border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
  background: var(--primary);
  color: var(--primary-foreground, #fff);
}

.time-block-repeat-icon {
  display: inline-block;
  vertical-align: -1px;
  margin-inline-end: 0.2rem;
  color: color-mix(in srgb, var(--block-color) 70%, var(--foreground));
}

.time-habit-picker-field {
  position: relative;
}

.time-habit-trigger {
  display: flex;
  width: 100%;
  min-height: 2.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  padding: 0 0.8rem;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.time-habit-trigger:disabled {
  cursor: default;
  opacity: 0.72;
}

.time-habit-trigger.is-open .ui-icon {
  transform: rotate(180deg);
}

.time-habit-options {
  display: flex;
  max-height: 13rem;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.35rem;
  box-shadow: 0 14px 32px rgba(var(--shadow-color), 0.14);
}

.time-habit-options[hidden] {
  display: none;
}

.time-habit-option {
  width: 100%;
  border: 0;
  border-radius: calc(var(--radius) - 3px);
  background: transparent;
  color: var(--foreground);
  padding: 0.65rem 0.7rem;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.time-habit-option:hover,
.time-habit-option.is-selected {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.time-task-modal {
  display: grid;
  width: min(58rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100vh - 2rem));
  grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.22);
}

.time-task-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 42%, var(--card));
  padding: 0.9rem;
}

.time-task-projects {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.5rem;
}

.time-task-main {
  display: flex;
  min-height: 26rem;
  flex-direction: column;
  overflow: hidden;
}

.time-task-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  padding: 0.9rem;
}

.time-task-choice {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  cursor: pointer;
  text-align: left;
}

.time-task-choice:hover,
.time-task-choice.is-selected {
  border-color: color-mix(in srgb, var(--primary) 52%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--background));
}

.time-block-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.time-block-details[hidden] {
  display: none;
}

.time-detail-hero {
  --block-color: #2563eb;
  border: 1px solid color-mix(in srgb, var(--block-color) 48%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--block-color) 11%, var(--card));
  padding: 0.9rem;
}

.time-detail-hero h3 {
  margin: 0.25rem 0 0;
  font-size: 1.1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.time-detail-hero > span {
  display: block;
  margin-top: 0.7rem;
  color: var(--muted-foreground);
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.8rem;
  font-weight: 750;
}

.time-detail-hero.color-blue {
  --block-color: #2563eb;
}

.time-detail-hero.color-green {
  --block-color: #16a34a;
}

.time-detail-hero.color-amber {
  --block-color: #d97706;
}

.time-detail-hero.color-rose {
  --block-color: #e11d48;
}

.time-detail-hero.color-violet {
  --block-color: #7c3aed;
}

.time-detail-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.time-detail-list div {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--muted) 18%, var(--card));
  padding: 0.75rem;
}

.time-detail-list dt {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 750;
}

.time-detail-list dd {
  margin: 0.25rem 0 0;
  color: var(--foreground);
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.time-form-actions,
.confirm-actions {
  display: flex;
  gap: 0.75rem;
}

.time-form-actions .btn,
.confirm-actions .btn {
  flex: 1;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-color), 0.28);
  backdrop-filter: blur(0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease, backdrop-filter 0.26s ease;
}

.confirm-backdrop.is-open {
  backdrop-filter: blur(2px);
  opacity: 1;
  pointer-events: auto;
}

.confirm-modal {
  width: min(24rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.2);
  opacity: 0;
  transform: translateY(0.75rem) scale(0.985);
  transition: opacity 0.26s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.confirm-backdrop.is-open .confirm-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.confirm-modal h2 {
  margin: 0.25rem 0 0;
  font-size: 1.2rem;
}

.confirm-modal p:last-child {
  margin: 0.5rem 0 1rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ===== Todo ===== */
.todo-page {
  display: grid;
  width: 100%;
  min-height: calc(100vh - 3.5rem);
  grid-template-columns: 18rem minmax(0, 1fr);
  background: var(--card);
  direction: ltr;
}

.todo-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 36%, var(--card));
  padding: 1rem;
}

.todo-add-main {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font: inherit;
  font-size: 1rem;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.todo-add-main:hover {
  color: color-mix(in srgb, var(--primary) 78%, #000);
}

.todo-add-main span {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, background 0.15s ease;
}

.todo-add-main:hover span {
  background: color-mix(in srgb, var(--primary) 85%, #fff);
  transform: scale(1.08) rotate(90deg);
  box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}

.todo-add-main:active span {
  transform: scale(0.96) rotate(90deg);
}

.todo-nav,
.todo-project-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.todo-nav-item,
.todo-project-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--foreground);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.todo-nav-item:hover,
.todo-project-item:hover {
  background: var(--muted);
}

.todo-nav-item.is-active,
.todo-project-item.is-active {
  background: color-mix(in srgb, var(--primary) 11%, var(--card));
  color: var(--primary);
  font-weight: 600;
}

.todo-nav-item.is-active::before,
.todo-project-item.is-active::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 50%;
  height: 1.1rem;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
  transform: translateY(-50%);
}

.todo-nav-item strong,
.todo-project-count {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 500;
}

[data-todo-count="overdue"]:not(:empty) {
  color: #dc2626;
}

.todo-projects {
  margin-top: 0.5rem;
}

.todo-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.todo-sidebar-head h2 {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.todo-icon-btn {
  display: inline-flex;
  width: 1.85rem;
  height: 1.85rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.todo-icon-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-icon-btn:active {
  transform: scale(0.9);
}

.todo-project-form {
  overflow: hidden;
  animation: todo-slide-down 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.todo-project-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--muted);
  color: var(--foreground);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.todo-project-form input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.todo-main {
  min-width: 0;
  background: var(--background);
}

.todo-content {
  width: min(100%, 54rem);
  margin-inline: auto;
  padding: 1.25rem 1.5rem 3rem;
}

.todo-content-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.todo-content-head h1 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.9rem;
  line-height: 1.2;
}

.todo-content-head,
.todo-task-list,
.todo-empty {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.todo-page.is-switching-view .todo-content-head,
.todo-page.is-switching-view .todo-task-list,
.todo-page.is-switching-view .todo-empty {
  opacity: 0;
  transform: translateY(0.35rem);
}

.todo-page.is-view-entering .todo-content-head {
  animation: todo-view-head-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.todo-page.is-view-entering .todo-task-row {
  animation: todo-row-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.todo-page.is-view-entering .todo-task-row:nth-child(2) {
  animation-delay: 28ms;
}

.todo-page.is-view-entering .todo-task-row:nth-child(3) {
  animation-delay: 56ms;
}

.todo-page.is-view-entering .todo-task-row:nth-child(4) {
  animation-delay: 84ms;
}

.todo-page.is-view-entering .todo-task-row:nth-child(n + 5) {
  animation-delay: 112ms;
}

@keyframes todo-view-head-in {
  from {
    opacity: 0;
    transform: translateY(0.35rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes todo-row-in {
  from {
    opacity: 0;
    transform: translateY(0.45rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes todo-form-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes todo-slide-down {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.todo-task-form {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 4px 14px -8px rgba(var(--shadow-color), 0.18);
  transform-origin: top center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  animation: todo-form-in 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.todo-task-form:focus-within {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 12px 30px -14px color-mix(in srgb, var(--primary) 38%, transparent),
    0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.todo-task-compose-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 0.9rem 0.9rem 0.5rem;
}

.todo-task-compose-fields {
  min-width: 0;
}

.todo-title-input,
.todo-description-input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
}

.todo-title-input {
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
}

.todo-title-input::placeholder,
.todo-description-input::placeholder {
  color: color-mix(in srgb, var(--muted-foreground) 78%, var(--foreground));
}

.todo-description-input {
  display: block;
  resize: vertical;
  min-height: 4.6rem;
  max-height: 11rem;
  margin-top: 0.45rem;
  padding: 0;
  color: var(--muted-foreground);
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-y: auto;
  white-space: pre-wrap;
}

.todo-title-input:focus,
.todo-description-input:focus {
  outline: none;
}

.todo-compose-tools {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--muted-foreground);
}

.todo-lines-icon,
.todo-wave-icon,
.todo-paperclip,
.todo-flag,
.todo-alarm {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.todo-lines-icon {
  width: 1.2rem;
  height: 1rem;
  margin-top: 0.25rem;
  background: repeating-linear-gradient(to bottom, currentColor 0 1.5px, transparent 1.5px 5px);
}

.todo-dictate {
  border-radius: 6px;
  background: color-mix(in srgb, #16a34a 12%, var(--card));
  color: #15803d;
  padding: 0.15rem 0.35rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.todo-wave-icon {
  width: 1.45rem;
  height: 1.75rem;
  border-right: 4px solid var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: 999px;
}

.todo-wave-icon::before {
  content: "";
  position: absolute;
  top: 0.25rem;
  left: 0.45rem;
  width: 0.35rem;
  height: 1.15rem;
  border-right: 4px solid var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: 999px;
}

.todo-compose-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.45rem 0.9rem 0.75rem;
}

.todo-chip {
  position: relative;
  display: inline-flex;
  height: 2rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: color-mix(in srgb, var(--foreground) 72%, var(--muted-foreground));
  padding: 0 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.todo-chip:not(:disabled):hover {
  border-color: color-mix(in srgb, var(--foreground) 22%, var(--border));
  background: var(--muted);
  color: var(--foreground);
}

.todo-chip:not(:disabled):active {
  transform: scale(0.96);
}

.todo-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.todo-date-chip:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary);
}

.todo-date-picker {
  position: relative;
  display: inline-flex;
}

.todo-date-picker.has-value .todo-date-chip {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
  color: var(--primary);
}

.todo-date-picker.is-open .todo-date-chip {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  color: var(--primary);
}

.todo-cal {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  z-index: 30;
  width: 17rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  padding: 0.75rem;
  box-shadow: 0 18px 42px -14px rgba(var(--shadow-color), 0.36);
  transform-origin: top left;
  animation: todo-slide-down 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.todo-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.todo-cal-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.todo-cal-nav {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.todo-cal-nav:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-cal-weekdays,
.todo-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
}

.todo-cal-weekdays {
  margin-bottom: 0.3rem;
}

.todo-cal-weekdays span {
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.todo-cal-day {
  display: inline-flex;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.todo-cal-day.is-empty {
  pointer-events: none;
}

.todo-cal-day:hover {
  background: var(--muted);
}

.todo-cal-day.is-today {
  color: var(--primary);
  font-weight: 700;
}

.todo-cal-day.is-selected {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
}

.todo-cal-day.is-selected:hover {
  background: color-mix(in srgb, var(--primary) 85%, #fff);
}

.todo-cal-foot {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.todo-cal-foot-btn {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.todo-cal-foot-btn:hover {
  background: var(--muted);
  border-color: color-mix(in srgb, var(--foreground) 22%, var(--border));
}

.todo-cal-clear:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.todo-more-chip {
  width: 2.25rem;
  padding: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.todo-paperclip {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 999px;
  transform: rotate(-35deg);
}

.todo-flag {
  width: 0.9rem;
  height: 1rem;
  border-left: 2px solid currentColor;
}

.todo-flag::before {
  content: "";
  position: absolute;
  top: 0.1rem;
  left: 0.1rem;
  width: 0.65rem;
  height: 0.45rem;
  border: 1.5px solid currentColor;
  border-left: 0;
}

.todo-alarm {
  width: 1rem;
  height: 1rem;
  border: 1.8px solid currentColor;
  border-radius: 999px;
}

.todo-alarm::before,
.todo-alarm::after {
  content: "";
  position: absolute;
  top: -0.28rem;
  width: 0.38rem;
  height: 0.28rem;
  border: 1.6px solid currentColor;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.todo-alarm::before {
  left: -0.1rem;
  transform: rotate(-35deg);
}

.todo-alarm::after {
  right: -0.1rem;
  transform: rotate(35deg);
}

.todo-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding: 0.75rem 0.8rem;
}

.todo-project-select {
  position: relative;
  min-width: 0;
}

.todo-project-trigger {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: color-mix(in srgb, var(--foreground) 72%, var(--muted-foreground));
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.todo-project-trigger:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-project-select.is-open .todo-project-trigger {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
}

.todo-project-current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-project-caret {
  width: 0.85rem;
  height: 0.85rem;
  color: var(--muted-foreground);
  transition: transform 0.2s ease;
}

.todo-project-select.is-open .todo-project-caret {
  transform: rotate(180deg);
}

.todo-project-menu {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 0;
  z-index: 30;
  min-width: 13rem;
  max-width: min(20rem, 72vw);
  max-height: 15rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 0.35rem;
  box-shadow: 0 16px 38px -12px rgba(var(--shadow-color), 0.34);
  transform-origin: bottom left;
  animation: todo-slide-up 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.todo-project-option {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr) 1rem;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  padding: 0.5rem 0.55rem;
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.todo-project-option:hover {
  background: var(--muted);
}

.todo-project-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-project-hash {
  display: inline-flex;
  justify-content: center;
  color: var(--muted-foreground);
  font-weight: 700;
}

.todo-project-tick {
  width: 0.9rem;
  height: 0.9rem;
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.todo-project-option.is-selected {
  color: var(--primary);
  font-weight: 600;
}

.todo-project-option.is-selected .todo-project-tick {
  opacity: 1;
}

@keyframes todo-slide-up {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.todo-form-actions {
  display: flex;
  gap: 0.5rem;
}

.todo-submit-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--primary) 80%, transparent);
}

.todo-submit-btn:hover {
  background: color-mix(in srgb, var(--primary) 85%, #fff);
  border-color: color-mix(in srgb, var(--primary) 85%, #fff);
  opacity: 1;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 85%, transparent);
}

.todo-submit-btn:active {
  transform: translateY(1px);
}

.todo-task-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.todo-task-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, opacity 0.2s ease;
}

.todo-task-drag {
  display: inline-flex;
  width: 1rem;
  height: 1.4rem;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  cursor: grab;
  opacity: 0.55;
}

.todo-task-drag:active {
  cursor: grabbing;
}

.todo-task-row:hover .todo-task-drag,
.todo-task-row:focus-within .todo-task-drag {
  opacity: 1;
}

.todo-task-row.is-dragging {
  opacity: 0.45;
  transform: scale(0.995);
  box-shadow: 0 14px 30px -20px rgba(var(--shadow-color), 0.7);
}

.todo-task-row:hover {
  border-color: color-mix(in srgb, var(--foreground) 16%, var(--border));
  box-shadow: 0 8px 20px -14px rgba(var(--shadow-color), 0.4);
  transform: translateY(-1px);
}

.todo-task-row.is-completed {
  opacity: 0.62;
}

.todo-check {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--primary);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.todo-check:active {
  transform: scale(0.85);
}

[data-priority="1"] { --todo-priority-color: #ef4444; }
[data-priority="2"] { --todo-priority-color: #eab308; }
[data-priority="3"] { --todo-priority-color: #2563eb; }
[data-priority="4"] { --todo-priority-color: #9ca3af; }

.todo-check,
.productivity-ios input.todo-check[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  border: 2px solid var(--todo-priority-color, #9ca3af);
  border-radius: 50%;
  background: transparent;
}

.todo-check:checked,
.productivity-ios input.todo-check[type="checkbox"]:checked {
  border-color: var(--primary);
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 10 3 3 7-7' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.todo-check:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.todo-context-icons .todo-priority-flag,
.todo-priority-select { color: var(--todo-priority-color); }
.todo-context-icons .todo-priority-flag[aria-pressed="true"] {
  background: color-mix(in srgb, var(--todo-priority-color) 14%, transparent);
  box-shadow: inset 0 0 0 2px var(--todo-priority-color);
}

.todo-task-body {
  min-width: 0;
}

.todo-task-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.todo-task-description {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  color: var(--muted-foreground);
  font-size: 0.84rem;
  line-height: 1.45;
}

.todo-task-row.is-completed .todo-task-title {
  color: var(--muted-foreground);
  text-decoration: line-through;
}

.todo-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
}

.todo-task-meta span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  padding: 0.1rem 0.5rem;
  font-weight: 500;
}

.todo-task-meta-action {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.todo-task-meta-action .ui-icon {
  width: 0.75rem;
  height: 0.75rem;
}

.todo-task-actions {
  display: flex;
  gap: 0.25rem;
}

.todo-task-actions .todo-icon-btn:hover {
  background: color-mix(in srgb, var(--primary) 14%, var(--card));
  color: var(--primary);
}

.todo-task-actions .todo-delete:hover {
  background: color-mix(in srgb, #dc2626 12%, var(--card));
  color: #dc2626;
}

.todo-context-menu {
  position: fixed;
  z-index: 100;
  width: min(15.75rem, calc(100vw - 1rem));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 18px 55px rgba(var(--shadow-color), 0.22);
  padding: 0.35rem 0;
}

.todo-context-menu[hidden] {
  display: none;
}

.todo-context-menu button,
.todo-context-label {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--foreground);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
}

.todo-context-menu button {
  cursor: pointer;
}

.todo-context-menu button:hover:not(:disabled) {
  background: var(--muted);
}

.todo-context-menu button:disabled {
  cursor: default;
}

.todo-context-menu svg,
.todo-context-menu button > span {
  width: 1rem;
  justify-self: center;
  color: var(--muted-foreground);
}

.todo-context-menu kbd {
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.72rem;
}

.todo-context-separator {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.todo-context-label {
  padding-bottom: 0.2rem;
  color: var(--foreground);
  font-size: 0.78rem;
  font-weight: 800;
}

.todo-context-label span {
  grid-column: 1 / 3;
}

.todo-context-icons {
  display: grid;
  grid-template-columns: repeat(5, 1.9rem);
  gap: 0.35rem;
  padding: 0.15rem 0.75rem 0.55rem;
}

.todo-context-icons button {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.todo-context-icons .is-green {
  color: #16a34a;
}

.todo-context-icons .is-amber {
  color: #d97706;
}

.todo-context-icons .is-amber::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.todo-context-icons .is-blue {
  color: #2563eb;
}

.todo-context-icons .is-blue::before {
  content: "";
  width: 1.15rem;
  height: 0.78rem;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.todo-context-icons .is-violet {
  color: #7c3aed;
}

.todo-context-icons .is-clear {
  color: var(--muted-foreground);
}

.todo-context-icons .is-clear svg {
  width: 0.85rem;
  height: 0.85rem;
}

.todo-context-icons .flag-red {
  color: #ef4444;
}

.todo-context-icons .flag-orange {
  color: #f97316;
}

.todo-context-icons .flag-blue {
  color: #2563eb;
}

.todo-context-menu button.is-danger {
  color: #dc2626;
}

.todo-context-menu button.is-danger svg {
  color: #dc2626;
}

.tb-context-menu {
  width: min(10rem, calc(100vw - 1rem));
}

.todo-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.36);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0);
  transition:
    opacity 0.3s ease,
    backdrop-filter 0.34s ease;
}

.todo-detail-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(5px);
}

.todo-detail-backdrop[hidden] {
  display: none;
}

.todo-detail-modal {
  display: grid;
  width: min(54rem, calc(100vw - 2rem));
  height: min(51rem, calc(100vh - 3rem));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 24px 80px rgba(var(--shadow-color), 0.28);
  opacity: 0;
  transform: translateY(2rem) scale(0.94);
  transform-origin: 50% 46%;
  transition:
    opacity 0.28s ease,
    transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.todo-detail-backdrop.is-open .todo-detail-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.todo-detail-head,
.todo-detail-body {
  opacity: 0;
  transform: translateY(0.55rem);
  transition:
    opacity 0.28s ease 0.1s,
    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.todo-detail-backdrop.is-open .todo-detail-head,
.todo-detail-backdrop.is-open .todo-detail-body {
  opacity: 1;
  transform: translateY(0);
}

.todo-detail-head {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
}

.todo-detail-context,
.todo-detail-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.todo-detail-context {
  min-width: 0;
  color: var(--foreground);
  font-size: 0.86rem;
  font-weight: 650;
}

.todo-detail-context span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-detail-actions .todo-icon-btn:disabled {
  opacity: 0.45;
}

.todo-detail-body {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 16.25rem;
  overflow: visible;
}

.todo-detail-main {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1.15rem 1.5rem;
}

.todo-detail-title-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.7rem;
}

.todo-detail-title-input,
.todo-detail-description,
.todo-detail-side select,
.todo-detail-side input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
}

.todo-detail-title-input {
  min-height: 2rem;
  font-size: 1.35rem;
  font-weight: 750;
  line-height: 1.35;
}

.todo-detail-description {
  display: block;
  margin: 0.35rem 0 0 1.9rem;
  max-width: calc(100% - 1.9rem);
  resize: vertical;
  color: var(--muted-foreground);
  font-size: 0.95rem;
  line-height: 1.55;
}

.todo-detail-title-input[readonly],
.todo-detail-description[readonly] {
  cursor: pointer;
}

.todo-detail-title-input[readonly]:focus,
.todo-detail-description[readonly]:focus {
  outline: 0;
}

.todo-detail-title-input.is-editing,
.todo-detail-description.is-editing {
  border-radius: calc(var(--radius) - 3px);
  background: color-mix(in srgb, var(--muted) 28%, var(--card));
  padding-inline: 0.35rem;
}

.todo-detail-edit-actions {
  display: flex;
  justify-content: flex-start;
  margin: 0.75rem 0 0 1.9rem;
}

.todo-detail-edit-actions[hidden] {
  display: none;
}

.todo-detail-title-input:focus,
.todo-detail-description:focus,
.todo-detail-side select:focus,
.todo-detail-side input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 28%, transparent);
  outline-offset: 2px;
}

.todo-detail-subtasks {
  margin-top: 1.1rem;
}

.todo-detail-subtask {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0 0 1.9rem;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

.todo-detail-subtask-input {
  display: block;
  width: calc(100% - 1.9rem);
  margin: 0.25rem 0 0 1.9rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 3px);
  background: var(--card);
  color: var(--foreground);
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
}

.todo-detail-subtask-input[hidden] {
  display: none;
}

.todo-detail-subtask-input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 28%, transparent);
  outline-offset: 2px;
}

.todo-detail-subtask-list {
  display: flex;
  flex-direction: column;
  margin-left: 1.9rem;
}

.todo-detail-subtask-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.todo-detail-subtask-row:last-child {
  border-bottom: 0;
}

.todo-detail-subtask-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  cursor: pointer;
}

.todo-detail-subtask-row.is-completed .todo-detail-subtask-title {
  color: var(--muted-foreground);
  text-decoration: line-through;
}

.todo-detail-subtask-count {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
}

[data-todo-detail-back][hidden] {
  display: none;
}

.todo-detail-comments {
  margin-top: 1.4rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.todo-detail-comment-list {
  display: grid;
  gap: 0.85rem;
}

.todo-detail-comment-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.65rem;
}

.todo-detail-comment-content {
  position: relative;
  min-width: 0;
}

.todo-detail-comment-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.todo-detail-comment-item strong,
.todo-detail-comment-item p,
.todo-detail-comment-item time {
  display: block;
}

.todo-detail-comment-item strong {
  font-size: 0.82rem;
  font-weight: 750;
}

.todo-detail-comment-item p {
  margin: 0.18rem 0 0;
  color: var(--foreground);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.todo-detail-comment-item time,
.todo-detail-comment-empty {
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

.todo-comment-menu-btn {
  display: inline-flex;
  width: 1.65rem;
  height: 1.65rem;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1;
}

.todo-comment-menu-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-comment-menu {
  position: absolute;
  top: 1.75rem;
  right: 0;
  z-index: 12;
  width: 14rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(var(--shadow-color), 0.18);
}

.todo-comment-menu[hidden] {
  display: none;
}

.todo-comment-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  color: var(--foreground);
  padding: 0.72rem 0.85rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
}

.todo-comment-menu button:hover {
  background: var(--muted);
}

.todo-comment-menu button.is-danger {
  border-top: 1px solid var(--border);
  color: #dc2626;
}

.todo-comment-menu .ui-icon {
  width: 1rem;
  height: 1rem;
}

.todo-comment-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.todo-comment-edit-form[hidden] {
  display: none;
}

.todo-comment-edit-form input {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.todo-comment-edit-form .btn {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.todo-detail-comment-empty {
  margin: 0;
}

.todo-detail-comment-empty[hidden] {
  display: none;
}

.todo-detail-comment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
}

.todo-detail-avatar {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #b23a8b;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
}

.todo-detail-avatar .ui-icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 2.2;
}

.todo-detail-comment-input {
  display: flex;
  min-height: 2rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid transparent;
  background: var(--muted);
  border-radius: 999px;
  color: var(--muted-foreground);
  padding: 0 0.8rem;
  font-size: 0.88rem;
}

.todo-detail-comment-input input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  outline: 0;
}

.todo-detail-comment-input input::placeholder {
  color: var(--muted-foreground);
}

/* After-completion actions section */
.todo-detail-after-completion {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0 0.5rem;
}

.todo-detail-after-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.todo-detail-after-head > span {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 750;
}

.todo-detail-action-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0;
}

.todo-detail-action-add-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-action-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0;
  font-size: 0.82rem;
}

.todo-action-row-icon {
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.todo-action-row-desc {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-action-row-mode {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.todo-action-row .todo-icon-btn {
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
}

.todo-action-row:hover .todo-icon-btn {
  opacity: 1;
  pointer-events: auto;
}

.todo-detail-action-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem;
  background: var(--muted);
  border-radius: 8px;
  margin-top: 0.35rem;
}

.todo-detail-action-form[hidden] {
  display: none;
}

.todo-action-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.todo-action-form-label {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
}

.todo-action-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.todo-action-radios {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
}

.todo-action-radios label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.todo-action-hours-input {
  width: 6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
}

.todo-action-form-btns {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
}

.todo-action-form-btns .btn {
  min-height: 1.9rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* Completion action modal */
.todo-completion-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.todo-completion-backdrop[hidden] {
  display: none;
}

.todo-completion-modal {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  padding: 1.5rem 1.75rem;
  max-width: 26rem;
  width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.todo-completion-eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.todo-completion-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.todo-completion-body {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.88rem;
  line-height: 1.55;
}

.todo-completion-input-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.todo-completion-input-row[hidden] {
  display: none;
}

.todo-completion-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.todo-completion-hours {
  width: 8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.92rem;
}

.todo-completion-hours:focus {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.todo-completion-btns {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.todo-detail-comment-submit {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  cursor: pointer;
}

.todo-detail-comment-submit[hidden] {
  display: none;
}

.todo-detail-comment-submit:hover {
  color: color-mix(in srgb, var(--primary) 76%, var(--foreground));
}

.todo-detail-comment-submit:disabled {
  cursor: default;
  opacity: 0.55;
}

.todo-detail-side {
  position: relative;
  z-index: 5;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: visible;
  background: color-mix(in srgb, var(--muted) 22%, var(--card));
  padding: 1rem 1.5rem;
}

.todo-detail-field {
  display: grid;
  gap: 0.45rem;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.todo-detail-field > span {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 750;
}

.todo-detail-field strong,
.todo-detail-side select,
.todo-detail-side input {
  min-height: 1.5rem;
  color: var(--foreground);
  font-size: 0.88rem;
  font-weight: 550;
}

.todo-detail-side select,
.todo-detail-side input {
  cursor: pointer;
}

.todo-detail-field.is-locked strong {
  color: var(--muted-foreground);
}

.todo-detail-date-field {
  position: relative;
}

.todo-detail-date-trigger {
  display: flex;
  width: 100%;
  min-height: 1.6rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  color: var(--foreground);
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  text-align: left;
}

.todo-detail-date-trigger .ui-icon {
  color: var(--muted-foreground);
}

.todo-detail-date-field.has-value .todo-detail-date-trigger span {
  color: var(--primary);
  font-weight: 700;
}

.todo-detail-date-pop {
  position: absolute;
  top: 0.25rem;
  right: calc(100% + 0.75rem);
  z-index: 20;
  width: min(15.75rem, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 18px 60px rgba(var(--shadow-color), 0.22);
}

.todo-detail-date-pop[hidden] {
  display: none;
}

.todo-detail-date-type {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-size: 0.88rem;
}

.todo-detail-date-type::placeholder {
  color: var(--muted-foreground);
}

.todo-detail-date-presets {
  display: grid;
  gap: 0.1rem;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
}

.todo-detail-date-presets button {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  padding: 0.42rem 0.45rem;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.todo-detail-date-presets button:hover,
.todo-detail-date-day:hover {
  background: var(--muted);
}

.todo-detail-date-presets strong {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-detail-date-presets em {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-style: normal;
}

.date-preset-icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--muted-foreground);
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1;
}

.date-preset-icon.is-green {
  color: #16a34a;
}

.date-preset-icon.is-amber {
  border-radius: 999px;
  color: #d97706;
}

.date-preset-icon.is-blue {
  color: #2563eb;
}

.date-preset-icon.is-violet {
  color: #7c3aed;
}

.todo-detail-date-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.95rem 0.35rem;
}

.todo-detail-date-cal-head strong {
  font-size: 0.88rem;
  font-weight: 800;
}

.todo-detail-date-cal-head div {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.todo-detail-date-cal-head button {
  display: inline-flex;
  width: 1.45rem;
  height: 1.45rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  font: inherit;
}

.todo-detail-date-cal-head button:hover {
  background: var(--muted);
  color: var(--foreground);
}

.todo-detail-date-weekdays,
.todo-detail-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.1rem;
  padding-inline: 0.85rem;
}

.todo-detail-date-weekdays {
  margin-bottom: 0.25rem;
}

.todo-detail-date-weekdays span {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 650;
  text-align: center;
}

.todo-detail-date-grid {
  padding-bottom: 0.7rem;
}

.todo-detail-date-day {
  display: inline-flex;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}

.todo-detail-date-day.is-empty {
  pointer-events: none;
}

.todo-detail-date-day.is-today {
  color: #dc2626;
  font-weight: 800;
}

.todo-detail-date-day.is-selected {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 800;
}

.todo-detail-date-extra {
  display: flex;
  width: calc(100% - 1rem);
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 0.5rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.todo-detail-date-extra:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.time-block-todos {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.time-block-todos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.time-block-todos-head h3 {
  margin: 0;
  font-size: 1rem;
}

.time-block-todo-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.time-block-todo-actions .todo-icon-btn {
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  color: var(--primary);
}

.time-block-todo-form {
  display: grid;
  gap: 0.7rem;
}

.time-block-todo-form input[type="text"],
.time-block-todo-form textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--muted);
  color: var(--foreground);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.time-block-todo-form textarea {
  resize: vertical;
}

.time-block-todo-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

.time-block-todo-check input {
  accent-color: var(--primary);
}

.time-block-todo-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.time-block-todo-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
}

.time-block-todo-row .btn {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
}

.time-todo-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-color), 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.time-todo-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.time-todo-modal-backdrop[hidden] {
  display: none;
}

.time-todo-modal {
  display: flex;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(38rem, calc(100vh - 2rem));
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.24);
  transform: translateY(0.5rem) scale(0.98);
  transition: transform 0.18s ease;
}

.time-todo-modal-backdrop.is-open .time-todo-modal {
  transform: translateY(0) scale(1);
}

.time-todo-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.time-todo-modal-head h2 {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
}

.time-todo-modal > .time-block-todo-list {
  overflow: auto;
}

.drawer-close.mini {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.9rem;
}

@media (hover: hover) {
  .todo-task-actions {
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .todo-task-row:hover .todo-task-actions,
  .todo-task-row:focus-within .todo-task-actions {
    opacity: 1;
    transform: translateX(0);
  }
}

.todo-empty {
  display: flex;
  min-height: 25rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.todo-empty-art {
  width: min(18rem, 70vw);
  margin-bottom: 1.25rem;
}

.todo-empty-art svg {
  display: block;
  width: 100%;
  height: auto;
  animation: todo-float 4.5s ease-in-out infinite;
}

@keyframes todo-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .todo-task-form,
  .todo-project-form,
  .todo-empty-art svg,
  .todo-add-main span,
  .todo-task-row,
  .todo-task-actions,
  .todo-content-head,
  .todo-task-list,
  .todo-empty,
  .todo-project-menu,
  .todo-project-caret,
  .todo-cal,
  .todo-detail-backdrop,
  .todo-detail-modal,
  .auth-loader,
  .auth-loader-spinner,
  .auth-page[data-auth-page],
  .login-hero-text,
  .login-card {
    animation: none !important;
    transition: none !important;
  }
}

.todo-empty h2 {
  margin: 0;
  font-size: 1.35rem;
}

.todo-empty p {
  max-width: 18rem;
  margin: 0.5rem 0 1rem;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* ===== Today ===== */
.today-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.today-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 0.34fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.today-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
}

.today-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
}

.today-panel-head h2,
.today-time-state h2 {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.today-panel-link {
  flex-shrink: 0;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.today-items {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.today-item {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--muted) 24%, var(--card));
  padding: 0.85rem;
}

.today-item span {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 750;
}

.today-item p,
.today-empty {
  margin: 0.35rem 0 0;
  color: var(--foreground);
  font-size: 0.92rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.today-empty {
  color: var(--muted-foreground);
}

.today-time {
  display: grid;
  grid-template-columns: minmax(14rem, 0.9fr) minmax(16rem, 1fr);
  min-height: 12.5rem;
  gap: 1rem;
}

.today-time-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.today-time-state::before {
  content: "";
  display: block;
  width: 2rem;
  height: 0.2rem;
  margin-bottom: 0.8rem;
  border-radius: 999px;
  background: var(--primary);
}

.today-time-state.is-upcoming::before {
  background: #d97706;
}

.today-time-state.is-done::before,
.today-time-state.is-empty::before {
  background: var(--muted-foreground);
}

.today-time-state p:last-of-type {
  margin: 0.55rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.6;
}

.today-time-state .calendar-eyebrow {
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.today-time-state > span {
  display: inline-flex;
  margin-top: 0.55rem;
  color: var(--muted-foreground);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

.today-time-state > span:empty {
  display: none;
}

.today-next-block {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.today-next-block span {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.today-next-block strong {
  display: block;
  margin-top: 0.25rem;
  overflow: hidden;
  color: var(--foreground);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-time-agenda {
  min-width: 0;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.today-time-agenda-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.today-time-agenda-head span {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.today-time-agenda-head a {
  flex-shrink: 0;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 750;
}

.today-time-list {
  display: grid;
  gap: 0.45rem;
}

.today-time-list-item {
  display: grid;
  grid-template-columns: minmax(4.8rem, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
  border-radius: calc(var(--radius) - 4px);
  background: color-mix(in srgb, var(--muted) 18%, var(--card));
  padding: 0.48rem 0.58rem;
}

.today-time-list-item span,
.today-time-list-item em {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.today-time-list-item strong {
  overflow: hidden;
  color: var(--foreground);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-time-list-item.is-now {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--border));
  background: color-mix(in srgb, var(--primary) 9%, var(--card));
}

.today-time-list-item.is-now em {
  color: var(--primary);
}

.today-time-list-item.is-past {
  opacity: 0.62;
}

.today-time-list-empty {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  line-height: 1.5;
}

.today-track-plans-panel {
  padding-bottom: 0;
}

.today-track-plan-list {
  display: grid;
  margin: 1rem -1rem 0;
}

.today-track-plan {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  padding: 0.82rem 1rem;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.today-track-plan:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  transform: translateY(-1px);
}

.today-track-plan.is-active {
  background: color-mix(in srgb, #facc15 7%, transparent);
}

.today-track-plan.is-active:hover {
  background: color-mix(in srgb, #facc15 11%, transparent);
}

.today-track-plan.is-done {
  background: color-mix(in srgb, #22c55e 7%, transparent);
}

.today-track-plan.is-done:hover {
  background: color-mix(in srgb, #22c55e 11%, transparent);
}

.today-track-plan-main,
.today-track-plan-hours {
  min-width: 0;
}

.today-track-plan-main strong,
.today-track-plan-main span,
.today-track-plan-hours strong,
.today-track-plan-hours span {
  display: block;
}

.today-track-plan-main strong {
  overflow: hidden;
  color: var(--foreground);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-track-plan-main span,
.today-track-plan-hours span {
  margin-top: 0.2rem;
  color: var(--muted-foreground);
  font-size: 0.76rem;
  line-height: 1.35;
}

.today-track-plan-hours {
  text-align: right;
}

.today-track-plan-hours strong {
  color: var(--foreground);
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.today-track-plan-progress {
  grid-column: 1 / -1;
  height: 0.32rem;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted-foreground) 14%, transparent);
}

.today-track-plan-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.today-todos-panel {
  padding-bottom: 0;
}

.today-todo-list {
  margin: 1rem -1rem 0;
}

.today-todo-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  padding: 0.8rem 1rem;
  transition: opacity 0.18s ease;
}

.today-todo-check {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.today-todo-body {
  min-width: 0;
}

.today-todo-title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}

.today-todo-desc {
  display: block;
  margin-top: 0.2rem;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-todo-project {
  flex-shrink: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  color: color-mix(in srgb, var(--primary) 82%, var(--foreground));
  padding: 0.18rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
}

.today-todo-project.is-inbox {
  background: var(--muted);
  color: var(--muted-foreground);
}

.today-todo-row.is-completed {
  opacity: 0.55;
}

.today-todo-row.is-completed .today-todo-title {
  color: var(--muted-foreground);
  text-decoration: line-through;
}

.today-habits-panel {
  padding-bottom: 0;
}

.today-habit-list-wrap {
  position: relative;
  margin: 1rem -1rem 0;
}

.today-habit-list {
  position: relative;
  overflow: hidden;
  transition: max-height 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: max-height;
}

.today-habit-list-wrap.is-collapsed .today-habit-list {
  max-height: 10.35rem;
}

.today-habit-list-wrap.is-expanded .today-habit-list {
  max-height: var(--today-habit-list-height, 60rem);
}

.today-habit-list-wrap.is-collapsed::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2.45rem;
  left: 0;
  height: 3.25rem;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--card) 12%, transparent),
    color-mix(in srgb, var(--card) 92%, transparent)
  );
  pointer-events: none;
}

.today-habit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  padding: 0.8rem 1rem;
}

.today-habit-row.is-priority {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.today-habit-row.is-updating {
  opacity: 0.72;
}

.today-habit-row strong,
.today-habit-row span {
  display: block;
}

.today-habit-row strong {
  font-size: 0.92rem;
  line-height: 1.35;
}

.today-habit-row div > span {
  margin-top: 0.2rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.today-habit-status-wrap {
  flex-shrink: 0;
}

.today-habit-status {
  display: inline-flex;
  min-width: 5.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 0.28rem 0.6rem;
  color: var(--foreground);
  cursor: pointer;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
  appearance: none;
}

.today-habit-status.is-pending {
  border-color: color-mix(in srgb, var(--muted-foreground) 46%, var(--border));
  background: color-mix(in srgb, var(--muted-foreground) 13%, var(--card));
  color: var(--muted-foreground);
}

.today-habit-status.is-done {
  border-color: color-mix(in srgb, #16a34a 40%, var(--border));
  background: color-mix(in srgb, #16a34a 14%, var(--card));
  color: #15803d;
}

.today-habit-status.is-missed {
  border-color: color-mix(in srgb, #dc2626 40%, var(--border));
  background: color-mix(in srgb, #dc2626 12%, var(--card));
  color: #b91c1c;
}

.today-habit-expand {
  position: relative;
  z-index: 1;
  width: 100%;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  background: color-mix(in srgb, var(--muted) 24%, var(--card));
  color: var(--primary);
  padding: 0.72rem 1rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.today-habit-expand:hover {
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
  }

  .brand {
    font-size: 0.9rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .post,
  .footer-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .post time {
    align-self: center;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-actions .btn {
    width: 100%;
    height: auto;
    min-height: 44px;
    padding-block: 0.55rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .today-layout {
    grid-template-columns: 1fr;
  }

  .today-time {
    grid-template-columns: 1fr;
  }

  .today-time-agenda {
    border-top: 1px solid var(--border);
    border-left: 0;
    padding-top: 1rem;
    padding-left: 0;
  }

  .today-time-list-item {
    grid-template-columns: 1fr auto;
  }

  .today-time-list-item span {
    grid-column: 1 / -1;
  }

  .today-track-plan {
    grid-template-columns: 1fr;
  }

  .today-track-plan-hours {
    text-align: left;
  }

  .today-panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
  }

  .today-habit-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .calendar-card {
    padding: 0.65rem;
  }

  .app-calendar-weekdays,
  .app-calendar-week,
  .app-calendar-month {
    gap: 0.25rem;
  }

  .app-calendar-day {
    min-height: 4.4rem;
    padding: 0.45rem;
  }

  .calendar-day-preview {
    display: none;
  }

  .calendar-drawer {
    top: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-height: 86vh;
    transform: translateY(calc(100% + 1rem));
  }

  .calendar-drawer.is-left {
    right: 0.5rem;
    left: 0.5rem;
    transform: translateY(calc(100% + 1rem));
  }

  .calendar-drawer.is-open {
    transform: translateY(0);
  }

  .calendar-drawer.is-left.is-open {
    transform: translateY(0);
  }

  .time-header,
  .time-body {
    min-width: calc(4rem + 7 * 8.75rem);
  }

  .time-header {
    grid-template-columns: 4rem repeat(7, minmax(8.75rem, 1fr));
  }

  .time-body {
    grid-template-columns: 4rem minmax(0, 1fr);
  }

  .time-days {
    grid-template-columns: repeat(7, minmax(8.75rem, 1fr));
  }

  .time-calendar {
    margin-inline: -0.75rem;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    scroll-snap-type: x proximity;
  }

  .time-day-head {
    padding: 0.5rem;
  }

  .time-day-head strong {
    font-size: 0.8rem;
  }

  .time-axis-hour {
    height: 4.3rem;
    font-size: 0.68rem;
  }

  .time-day-column {
    min-height: calc(18 * 4.3rem);
    scroll-snap-align: start;
  }

  .time-day-grid {
    grid-template-rows: repeat(36, 2.15rem);
  }

  .time-hour-slot:hover::after {
    opacity: 0;
  }

  .time-hour-slot.is-selection-range-start::after,
  .time-hour-slot.is-selection-range-end::after {
    display: none;
  }

  .time-page .calendar-actions {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.15rem;
  }

  .time-page .calendar-actions .btn {
    flex: 0 0 auto;
    width: auto;
    height: 2.5rem;
    white-space: nowrap;
  }

  .time-mobile-selection {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .time-form-row {
    grid-template-columns: 1fr;
  }

}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  max-width: 42rem;
}

.settings-security-card,
.mobile-nav-setting {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 16px 0;
}
.mobile-nav-setting .field { flex: 1; min-width: 0; margin: 0; }
.mobile-nav-setting select { width: 100%; min-height: 44px; }
.mobile-nav-setting button { flex: 0 0 44px; width: 44px; min-width: 44px; min-height: 44px; padding: 8px; }
.mobile-nav-setting button:disabled { opacity: .35; cursor: default; }

.settings-backup-card {
  margin-top: 1rem;
}

.settings-section h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.settings-hint {
  margin: 0 0 1rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.5;
}

.settings-options {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.settings-label {
  margin-bottom: 0.6rem;
  padding: 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.settings-option:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.settings-option.is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.settings-option input {
  accent-color: var(--primary);
}

.settings-color-options {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.settings-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, #000 12%, transparent);
}

.settings-color-swatch[data-color="blue"] { background: #007aff; }
.settings-color-swatch[data-color="pink"] { background: #ec6a9c; }
.settings-color-swatch[data-color="red"] { background: #ff3b30; }
.settings-color-swatch[data-color="green"] { background: #34c759; }
.settings-color-swatch[data-color="purple"] { background: #5856d6; }

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.settings-import-form {
  display: grid;
  gap: 1rem;
}

.settings-password-modal form {
  display: grid;
  gap: 1rem;
}

.settings-password-modal .settings-hint,
.settings-password-modal .settings-error {
  margin-bottom: 0;
}

.settings-danger-option {
  border-color: color-mix(in srgb, #dc2626 28%, var(--border));
}

.settings-danger-option:hover {
  border-color: color-mix(in srgb, #dc2626 45%, var(--border));
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}

.settings-saved,
.settings-error {
  margin: 0 0 1.25rem;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.settings-saved {
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.settings-error {
  border: 1px solid color-mix(in srgb, #dc2626 38%, var(--border));
  background: color-mix(in srgb, #dc2626 10%, transparent);
  color: #b91c1c;
}

/* ===== Time Tracking ===== */
.tracking-total-head {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 750;
}

.tracking-board {
  margin-top: 0;
}

.tracking-mode-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 0.18rem;
}

.tracking-mode-toggle button {
  min-width: 4.2rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.tracking-mode-toggle button.is-active {
  background: var(--foreground);
  color: var(--background);
}

.tracking-week-nav {
  display: flex;
  gap: 0.5rem;
}

.tracking-grid {
  min-width: 52rem;
  --tracking-cols: minmax(10rem, 17rem) repeat(7, minmax(4rem, 1fr)) minmax(4.2rem, 5rem);
}

.tracking-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--tracking-cols);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 62%, var(--card));
}

.tracking-total-head {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  padding: 0.75rem 0.5rem;
}

.tracking-row {
  display: grid;
  grid-template-columns: var(--tracking-cols);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.tracking-category-total-row {
  display: grid;
  grid-template-columns: var(--tracking-cols);
  border-top: 1px solid color-mix(in srgb, var(--foreground) 10%, var(--border));
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--muted) 32%, var(--card));
}

.tracking-category-total-label,
.tracking-category-total-cell {
  display: flex;
  min-height: 2.45rem;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  font-size: 0.76rem;
  font-weight: 800;
}

.tracking-category-total-label {
  justify-content: flex-start;
  padding: 0 0.85rem;
}

.tracking-category-total-cell {
  border-left: 1px solid color-mix(in srgb, var(--border) 62%, transparent);
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
}

.tracking-category-total-cell:not(:empty) {
  color: color-mix(in srgb, var(--foreground) 82%, var(--muted-foreground));
}

.tracking-category-total-cell.is-total {
  background: color-mix(in srgb, var(--foreground) 5%, transparent);
  color: var(--foreground);
}

.tracking-cell {
  position: relative;
  display: flex;
  min-height: 2.75rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.13s ease, box-shadow 0.13s ease;
}

.tracking-cell:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.tracking-board .habit-day-head.is-today {
  background: color-mix(in srgb, var(--muted-foreground) 10%, var(--card));
  color: var(--foreground);
}

.tracking-cell.is-today-column {
  background: color-mix(in srgb, var(--muted-foreground) 7%, transparent);
}

.tracking-cell.is-today-column:hover {
  background: color-mix(in srgb, var(--muted-foreground) 10%, transparent);
}

.tracking-cell:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--primary) 45%, transparent);
}

.tracking-cell.has-records {
  background: color-mix(in srgb, var(--primary) 11%, transparent);
  font-weight: 700;
}

.tracking-cell.has-plan {
  box-shadow: inset 0 -2px 0 color-mix(in srgb, #16a34a 52%, transparent);
}

.tracking-board.is-plan-mode .tracking-cell {
  background: color-mix(in srgb, #16a34a 5%, transparent);
}

.tracking-board.is-plan-mode .tracking-cell.has-plan {
  background: color-mix(in srgb, #16a34a 13%, transparent);
  font-weight: 700;
}

.tracking-board.is-plan-mode .tracking-cell:hover {
  background: color-mix(in srgb, #16a34a 18%, transparent);
}

.tracking-cell.has-records.is-today-column {
  background: color-mix(in srgb, var(--primary) 8%, color-mix(in srgb, var(--muted-foreground) 8%, transparent));
}

.tracking-cell.has-records:hover {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.tracking-cell.has-records.is-today-column:hover {
  background: color-mix(in srgb, var(--primary) 12%, color-mix(in srgb, var(--muted-foreground) 10%, transparent));
}

.tracking-cell-value {
  pointer-events: none;
}

.tracking-cell-plan {
  color: color-mix(in srgb, #16a34a 74%, var(--foreground));
  font-family: "Vazirmatn", sans-serif;
  font-size: 0.66rem;
  font-weight: 750;
  line-height: 1.1;
  pointer-events: none;
}

.tracking-board.is-plan-mode .tracking-cell-value {
  display: none;
}

.tracking-board.is-actual-mode .tracking-cell-plan:empty {
  display: none;
}

.tracking-board.is-plan-mode .tracking-cell-plan:empty::before {
  content: "+";
  color: color-mix(in srgb, var(--muted-foreground) 62%, transparent);
}

.tracking-board.is-actual-mode .tracking-cell:not(.has-records) .tracking-cell-value::before {
  content: "+";
  color: color-mix(in srgb, var(--muted-foreground) 60%, transparent);
  opacity: 0;
  transition: opacity 0.13s ease;
}

.tracking-board.is-actual-mode .tracking-cell:not(.has-records):hover .tracking-cell-value::before {
  opacity: 1;
}

.tracking-cell-badge {
  position: absolute;
  top: 0.28rem;
  right: 0.32rem;
  display: inline-flex;
  min-width: 1.05rem;
  height: 1.05rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0 0.25rem;
  font-family: "Vazirmatn", sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.tracking-row-total {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 22%, var(--card));
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.84rem;
  font-weight: 800;
}

.tracking-row.habit-add-row .habit-add-input {
  grid-column: 1 / -1;
}

.tracking-overview-modal {
  width: min(58rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

/* ===== Day records modal ===== */
.track-records-modal {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
}

.track-records-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.track-records-head h2 {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
}

.track-records-head .calendar-today {
  margin: 0.2rem 0 0;
}

.track-records-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  max-height: 18rem;
}

.track-records-empty {
  margin: 0;
  padding: 0.75rem 0;
  color: var(--muted-foreground);
  font-size: 0.86rem;
  text-align: center;
}

.track-record {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 0.55rem 0.65rem;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.track-record:hover {
  border-color: color-mix(in srgb, var(--foreground) 16%, var(--border));
}

.track-record.is-editing {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.track-record-hours-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 13%, var(--card));
  color: color-mix(in srgb, var(--primary) 80%, var(--foreground));
  padding: 0.3rem 0.4rem;
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 0.82rem;
  font-weight: 800;
}

.track-record-body {
  min-width: 0;
}

.track-record-title-text {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 600;
  font-size: 0.92rem;
}

.track-record-title-text.is-untitled {
  color: var(--muted-foreground);
  font-style: italic;
  font-weight: 500;
}

.track-record-desc-text {
  margin: 0.18rem 0 0;
  overflow-wrap: anywhere;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  line-height: 1.45;
}

.track-record-actions {
  display: flex;
  gap: 0.15rem;
}

.track-record-actions .habit-icon-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.track-record-actions .track-record-del:hover {
  background: color-mix(in srgb, #dc2626 12%, var(--card));
  color: #dc2626;
}

.track-record-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.track-record-title,
.track-record-desc,
.track-record-hours {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.track-record-desc {
  resize: vertical;
  min-height: 2.6rem;
  line-height: 1.45;
}

.track-record-title:focus,
.track-record-desc:focus,
.track-record-hours:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.track-record-form-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.track-record-hours-field {
  position: relative;
  flex: 1;
  width: 100%;
  min-width: 0;
}

.track-record-hours {
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  padding-right: 1.8rem;
}

.track-record-hours-suffix {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 0.85rem;
  pointer-events: none;
}

.track-records-foot {
  display: grid;
  gap: 0.38rem;
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.track-records-foot-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.track-records-foot strong {
  color: var(--foreground);
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 1.05rem;
}

.track-goal-card {
  display: grid;
  gap: 0.45rem;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 18%, var(--card));
  padding: 0.65rem;
  --track-goal-color: var(--muted-foreground);
  --track-goal-fill: color-mix(in srgb, var(--muted-foreground) 42%, transparent);
  --track-goal-bg: color-mix(in srgb, var(--muted-foreground) 12%, transparent);
}

.track-goal-card[data-goal-state="planned"] {
  --track-goal-color: #0284c7;
  --track-goal-fill: #38bdf8;
  --track-goal-bg: color-mix(in srgb, #38bdf8 16%, transparent);
}

.track-goal-card[data-goal-state="active"] {
  --track-goal-color: #ca8a04;
  --track-goal-fill: #facc15;
  --track-goal-bg: color-mix(in srgb, #facc15 18%, transparent);
}

.track-goal-card[data-goal-state="near"] {
  --track-goal-color: #2563eb;
  --track-goal-fill: #60a5fa;
  --track-goal-bg: color-mix(in srgb, #60a5fa 18%, transparent);
}

.track-goal-card[data-goal-state="done"] {
  --track-goal-color: #16a34a;
  --track-goal-fill: #22c55e;
  --track-goal-bg: color-mix(in srgb, #22c55e 18%, transparent);
}

.track-goal-card .track-records-foot-line span,
.track-goal-meta {
  color: color-mix(in srgb, var(--track-goal-color) 68%, var(--muted-foreground));
}

.track-goal-card .track-records-foot-line strong {
  color: var(--track-goal-color);
}

.track-goal-bar {
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track-goal-bg);
}

.track-goal-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--track-goal-fill), color-mix(in srgb, var(--track-goal-fill) 72%, white));
  transition: width 0.22s ease;
}

.track-goal-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.74rem;
  font-weight: 700;
}

.track-plan-modal {
  width: min(25rem, calc(100vw - 2rem));
}

.track-plan-actions {
  justify-content: flex-end;
}

.track-week-select-modal {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
}

.track-week-select-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.track-week-select-search::placeholder {
  color: var(--muted-foreground);
}

.track-week-select-search:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.track-week-select-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 20rem;
  padding-right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
}

.track-week-select-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.5rem 0.75rem;
  margin: 0;
  font-weight: 600;
  font-size: 0.86rem;
  background: color-mix(in srgb, var(--card) 92%, var(--muted-foreground) 8%);
  border-bottom: 1px solid var(--border);
}

.track-week-select-group-head label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.track-week-select-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.track-week-select-item:last-child {
  border-bottom: none;
}

.track-week-select-item:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.track-week-select-group-head input,
.track-week-select-item input {
  cursor: pointer;
  accent-color: var(--primary);
}

.track-week-select-empty {
  margin: 0;
  padding: 1.5rem 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.86rem;
  text-align: center;
}

.track-week-select-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.track-week-select-spinner-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  animation: track-week-select-spin 0.7s linear infinite;
}

@keyframes track-week-select-spin {
  to {
    transform: rotate(360deg);
  }
}

.track-manage-modal {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
}

.track-manage-list {
  max-height: 18rem;
}

.track-manage-category-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.track-manage-category-head .track-manage-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-manage-item {
  cursor: grab;
}

.track-manage-item:active {
  cursor: grabbing;
}

.track-manage-item.is-reordering {
  opacity: 0.4;
}

.track-manage-item .track-manage-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-manage-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  margin-inline-start: auto;
}

.habit-icon-btn.is-rename:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}

.track-manage-rename-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.15rem 0.4rem;
  font: inherit;
  font-size: inherit;
}

.track-manage-rename-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.track-manage-add-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

.track-manage-add-input::placeholder {
  color: var(--muted-foreground);
}

.track-manage-add-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.track-manage-add-item {
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  margin: 0.3rem 0.75rem 0.5rem 2rem;
}

.track-manage-add-item::placeholder {
  color: var(--muted-foreground);
}

.track-manage-add-item:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
}

.track-week-select-empty.track-manage-empty {
  padding: 1.5rem 0.75rem;
}

.tracking-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  color: var(--muted-foreground);
  text-align: center;
}

.tracking-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tracking-overview-head h2 {
  margin: 0.25rem 0 0;
  font-size: 1.2rem;
}

.tracking-overview-summary {
  display: grid;
  grid-template-columns: minmax(10rem, 0.28fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tracking-week-total,
.tracking-day-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 18%, var(--card));
  padding: 0.75rem;
}

.tracking-week-total span,
.tracking-day-card span {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 750;
}

.tracking-week-total strong,
.tracking-day-card strong {
  display: block;
  margin-top: 0.25rem;
  font-family: "JetBrains Mono", "Vazirmatn", monospace;
  font-size: 1.05rem;
}

.tracking-week-total small,
.tracking-day-card small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.35;
}

.tracking-week-total small.is-up,
.tracking-day-card small.is-up {
  color: #15803d;
}

.tracking-week-total small.is-down,
.tracking-day-card small.is-down {
  color: #b91c1c;
}

html.dark .tracking-week-total small.is-up,
html.dark .tracking-day-card small.is-up,
html.amoled .tracking-week-total small.is-up,
html.amoled .tracking-day-card small.is-up {
  color: #4ade80;
}

html.dark .tracking-week-total small.is-down,
html.dark .tracking-day-card small.is-down,
html.amoled .tracking-week-total small.is-down,
html.amoled .tracking-day-card small.is-down {
  color: #f87171;
}

.tracking-day-cards {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
}

.tracking-heat-card {
  box-shadow: none;
}

.tracking-heat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
}

.tracking-heat-toolbar[hidden] {
  display: none;
}

.tracking-heat-toolbar strong {
  color: var(--foreground);
  font-size: 0.95rem;
}

.tracking-heat-card .github-grid-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.tracking-heat-card .habit-heat-months span[data-track-month] {
  position: relative;
  cursor: pointer;
  color: transparent;
  border-radius: 4px;
  overflow: visible;
}

.tracking-heat-card .habit-heat-months span[data-track-month]::before {
  content: attr(data-track-month-label);
  position: absolute;
  inset-block: -2px;
  inset-inline-start: -2px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  color: var(--muted-foreground);
  padding-inline: 2px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.tracking-heat-card .habit-heat-months span[data-track-month]:hover::before,
.tracking-heat-card .habit-heat-months span[data-track-month]:focus::before {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.tracking-heat-card .habit-heat-months span[data-track-month]:focus {
  outline: none;
}

.tracking-heat-card .github-cell {
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tracking-heat-card .github-cell.is-month-dimmed {
  opacity: 0.28;
}

.tracking-heat-card .github-cell.is-month-highlight {
  transform: scale(1.18);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 55%, transparent);
  opacity: 1;
}

.tracking-heat-card .github-grid.is-month-zoom {
  display: grid;
  grid-template-columns: repeat(7, 1.85rem);
  gap: 0.45rem;
  justify-content: center;
  padding: 0.5rem 0 0.25rem;
}

.tracking-heat-card .github-grid.is-month-zoom .github-cell {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
}

/* ===== Habit Tracker ===== */
.habit-board {
  margin-top: 1.5rem;
}

.habit-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.habit-grid {
  min-width: 46rem;
  --habit-cols: minmax(9rem, 16rem) repeat(7, minmax(2.75rem, 1fr));
}

.habit-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--habit-cols);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 62%, var(--card));
}

.habit-corner {
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
  padding: 0.75rem 1rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 650;
}

.habit-day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  border-left: 1px solid var(--border);
  padding: 0.5rem;
  text-align: center;
}

.habit-day-head span {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 650;
}

.habit-day-head strong {
  font-size: 0.82rem;
}

.habit-day-head.is-today {
  background: color-mix(in srgb, var(--muted-foreground) 10%, var(--card));
  color: var(--foreground);
}

.habit-category {
  border-bottom: 1px solid var(--border);
}

.habit-category-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 32%, var(--card));
  padding: 0.7rem 1rem;
}

.habit-category-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.habit-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 700;
}

.habit-category-head [data-habit-cat-delete],
.habit-category-head [data-track-cat-delete] {
  margin-inline-start: auto;
}

.habit-row {
  display: grid;
  grid-template-columns: var(--habit-cols);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.habit-rows .habit-row:last-child {
  border-bottom: 0;
}

.habit-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-right: 1px solid var(--border);
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
}

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

.habit-name .habit-icon-btn {
  opacity: 0;
}

.habit-row:hover .habit-name .habit-icon-btn {
  opacity: 1;
}

.habit-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted-foreground);
  cursor: grab;
  opacity: 0.35;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.habit-drag:active {
  cursor: grabbing;
}

.habit-row:hover .habit-drag,
.habit-category-head .habit-drag {
  opacity: 0.75;
}

.habit-drag:hover {
  opacity: 1;
  color: var(--foreground);
}

.habit-row.is-reordering,
.habit-category.is-reordering {
  opacity: 0.45;
}

.habit-category.is-reordering {
  outline: 2px dashed color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: -2px;
}

.habit-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: background 0.15s ease;
}

.habit-cell:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.habit-cell.is-today-column {
  background: color-mix(in srgb, var(--muted-foreground) 7%, transparent);
}

.habit-cell.is-today-column:hover {
  background: color-mix(in srgb, var(--muted-foreground) 10%, transparent);
}

.habit-cell.is-done {
  background: color-mix(in srgb, #16a34a 22%, var(--card));
  color: #15803d;
}

.habit-cell.is-missed {
  background: color-mix(in srgb, #dc2626 22%, var(--card));
  color: #b91c1c;
}

.habit-cell.is-pending {
  background: color-mix(in srgb, var(--muted-foreground) 24%, var(--card));
  color: var(--muted-foreground);
}

.habit-cell.is-done.is-today-column {
  background: color-mix(in srgb, #16a34a 18%, color-mix(in srgb, var(--muted-foreground) 8%, var(--card)));
}

.habit-cell.is-missed.is-today-column {
  background: color-mix(in srgb, #dc2626 18%, color-mix(in srgb, var(--muted-foreground) 8%, var(--card)));
}

.habit-cell.is-pending.is-today-column {
  background: color-mix(in srgb, var(--muted-foreground) 28%, var(--card));
}

.habit-cell.is-done::before {
  content: "\2713";
}

.habit-cell.is-missed::before {
  content: "\2715";
}

.habit-cell.is-pending::before {
  content: "\2026";
}

html.dark .habit-cell.is-done,
html.amoled .habit-cell.is-done {
  color: #4ade80;
}

html.dark .habit-cell.is-missed,
html.amoled .habit-cell.is-missed {
  color: #f87171;
}

.habit-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.habit-icon-btn:hover {
  background: color-mix(in srgb, #dc2626 14%, transparent);
  color: #b91c1c;
}

.habit-add-row {
  background: color-mix(in srgb, var(--muted) 16%, var(--card));
}

.habit-add-input {
  grid-column: 1 / -1;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0.6rem 1rem;
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
}

.habit-add-input::placeholder {
  color: var(--muted-foreground);
}

.habit-add-input:focus {
  outline: none;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.habit-add-category-wrap {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 22%, var(--card));
}

.habit-add-category-input {
  font-weight: 600;
}

.habit-status-options {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.habit-status-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.habit-status-option:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background: color-mix(in srgb, var(--primary) 5%, var(--card));
}

.habit-dot {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.habit-status-option.is-done .habit-dot {
  background: #16a34a;
  border-color: #16a34a;
}

.habit-status-option.is-missed .habit-dot {
  background: #dc2626;
  border-color: #dc2626;
}

.habit-status-option.is-pending .habit-dot {
  background: var(--muted-foreground);
  border-color: var(--muted-foreground);
}

.habit-status-option.is-empty .habit-dot {
  background: transparent;
}

/* ===== Habit overview heatmap ===== */
.habit-name .habit-overview-btn {
  opacity: 0.5;
}

.habit-row:hover .habit-overview-btn {
  opacity: 1;
}

.habit-overview-btn:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}

.habit-overview-modal {
  width: min(50rem, calc(100vw - 2rem));
}

.habit-overview-head {
  margin-bottom: 1rem;
}

.habit-overview-head h2 {
  margin: 0.25rem 0 0;
  font-size: 1.2rem;
}

.habit-overview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.2rem;
}

.habit-green-switch {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.habit-green-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.habit-green-switch-track {
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.habit-green-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 6px);
  height: calc(1.25rem - 6px);
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease;
}

.habit-green-switch input:checked + .habit-green-switch-track {
  border-color: #16a34a;
  background: #16a34a;
}

.habit-green-switch input:checked + .habit-green-switch-track::after {
  transform: translateX(1rem);
}

.habit-green-switch input:focus-visible + .habit-green-switch-track {
  outline: 2px solid color-mix(in srgb, #16a34a 45%, transparent);
  outline-offset: 2px;
}

.habit-heat-months {
  gap: 3px;
}

.habit-heat-months span {
  flex: 0 0 11px;
  min-width: 0;
  width: 11px;
  overflow: visible;
  white-space: nowrap;
}

.habit-overview-modal .habit-heat-months span[data-habit-month] {
  position: relative;
  color: transparent;
  border-radius: 4px;
  cursor: pointer;
  overflow: visible;
}

.habit-overview-modal .habit-heat-months span[data-habit-month]::before {
  content: attr(data-habit-month-label);
  position: absolute;
  inset-block: -2px;
  inset-inline-start: -2px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  color: var(--muted-foreground);
  padding-inline: 2px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.habit-overview-modal .habit-heat-months span[data-habit-month]:hover::before,
.habit-overview-modal .habit-heat-months span[data-habit-month]:focus::before {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.habit-overview-modal .habit-heat-months span[data-habit-month]:focus {
  outline: none;
}

.habit-overview-modal .github-cell {
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.habit-overview-modal .github-cell.is-month-dimmed {
  opacity: 0.28;
}

.habit-overview-modal .github-cell.is-month-highlight {
  transform: scale(1.18);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 55%, transparent);
  opacity: 1;
}

.habit-heat-legend {
  gap: 0.4rem;
}

.github-cell.habit-done {
  background: #16a34a;
}

.github-cell.habit-missed {
  background: #dc2626;
}

.github-cell.habit-pending {
  background: color-mix(in srgb, var(--muted-foreground) 65%, var(--card));
}

.github-cell.habit-out {
  background: transparent;
}

.exercise-page {
  display: grid;
  min-height: calc(100vh - 3.5rem);
  grid-template-columns: 18rem minmax(0, 1fr);
  background: var(--card);
}

.exercise-sidebar {
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  padding: 1rem;
}

.exercise-main {
  min-width: 0;
}

.exercise-content {
  width: min(100%, 68rem);
  margin-inline: auto;
  padding: 1.5rem;
}

.exercise-list {
  display: grid;
  gap: 0.75rem;
}

.exercise-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 14px 34px rgba(var(--shadow-color), 0.06);
}

.exercise-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.exercise-card p {
  margin: 0.3rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.exercise-card-actions,
.exercise-builder-tools,
.exercise-form-actions,
.exercise-step-actions,
.exercise-runner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.exercise-empty-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.exercise-empty-icon .ui-icon {
  width: 1.5rem;
  height: 1.5rem;
}

.exercise-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 23, 0.42);
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.exercise-modal-backdrop.is-open {
  opacity: 1;
}

.exercise-builder,
.exercise-runner {
  width: min(100%, 48rem);
  max-height: min(46rem, calc(100vh - 2rem));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  transform: translateY(0.6rem) scale(0.98);
  transition: transform 0.2s ease;
}

.exercise-modal-backdrop.is-open .exercise-builder,
.exercise-modal-backdrop.is-open .exercise-runner {
  transform: translateY(0) scale(1);
}

.exercise-form,
.exercise-runner-body {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.exercise-form .form-field,
.exercise-step-grid label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 700;
}

.exercise-form input {
  width: 100%;
  height: 2.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--muted);
  color: var(--foreground);
  padding: 0 0.75rem;
  font: inherit;
}

.exercise-form input:focus {
  border-color: var(--ring);
  outline: 2px solid color-mix(in srgb, var(--ring) 35%, transparent);
  outline-offset: 1px;
}

.exercise-step-list {
  display: grid;
  gap: 0.75rem;
}

.exercise-step-row {
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  padding: 0.85rem;
}

.exercise-step-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.exercise-step-head strong {
  font-size: 0.9rem;
}

.exercise-step-grid {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) repeat(4, minmax(5rem, 0.35fr));
  gap: 0.7rem;
}

.exercise-step-grid.is-rest {
  grid-template-columns: repeat(2, minmax(6rem, 1fr));
}

.exercise-progress {
  display: grid;
  gap: 0.45rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.exercise-progress > div {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--muted);
}

.exercise-progress span span,
.exercise-progress > div > span {
  display: block;
}

.exercise-progress > div > span {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

.exercise-current-step {
  display: grid;
  min-height: 16rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  padding: 2rem;
  text-align: center;
}

.exercise-current-step h3 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.5rem);
}

.exercise-current-step p {
  margin: 0.8rem 0 0;
  color: var(--muted-foreground);
  font-size: 1.05rem;
}

.exercise-countdown {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 800;
}

.exercise-done-btn {
  min-width: 8rem;
}

@media (max-width: 560px) {
  .exercise-page {
    grid-template-columns: 1fr;
  }

  .exercise-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .exercise-content {
    padding-inline: 1rem;
  }

  .exercise-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .exercise-step-grid,
  .exercise-step-grid.is-rest {
    grid-template-columns: 1fr;
  }

  .exercise-builder,
  .exercise-runner {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .todo-page {
    grid-template-columns: 1fr;
  }

  .todo-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .todo-content {
    padding-inline: 1rem;
  }

  .todo-content-head {
    align-items: stretch;
    flex-direction: column;
  }

  .todo-task-form {
    border-radius: var(--radius);
  }

  .todo-task-compose-top,
  .todo-compose-footer {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }

  .todo-compose-tools {
    display: none;
  }

  .todo-compose-chips {
    gap: 0.45rem;
  }

  .todo-chip {
    height: 1.9rem;
    font-size: 0.82rem;
  }

  .todo-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .todo-task-row {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .todo-task-actions {
    grid-column: 3;
  }

  .todo-detail-modal {
    width: calc(100vw - 1rem);
    height: calc(100vh - 1rem);
  }

  .todo-detail-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .todo-detail-main {
    overflow: visible;
    padding: 1rem;
  }

  .todo-detail-side {
    overflow: visible;
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem 1rem;
  }

  .todo-detail-head {
    padding-inline: 0.75rem;
  }

  .todo-detail-title-input {
    font-size: 1.12rem;
  }

  .todo-detail-date-pop {
    right: 0;
    left: 0;
    width: min(100%, 18rem);
  }

  .timer-fields,
  .timer-mode-group {
    grid-template-columns: 1fr;
  }

  .timer-row {
    align-items: stretch;
    flex-direction: column;
  }

  .header-timer-popover {
    right: auto;
    left: 50%;
    width: 12rem;
    transform: translate(-50%, -0.25rem);
  }

  .header-timer:hover .header-timer-popover,
  .header-timer:focus-within .header-timer-popover {
    transform: translate(-50%, 0);
  }

  .habit-overview-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .tracking-overview-summary {
    grid-template-columns: 1fr;
  }

  .tracking-day-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── AI Prompt Generator ─────────────────────────────────── */
.habit-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, backdrop-filter 0.25s ease;
}
.habit-ai-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
.habit-ai-backdrop[hidden] { display: none; }

.habit-ai-modal {
  display: flex;
  flex-direction: column;
  width: min(42rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 24px 80px rgba(var(--shadow-color), 0.28);
  padding: 1.5rem;
  gap: 1.1rem;
  transform: translateY(1.5rem) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.habit-ai-backdrop.is-open .habit-ai-modal {
  transform: translateY(0) scale(1);
}
.habit-ai-history-modal {
  width: min(52rem, calc(100vw - 2rem));
  height: min(82vh, 680px);
  overflow-y: hidden;
  padding-bottom: 0;
}
.habit-ai-history-modal .habit-ai-head { flex-shrink: 0; }
.habit-ai-history-modal .habit-ai-foot { flex-shrink: 0; padding-bottom: 1.5rem; }

.habit-ai-head { display: flex; flex-direction: column; gap: 0.2rem; }
.habit-ai-head h2 { margin: 0; font-size: 1.25rem; }

.habit-ai-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.habit-ai-presets .btn.is-active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.habit-ai-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}
.habit-ai-divider::before,
.habit-ai-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.habit-ai-range-label { font-size: 0.8rem; color: var(--muted-foreground); font-weight: 500; }

.habit-ai-range-preview {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 500;
  min-height: 1.2em;
  margin: 0;
}

.habit-ai-foot {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.habit-ai-prompt-wrap {
  position: relative;
}
.habit-ai-prompt-text {
  width: 100%;
  min-height: 14rem;
  max-height: 22rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  font: 0.78rem/1.55 "Courier New", monospace;
  padding: 0.85rem;
  resize: vertical;
  box-sizing: border-box;
}
.habit-ai-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
}

.habit-ai-response-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.habit-ai-response-text {
  width: 100%;
  min-height: 8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.7rem;
  resize: vertical;
  box-sizing: border-box;
  direction: rtl;
}
.habit-ai-model-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.habit-ai-model-input {
  flex: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--muted);
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.3rem 0.6rem;
}

/* History */
.habit-ai-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.habit-ai-history-empty { color: var(--muted-foreground); font-size: 0.9rem; }
.habit-ai-history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  overflow: hidden;
}
.habit-ai-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.875rem;
}
.habit-ai-history-summary::-webkit-details-marker { display: none; }
.habit-ai-history-range { font-weight: 600; color: var(--foreground); }
.habit-ai-history-meta { color: var(--muted-foreground); font-size: 0.78rem; }
.habit-ai-history-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.habit-ai-history-response {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--foreground);
  direction: rtl;
  white-space: pre-wrap;
  margin: 0;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.habit-ai-history-del { font-size: 0.78rem; align-self: flex-start; }

/* ── AI Prompt date range calendar ────────────────────────── */
.habit-ai-cal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.habit-ai-cal-side { display: flex; flex-direction: column; gap: 0.3rem; }
.habit-ai-date-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 0.8rem;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.habit-ai-date-trigger:hover { border-color: var(--primary); color: var(--foreground); }
.habit-ai-date-trigger.has-value {
  border-style: solid;
  border-color: var(--primary);
  color: var(--foreground);
  font-weight: 600;
}

.habit-ai-cal-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  padding: 0.6rem;
}
.habit-ai-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.habit-ai-cal-nav {
  border: none;
  background: none;
  color: var(--muted-foreground);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
}
.habit-ai-cal-nav:hover { background: var(--muted); color: var(--foreground); }
.habit-ai-cal-title { font-weight: 700; font-size: 0.9rem; }
.habit-ai-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 3px;
}
.habit-ai-cal-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted-foreground);
  font-weight: 600;
}
.habit-ai-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.habit-ai-cal-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 5px;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--foreground);
  transition: background 0.1s;
}
.habit-ai-cal-day:hover { background: var(--muted); }
.habit-ai-cal-day.is-empty { cursor: default; }
.habit-ai-cal-day.is-today { font-weight: 800; color: var(--primary); }
.habit-ai-cal-day.is-from,
.habit-ai-cal-day.is-to {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
}
.habit-ai-cal-day.is-in-range {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--foreground);
}
.habit-ai-cal-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin: 0.35rem 0 0;
}

.track-ai-plan-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--foreground);
  cursor: pointer;
  user-select: none;
}
.track-ai-plan-toggle input { cursor: pointer; accent-color: var(--primary); }

/* ── AI history confirm + edit ────────────────────────────── */
.ai-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ai-confirm-overlay.is-open { opacity: 1; }
.ai-confirm-box {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: min(22rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  padding: 1.4rem 1.5rem;
  box-shadow: 0 20px 60px rgba(var(--shadow-color), 0.3);
  transform: scale(0.93);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
}
.ai-confirm-overlay.is-open .ai-confirm-box { transform: scale(1); }
.ai-confirm-msg { margin: 0; font-size: 0.9rem; }
.ai-confirm-btns { display: flex; gap: 0.5rem; justify-content: flex-end; }

.habit-ai-history-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.habit-ai-hist-action-btn { font-size: 0.78rem; padding: 0.22rem 0.7rem; }
.habit-ai-hist-action-btn.is-danger { color: #dc2626; border-color: #dc2626; }
.habit-ai-hist-action-btn.is-danger:hover { background: #dc2626; color: #fff; }

.habit-ai-hist-badge {
  display: inline-block;
  font-size: 0.7rem;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border-radius: 4px;
  padding: 0 0.3rem;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.habit-ai-history-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.habit-ai-history-edit-resp {
  min-height: 10rem;
  max-height: 30vh;
}
.habit-ai-history-edit-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ===== Color select with preview ===== */
.time-color-select-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.time-color-select-row select {
  flex: 1;
}
.time-color-preview-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  transition: background 0.15s;
}

/* ===== Extra time block colors ===== */
.time-block.color-indigo { --block-color: #4f46e5; }
.time-block.color-teal   { --block-color: #0d9488; }
.time-block.color-orange { --block-color: #ea580c; }
.time-block.color-black  { --block-color: #18181b; }

.time-detail-hero.color-indigo { background: #4f46e5; color: #fff; }
.time-detail-hero.color-teal   { background: #0d9488; color: #fff; }
.time-detail-hero.color-orange { background: #ea580c; color: #fff; }
.time-detail-hero.color-black  { background: #18181b; color: #fff; }

/* ===== Calendar management ===== */

/* Page body layout */
.time-page-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.time-cals-sidebar {
  width: 13rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.6rem;
}

.time-main-area {
  flex: 1;
  min-width: 0;
}

.time-cals-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.2rem 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.4rem;
}

.time-cals-label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.time-cals-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.time-cals-add-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.time-cal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.time-cals-empty {
  padding: 0.4rem 0.2rem;
  font-size: 0.8rem;
}

.time-cal-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.time-cal-item:hover {
  background: var(--muted);
}
.time-cal-item.is-active {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.time-cal-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.time-cal-name {
  flex: 1;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.time-cal-item.is-active .time-cal-name {
  font-weight: 650;
}

.time-cal-actions {
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.12s;
}
.time-cal-item:hover .time-cal-actions {
  opacity: 1;
}

.time-cal-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.time-cal-action-btn:hover {
  color: var(--foreground);
  background: var(--muted);
}
.time-cal-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Calendar modals */
.cal-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--shadow-color), 0.32);
  backdrop-filter: blur(2px);
}
.cal-modal-backdrop[hidden] {
  display: none;
}

.cal-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(80vh, 36rem);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1.1rem 1.25rem;
  box-shadow: 0 24px 70px rgba(var(--shadow-color), 0.22);
}

.cal-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.cal-modal-head h2 {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
}

.cal-modal form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cal-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.cal-color-swatch {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.cal-color-swatch:hover {
  transform: scale(1.12);
}
.cal-color-swatch.is-selected {
  border-color: var(--foreground);
  transform: scale(1.12);
}

.cal-modal-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Calendar delete modal */
.cal-delete-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.cal-delete-body p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}
.cal-delete-body p strong {
  color: var(--foreground);
}
.cal-delete-prompt {
  font-weight: 500;
}
.cal-delete-body code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  background: var(--muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.cal-delete-input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.875rem;
  font-family: "JetBrains Mono", monospace;
}
.cal-delete-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--ring), 0.25);
}

@media (max-width: 900px) {
  .time-page-body {
    flex-direction: column;
  }
  .time-cals-sidebar {
    width: 100%;
  }
  .time-cal-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .time-cal-item {
    width: auto;
  }
  .time-cal-actions {
    opacity: 1;
  }
}
