.fn-routines-open { overflow: hidden; }

.fn-routines-overlay {
  position: fixed;
  inset: 0;
  z-index: 2600;
  background: rgba(24, 24, 26, .42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.fn-routines-sheet {
  position: relative;
  width: min(760px, 100%);
  max-height: min(90dvh, 900px);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface, #fff);
  color: var(--text, #232323);
  border: 1px solid color-mix(in srgb, var(--text, #222) 8%, transparent);
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .22);
}

.fn-routines-header,
.fn-routine-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
}

.fn-routines-header span,
.fn-routine-editor-head span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .55;
}

.fn-routines-header h2,
.fn-routine-editor-head h2 {
  margin: 0;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.05;
}

.fn-routines-header p {
  margin: 8px 0 0;
  color: var(--muted, #6d6d72);
}

.fn-routines-close,
.fn-routine-editor-head > button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text, #222) 7%, transparent);
  color: inherit;
  font-size: 28px;
  line-height: 1;
}

.fn-routine-editor-head > button {
  order: -1;
  font-size: 34px;
}

.fn-routine-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 24px;
  padding: 4px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text, #222) 6%, transparent);
}

.fn-routine-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
}

.fn-routine-tabs button.active {
  background: var(--surface, #fff);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}

.fn-routines-content { padding: 20px 24px 28px; }

.fn-routine-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #6f8b77) 15%, var(--surface, #fff)), color-mix(in srgb, var(--accent, #6f8b77) 5%, var(--surface, #fff)));
}

.fn-routine-summary span,
.fn-routine-summary small { display: block; color: var(--muted, #6d6d72); }
.fn-routine-summary strong { display: block; margin: 3px 0; font-size: 28px; }

.fn-routine-ring {
  --progress: 0%;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: conic-gradient(var(--accent, #6f8b77) var(--progress), color-mix(in srgb, var(--text, #222) 8%, transparent) 0);
  display: grid;
  place-items: center;
  position: relative;
}

.fn-routine-ring::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: var(--surface, #fff);
}

.fn-routine-ring b { position: relative; z-index: 1; font-size: 13px; }

.fn-routine-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.fn-routine-section-head > div { display: flex; align-items: baseline; gap: 8px; }
.fn-routine-section-head h3 { margin: 0; font-size: 18px; }
.fn-routine-section-head span { color: var(--muted, #737378); font-size: 13px; }
.fn-routine-section-head button {
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  background: color-mix(in srgb, var(--accent, #6f8b77) 12%, transparent);
  color: inherit;
  font: inherit;
  font-weight: 700;
}

.fn-routine-list,
.fn-routine-definitions { display: grid; gap: 9px; }

.fn-routine-row,
.fn-routine-definition {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--text, #222) 8%, transparent);
  border-radius: 17px;
  background: color-mix(in srgb, var(--surface, #fff) 96%, var(--text, #222));
}

.fn-routine-row.is-done { opacity: .65; }
.fn-routine-row.is-done strong { text-decoration: line-through; }
.fn-routine-row.is-skipped { opacity: .52; }

.fn-routine-check {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent, #6f8b77) 60%, #8b8b8f);
  background: transparent;
  color: var(--surface, #fff);
  font-size: 18px;
  font-weight: 800;
}

.fn-routine-row.is-done .fn-routine-check { background: var(--accent, #6f8b77); border-color: var(--accent, #6f8b77); }
.fn-routine-row.is-skipped .fn-routine-check { background: color-mix(in srgb, var(--text, #222) 42%, transparent); border-color: transparent; }
.fn-routine-check:disabled { opacity: .35; }

.fn-routine-row-copy,
.fn-routine-definition-copy { min-width: 0; }
.fn-routine-row-copy > div,
.fn-routine-definition-copy > div { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.fn-routine-row-copy strong,
.fn-routine-definition-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.fn-routine-row-copy small { display: block; margin-top: 3px; color: var(--muted, #717178); }
.fn-routine-part,
.fn-routine-assignee,
.fn-routine-paused,
.fn-routine-definition-copy em {
  font-size: 11px;
  font-style: normal;
  line-height: 1.2;
  color: var(--muted, #727278);
}

.fn-routine-paused {
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, #c98734 14%, transparent);
  color: #9a5f18;
  font-weight: 700;
}

.fn-routine-definition-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent, #6f8b77) 11%, transparent);
}

.fn-routine-definition-copy small { display: block; margin: 3px 0; color: var(--muted, #707078); }
.fn-routine-definition.is-paused { opacity: .58; }

.fn-routine-more {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-size: 16px;
}

.fn-routine-empty,
.fn-routine-loading {
  padding: 24px 18px;
  text-align: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--text, #222) 4%, transparent);
}
.fn-routine-empty strong,
.fn-routine-empty span { display: block; }
.fn-routine-empty span { margin-top: 5px; color: var(--muted, #74747b); font-size: 13px; }

.fn-routine-editor { padding: 0 24px 28px; }
.fn-routine-editor-head { padding-left: 0; padding-right: 48px; }
.fn-routine-editor > label,
.fn-routine-form-grid > label,
.fn-routine-monthday {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}
.fn-routine-editor label > span { font-size: 12px; font-weight: 700; color: var(--muted, #696970); }
.fn-routine-editor input,
.fn-routine-editor select,
.fn-routine-editor textarea {
  width: 100%;
  min-height: 46px;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--text, #222) 12%, transparent);
  border-radius: 13px;
  padding: 11px 12px;
  background: color-mix(in srgb, var(--surface, #fff) 96%, var(--text, #222));
  color: inherit;
  font: inherit;
}
.fn-routine-editor textarea { resize: vertical; }
.fn-routine-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.fn-routine-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: -2px 0 15px;
}
.fn-routine-weekdays.hidden,
.fn-routine-monthday.hidden { display: none; }
.fn-routine-weekdays label { position: relative; }
.fn-routine-weekdays input { position: absolute; opacity: 0; pointer-events: none; }
.fn-routine-weekdays span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text, #222) 5%, transparent);
  font-size: 12px;
  font-weight: 700;
}
.fn-routine-weekdays input:checked + span {
  background: var(--accent, #6f8b77);
  color: #fff;
}

.fn-routine-editor-actions { display: grid; gap: 9px; margin-top: 10px; }
.fn-routine-editor-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text, #222) 7%, transparent);
  color: inherit;
  font: inherit;
  font-weight: 750;
}
.fn-routine-editor-actions .primary { background: var(--accent, #6f8b77); color: #fff; }
.fn-routine-editor-actions .danger { color: #b84646; }

.fn-routine-action-menu {
  position: fixed;
  z-index: 2800;
  display: grid;
  padding: 7px;
  border-radius: 15px;
  background: var(--surface, #fff);
  border: 1px solid color-mix(in srgb, var(--text, #222) 10%, transparent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .18);
}
.fn-routine-action-menu button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  text-align: left;
  background: transparent;
  color: inherit;
  font: inherit;
}
.fn-routine-action-menu button:active { background: color-mix(in srgb, var(--text, #222) 7%, transparent); }

.fn-routines-today-card { margin-top: 14px; }
.fn-routine-progress {
  height: 6px;
  overflow: hidden;
  margin: 2px 0 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text, #222) 7%, transparent);
}
.fn-routine-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent, #6f8b77); transition: width .25s ease; }
.fn-routine-today-list { display: grid; gap: 8px; }
.fn-routines-today-card .fn-routine-row { min-height: 58px; padding: 8px 10px; }
.fn-routine-show-all {
  width: 100%;
  margin-top: 8px;
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent, #6f8b77) 8%, transparent);
  color: inherit;
  font: inherit;
  font-weight: 700;
}
.fn-routine-quick-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 22px;
}

@media (min-width: 760px) {
  .fn-routines-overlay { align-items: center; }
  .fn-routines-sheet { max-height: min(86dvh, 900px); }
}

@media (max-width: 540px) {
  .fn-routines-overlay { padding: 0; align-items: flex-end; }
  .fn-routines-sheet {
    width: 100%;
    max-height: 94dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .fn-routines-header { padding: 22px 18px 16px; }
  .fn-routine-tabs { margin: 0 18px; }
  .fn-routines-content { padding: 18px 18px 26px; }
  .fn-routine-editor { padding: 0 18px 26px; }
  .fn-routine-form-grid { grid-template-columns: 1fr; gap: 0; }
  .fn-routine-weekdays { gap: 4px; }
  .fn-routine-weekdays span { min-height: 36px; font-size: 11px; }
}
